This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
The following function is used to re-create Pixelglyphs from on-chain data. | |
Original glyphs were created with the following: | |
const matrix = [ [ 0, 0, 0, 0, 0 ], [ 0, 1, 1, 0, 1 ], [ 0, 1, 1, 0, 0 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 1, 1, 1, 1 ], [ 0, 1, 0, 0, 0 ], [ 0, 1, 1, 1, 1 ], [ 0, 1, 1, 1, 1 ], [ 0, 0, 0, 0, 0 ] ]; | |
const colors = [ "rgb(93,19,36)", "rgb(123,234,113)", "rgb(173,109,23)" ]; | |
render(canvasElement, matrix, 37, ...colors); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Request, Response } from "express"; | |
import { createCanvas } from "canvas"; | |
import GifEncoder from "gifencoder"; | |
export async function generateImage(label: string): Promise<Buffer> { | |
const width = 955; | |
const height = 500; | |
const canvas = createCanvas(width, height); | |
const ctx = canvas.getContext("2d"); |