| | |
| | |
| | |
| | |
| |
|
| | import fs from 'fs'; |
| | import path from 'path'; |
| | import { fileURLToPath } from 'url'; |
| |
|
| | const __filename = fileURLToPath(import.meta.url); |
| | const __dirname = path.dirname(__filename); |
| | const projectRoot = path.join(__dirname, '..'); |
| |
|
| | async function generateTemplate() { |
| | try { |
| | const { createCanvas } = await import('canvas'); |
| | const canvas = createCanvas(256, 224); |
| | const ctx = canvas.getContext('2d'); |
| |
|
| | console.log('Canvas created:', canvas.width, 'x', canvas.height); |
| |
|
| | |
| | ctx.globalAlpha = 1.0; |
| |
|
| | |
| | ctx.fillStyle = 'rgb(204, 204, 204)'; |
| | ctx.fillRect(0, 0, 256, 224); |
| |
|
| | |
| | ctx.fillStyle = 'rgb(255, 0, 255)'; |
| | ctx.fillRect(88, 32, 80, 160); |
| |
|
| | |
| | ctx.strokeStyle = '#CC00CC'; |
| | ctx.lineWidth = 1; |
| | |
| | for (let x = 88; x <= 168; x += 8) { |
| | ctx.beginPath(); |
| | ctx.moveTo(x, 32); |
| | ctx.lineTo(x, 192); |
| | ctx.stroke(); |
| | } |
| | |
| | for (let y = 32; y <= 192; y += 8) { |
| | ctx.beginPath(); |
| | ctx.moveTo(88, y); |
| | ctx.lineTo(168, y); |
| | ctx.stroke(); |
| | } |
| |
|
| | |
| | ctx.strokeStyle = '#000000'; |
| | ctx.lineWidth = 2; |
| | ctx.strokeRect(88, 32, 80, 160); |
| |
|
| | |
| | ctx.fillStyle = '#000000'; |
| | ctx.font = 'bold 12px sans-serif'; |
| |
|
| | |
| | ctx.fillText('TETRIS BACKDROP TEMPLATE', 40, 15); |
| | ctx.font = '10px sans-serif'; |
| | ctx.fillText('256 x 224 pixels', 85, 215); |
| |
|
| | |
| | ctx.fillStyle = '#FFFFFF'; |
| | ctx.font = 'bold 10px sans-serif'; |
| | ctx.fillText('PLAY AREA', 100, 110); |
| | ctx.fillText('80 x 160', 105, 122); |
| |
|
| | |
| | ctx.fillStyle = '#000000'; |
| | ctx.font = '8px sans-serif'; |
| | ctx.fillText('(88,32)', 90, 28); |
| | ctx.fillText('(168,192)', 130, 200); |
| |
|
| | |
| | ctx.fillStyle = '#666666'; |
| | ctx.font = '8px sans-serif'; |
| | ctx.fillText('SCORE/LEVEL', 10, 20); |
| | ctx.fillText('AREA', 10, 30); |
| |
|
| | ctx.fillText('NEXT PIECE', 185, 20); |
| | ctx.fillText('AREA', 185, 30); |
| |
|
| | |
| | ctx.fillStyle = '#FF0000'; |
| | const markerSize = 6; |
| | |
| | ctx.fillRect(88 - markerSize/2, 32 - markerSize/2, markerSize, markerSize); |
| | |
| | ctx.fillRect(168 - markerSize/2, 32 - markerSize/2, markerSize, markerSize); |
| | |
| | ctx.fillRect(88 - markerSize/2, 192 - markerSize/2, markerSize, markerSize); |
| | |
| | ctx.fillRect(168 - markerSize/2, 192 - markerSize/2, markerSize, markerSize); |
| |
|
| | |
| | ctx.strokeStyle = '#000000'; |
| | ctx.lineWidth = 1; |
| | ctx.fillStyle = '#000000'; |
| |
|
| | |
| | ctx.beginPath(); |
| | ctx.moveTo(88, 25); |
| | ctx.lineTo(168, 25); |
| | ctx.stroke(); |
| | |
| | ctx.beginPath(); |
| | ctx.moveTo(88, 25); |
| | ctx.lineTo(92, 23); |
| | ctx.lineTo(92, 27); |
| | ctx.closePath(); |
| | ctx.fill(); |
| | ctx.beginPath(); |
| | ctx.moveTo(168, 25); |
| | ctx.lineTo(164, 23); |
| | ctx.lineTo(164, 27); |
| | ctx.closePath(); |
| | ctx.fill(); |
| | ctx.fillText('80px', 120, 23); |
| |
|
| | |
| | ctx.beginPath(); |
| | ctx.moveTo(82, 32); |
| | ctx.lineTo(82, 192); |
| | ctx.stroke(); |
| | |
| | ctx.beginPath(); |
| | ctx.moveTo(82, 32); |
| | ctx.lineTo(80, 36); |
| | ctx.lineTo(84, 36); |
| | ctx.closePath(); |
| | ctx.fill(); |
| | ctx.beginPath(); |
| | ctx.moveTo(82, 192); |
| | ctx.lineTo(80, 188); |
| | ctx.lineTo(84, 188); |
| | ctx.closePath(); |
| | ctx.fill(); |
| |
|
| | ctx.save(); |
| | ctx.translate(75, 112); |
| | ctx.rotate(-Math.PI / 2); |
| | ctx.fillText('160px', -15, 0); |
| | ctx.restore(); |
| | |
| | |
| | const templatePath = path.join(projectRoot, 'BACKDROP-TEMPLATE.png'); |
| | const buffer = canvas.toBuffer('image/png'); |
| | console.log('Buffer size:', buffer.length, 'bytes'); |
| | fs.writeFileSync(templatePath, buffer); |
| |
|
| | console.log('✅ Template created: BACKDROP-TEMPLATE.png'); |
| | console.log(''); |
| | console.log('The MAGENTA/PINK area (#FF00FF) is the play area.'); |
| | console.log('Use this template in your image editor:'); |
| | console.log(' 1. Open BACKDROP-TEMPLATE.png'); |
| | console.log(' 2. Create your artwork on layers below the template'); |
| | console.log(' 3. Delete or hide the template layer'); |
| | console.log(' 4. Export as 256x224 PNG'); |
| | console.log(' 5. Save to public/assets/backdrops/level-X/backdrop.png'); |
| | } catch (error) { |
| | console.error('Error generating template:', error); |
| | throw error; |
| | } |
| | } |
| |
|
| | generateTemplate().catch(console.error); |
| |
|
| |
|