// NOTE: // Base svg was authored with Inkscape. // On Inkscape, by using "Object to Path", text is converted to path, which enables consistent layout on browser. // `composeGlyph` expects elements in a 0,0,100,100 view box // // Note, if you use, markers, markers style="fill:context-stroke" is not supported yet by safari, so you have to edit the file manually to set the color // // Inkscape's output includes unnecessary attributes which can be cleaned up with https://lean-svg.netlify.app. // Small tweak (e.g. changing color, scaling size, etc...) can be done by directly modifying svg below. // the glyphs are laid-down from right to left // with the first glyph being at the top right, then progressively to the left, until the top left const glyphStacktoPx = (maxGlyphs: number, stack: number) => ({ x: 71 - (stack % maxGlyphs) * 28, y: -12, }); const makeComposeGlyph = (maxGlyphs: number) => (fill: string, path: string) => (stackedNumber: number) => { const { x, y } = glyphStacktoPx(maxGlyphs, stackedNumber); return `${path}`; }; export const glyphToSvg = (maxGlyphs: number): Record string> => { const composeGlyph = makeComposeGlyph(maxGlyphs); const whiteIsWinning = composeGlyph( '#bbb', '', ); const blackIsWinning = composeGlyph( '#333', '', ); return { // Inaccuracy '?!': composeGlyph( '#56b4e9', '', ), // Mistake '?': composeGlyph( '#e69f00', '', ), // Blunder '??': composeGlyph( '#df5353', '', ), // Interesting move '!?': composeGlyph( '#ea45d8', '', ), // Good move '!': composeGlyph( '#22ac38', '', ), // Brilliant move '!!': composeGlyph( '#168226', '', ), // Correct move in a puzzle '✓': composeGlyph( '#22ac38', '', ), // Incorrect move in a puzzle '✗': composeGlyph( '#df5353', '', ), // 1st repetition when a game ends in 3 or 5fold repetition '①': composeGlyph( '#6e7781', '1', ), // 2nd repetition when a game ends in 3 or 5fold repetition '②': composeGlyph( '#6e7781', '2', ), // 3rd repetition when a game ends in 3 or 5fold repetition '③': composeGlyph( '#6e7781', '3', ), // 4th repetition when a game ends in 3 or 5fold repetition '④': composeGlyph( '#6e7781', '4', ), // 5th repetition when a game ends in 3 or 5fold repetition '⑤': composeGlyph( '#6e7781', '5', ), // Only move '□': composeGlyph( '#a04048', '', ), // Zugzwang '⨀': composeGlyph( '#9171f2', '', ), // Equal position '=': composeGlyph( '#82c2ef', '', ), // Unclear position '∞': composeGlyph( '#f5918f', '', ), // White is slightly better '⩲': composeGlyph( '#999', '', ), // Black is slightly better '⩱': composeGlyph( '#555', '', ), // White is better '±': composeGlyph( '#aaa', '', ), // Black is better '∓': composeGlyph( '#444', '', ), // White is winning '+−': whiteIsWinning, '+-': whiteIsWinning, // Black is winning '−+': blackIsWinning, '-+': blackIsWinning, // Novelty N: composeGlyph( '#90c290', '', ), // Development '↑↑': composeGlyph( '#c87e9d', '', ), // Initiative '↑': composeGlyph( '#2660a4', '', ), // Attack '→': composeGlyph( '#fb0e3d', '', ), // Counterplay '⇆': composeGlyph( '#ff784f', '', ), // Time trouble '⊕': composeGlyph( '#c2095a', '', ), // With compensation '=∞': composeGlyph( '#180aae', '', ), // With the idea '∆': composeGlyph( '#c8c831', '', ), }; }; export const analysisGlyphs = (maxGlyphs: number): Record string> => { const composeGlyph = makeComposeGlyph(maxGlyphs); return { pin: composeGlyph( '#333', '', ), undefended: composeGlyph( '#df5353', '', ), checkable: composeGlyph('#2660a4', ''), trapped: composeGlyph( '#df5353', '', ), }; }; export type EndgameOutcome = 'mate' | 'resign' | 'abandoned' | 'outoftime' | 'unknown' | 'draw' | 'stalemate'; export const endgameGlyphs = ( maxGlyphs: number, ): Record string> => { const composeGlyph = makeComposeGlyph(maxGlyphs); return { mate: composeGlyph( '#df5353', '', ), resign: composeGlyph( '#df5353', '', ), abandoned: composeGlyph( '#df5353', '', ), outoftime: composeGlyph( '#df5353', '', ), unknown: composeGlyph( '#df5353', '', ), draw: composeGlyph( '#82c2ef', '', ), stalemate: composeGlyph( '#82c2ef', '', ), }; };