/** * Generates a complete svg image from a PuzzleData object * * @param {PuzzleData} puzzleData */ export function getPuzzleSvg(puzzleData){ const textSize = 21 const textWeigth = 'normal' const textColor = puzzleData.colors['text'] const shapeSVG = createShape(puzzleData.shape, puzzleData.colors['shape']) const topText = createText(puzzleData.text[0].toUpperCase(), textColor, textSize, textWeigth, 31) const bottomText = createText(puzzleData.text[1].toUpperCase(), textColor, textSize, textWeigth, 67) const numberText = createText(puzzleData.number, puzzleData.colors['number'], 60, 100, 50, 'Arial, Helvetica') return createSVG([shapeSVG, topText, bottomText, numberText]) } // Takes multiple SVG strings and combines them to a svg const createSVG = (elements) => ` ${elements.join("\n")} ` const createShape = (shape, color) => SHAPE_SVG[shape](color) const SHAPE_SVG = { "square" : (c) => ``, "triangle": (c) => ``, "rectangle" : (c) =>``, "circle" : (c) => ``, } const createText = (text, color, size, weight, y, font) => ` ${text} `