diff --git a/src/blockies.mjs b/src/blockies.mjs index 4b908b7..596bcf4 100644 --- a/src/blockies.mjs +++ b/src/blockies.mjs @@ -111,3 +111,30 @@ export function createIcon(opts) { return canvas; } + +export function renderIconSVG(opts) { + opts = buildOpts(opts); + const imageData = createImageData(opts.size); + const width = Math.sqrt(imageData.length); + + const size = opts.size * opts.scale; + + let svg = ''; + svg += ''; + + for (let i = 0; i < imageData.length; i++) { + + // if data is 0, leave the background + if (imageData[i]) { + const row = Math.floor(i / width); + const col = i % width; + + // if data is 2, choose spot color, if 1 choose foreground + const fill = (imageData[i] == 1) ? opts.color : opts.spotcolor; + + svg += ''; + } + } + + return svg + ''; +}