Team Ai
Apppublic

broadfield-dev/stack-overflow-game

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
test-canvas.js25 linesDownload Raw Back to scripts
1import { createCanvas } from 'canvas';2import fs from 'fs';3 4const canvas = createCanvas(256, 224);5const ctx = canvas.getContext('2d');6 7// Fill with white8ctx.fillStyle = '#FFFFFF';9ctx.fillRect(0, 0, 256, 224);10 11// Draw a big red rectangle12ctx.fillStyle = '#FF0000';13ctx.fillRect(50, 50, 100, 100);14 15// Draw a blue circle16ctx.fillStyle = '#0000FF';17ctx.beginPath();18ctx.arc(200, 100, 30, 0, Math.PI * 2);19ctx.fill();20 21const buffer = canvas.toBuffer('image/png');22fs.writeFileSync('test-canvas.png', buffer);23console.log('Test image created:', buffer.length, 'bytes');24 25