dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 28936f809d83f3189e6a239a91e9c45d36208df7
parent 903f73d9fce30cf8a31667dcd3af37c75ee2e0d8
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri, 16 Jun 2023 08:50:56 -0700

cleanup arrows & simplify math

Diffstat:
Mpkg/web/handlers/chess.go | 9++++++---
Mpkg/web/handlers/interceptors/chess.go | 12++++++------
2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go @@ -945,11 +945,14 @@ func arrow(s1, s2 chess.Square, isFlipped bool) (out string) { var h string if isDiag { dist /= 2 - h = fmt.Sprintf("calc(%d*17.67%% + 10.67%%)", dist-1) + // sqrt(100^2 + 100^2) = 141.42 + // sqrt(30^2 + 30^2) = 42.43 + h = fmt.Sprintf("calc(%d*141.42%% + 42.43%% + 55%%)", dist-1) } else if isLine { - h = fmt.Sprintf("calc(%d*12.5%% + 5.5%%)", dist-1) + h = fmt.Sprintf("calc(%d*100%% + 55%%)", dist-1) } else { - h = fmt.Sprintf("calc(20.95%%)") + // sqrt(100^2 + 200^2) = 223.60 + h = fmt.Sprintf("calc(223.60%% - 45%%)") } out += fmt.Sprintf("#arrow .rectangle { height: %s !important; }", h) return diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go @@ -142,24 +142,24 @@ var ChessCSS = ` top: 0; left: 0; width: 12.5%; - height: 100%; + height: 12.5%; z-index: 4; pointer-events: none; } #arrow .triangle-up { position: absolute; - width: 40%; - height: 7%; - left: 30%; + width: 60%; + height: 45%; + left: 20%; background: rgba(0, 0, 255, 0.6); clip-path: polygon(0% 100%, 50% 0%, 100% 100%); } #arrow .rectangle { position: absolute; - top: 7%; + top: 45%; left: 42.5%; width: 15%; - height: 5.5%; + height: 55%; background-color: rgba(0, 0, 255, 0.6); border-radius: 0 0 10px 10px }