dkforest

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

commit b30038a91a2813be8a5eb5ab0b1b6f4534670f26
parent f07e38b34e0c80e70348dfea69180b83cf4c2127
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri,  2 Jun 2023 00:12:33 -0700

Add coords to chess board

Diffstat:
Mpkg/web/handlers/api/v1/chess.go | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/api/v1/chess.go b/pkg/web/handlers/api/v1/chess.go @@ -158,6 +158,24 @@ func renderSquare(ctx *gg.Context, sq chess.Square, last *chess.Move, turn chess } } } + + ctx.Push() + ctx.SetColor(color.RGBA{R: 0, G: 0, B: 0, A: 180}) + if isFlipped { + if sq.Rank() == chess.Rank8 { + ctx.DrawString(sq.File().String(), float64(x+1), float64(y+sqSize-1)) + } else if sq.File() == chess.FileH { + ctx.DrawString(sq.Rank().String(), float64(x+1), float64(y+sqSize-1)) + } + } else { + if sq.Rank() == chess.Rank1 { + ctx.DrawString(sq.File().String(), float64(x+1), float64(y+sqSize-1)) + } else if sq.File() == chess.FileA { + ctx.DrawString(sq.Rank().String(), float64(x+1), float64(y+sqSize-1)) + } + } + ctx.Pop() + // draw piece p := sqPiece if p != chess.NoPiece {