From 2b4ead47ace8f175ee80345047c86eca6a7294fb Mon Sep 17 00:00:00 2001 From: Paul Yew <42766966+ypaul21@users.noreply.github.com> Date: Sat, 29 Aug 2026 19:13:19 +0200 Subject: [PATCH] Add pieces for Shogi and Janggi --- src/sheets/chess.ts | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/sheets/chess.ts b/src/sheets/chess.ts index 809b3a6..9253cb9 100644 --- a/src/sheets/chess.ts +++ b/src/sheets/chess.ts @@ -640,4 +640,58 @@ sheet.glyphs.set("chess-rook-solid-traditional", (canvas: SVGContainer) => { return symbol; }); +sheet.glyphs.set("piece-shogi", (canvas: SVGContainer) => { + const symbol = canvas.symbol(); + const border = 5; + const pts: [number, number][] = [ + [-92, 105], + [92, 105], + [73, -66], + [0, -105], + [-73, -66], + ]; + symbol.polygon(pts) + .attr("data-context-border", true) + .attr("data-playerfill", true) + .fill("#fff") + .stroke({width: border, color: "#000"}); + + const minX = Math.min(...pts.map(([x]) => x)); + const maxX = Math.max(...pts.map(([x]) => x)); + const minY = Math.min(...pts.map(([, y]) => y)); + const maxY = Math.max(...pts.map(([, y]) => y)); + symbol.viewbox( + minX - border, minY - border, + maxX - minX + (border * 2), maxY - minY + (border * 2), + ); + return symbol; +}); + +sheet.glyphs.set("piece-janggi", (canvas: SVGContainer) => { + const symbol = canvas.symbol(); + const border = 5; + const radius = 100; + const pts: [number, number][] = []; + for (let i = 0; i < 8; i++) { + const degrees = 22.5 + (45 * i); + const [x, y] = projectPoint(0, 0, radius, degrees); + pts.push([x, y]); + } + symbol.polygon(pts) + .attr("data-context-border", true) + .attr("data-playerfill", true) + .fill("#fff") + .stroke({width: border, color: "#000"}); + + const minX = Math.min(...pts.map(([x]) => x)); + const maxX = Math.max(...pts.map(([x]) => x)); + const minY = Math.min(...pts.map(([, y]) => y)); + const maxY = Math.max(...pts.map(([, y]) => y)); + symbol.viewbox( + minX - border, minY - border, + maxX - minX + (border * 2), maxY - minY + (border * 2), + ); + return symbol; +}); + export { sheet as ChessSheet };