1 files changed,
34 insertions(+),
19 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-07-04 16:34:07 +0300
Authored at:
2026-07-04 15:41:38 +0300
Change ID:
qymloyxnnuqtykylnznxxxuwmxuxryxr
Parent:
9d6800b
M
board.typ
ยทยทยท 83 83 #let render-board(board) = { 84 84 let files = ("a", "b", "c", "d", "e", "f", "g", "h") 85 85 let ranks = ("8", "7", "6", "5", "4", "3", "2", "1") 86 - 87 - let light-square = rgb("#f0d9b5") 88 - let dark-square = rgb("#b58863") 89 - 90 86 let cell-size = 2.8em 91 - let coord-size = 0.6em 87 + let label-size = 0.4em 88 + let white = rgb("#f0d9b5") 89 + let black = rgb("#b58863") 92 90 93 91 align(center + horizon, grid( 94 - columns: (coord-size,) + (cell-size,) * 8, 95 - rows: (cell-size,) * 8 + (coord-size,), 92 + columns: (cell-size,) * 8, 93 + rows: (cell-size,) * 8, 96 94 ..{ 97 - let rows = () 95 + let cells = () 98 96 for rank in range(8) { 99 - rows.push(text(size: coord-size, ranks.at(rank))) 100 97 for file in range(8) { 101 98 let piece = board.at(rank).at(file) 102 - let sq-color = if is-dark-sq(file, rank) { dark-square } else { light-square } 103 - let display = if piece == "." { [] } else { image("assets/" + piece-assets.at(piece), width: cell-size * 0.85) } 104 - rows.push(box(width: cell-size, 105 - height: cell-size, 106 - fill: sq-color, 107 - align(center + horizon, display))) 99 + let sq-color = if is-dark-sq(file, rank) { black } else { white } 100 + let display = if piece == "." { [] } else { 101 + image("assets/" + piece-assets.at(piece), width: cell-size * 0.85) 102 + } 103 + 104 + let labels = () 105 + if rank == 7 { 106 + labels.push(place(bottom + left, dx: 0.15em, dy: -0.15em, text( 107 + size: label-size, 108 + fill: if is-dark-sq(file, 7) { white } else { black }, 109 + files.at(file), 110 + ))) 111 + } 112 + if file == 7 { 113 + labels.push(place(top + right, dx: -0.15em, dy: 0.15em, text( 114 + size: label-size, 115 + fill: if is-dark-sq(7, rank) { white } else { black }, 116 + ranks.at(rank), 117 + ))) 118 + } 119 + 120 + cells.push(box( 121 + width: cell-size, 122 + height: cell-size, 123 + fill: sq-color, 124 + place(center + horizon, display) + labels.fold([], (acc, l) => acc + l), 125 + )) 108 126 } 109 127 } 110 - rows.push([]) 111 - for f in files { rows.push(text(size: coord-size, f)) } 112 - 113 - rows 128 + cells 114 129 }, 115 130 )) 116 131 }