(charset, cellSize = 16)
| 35 | import { EFFECT_TYPES, BLEND_MODES, DITHER_METHODS, ASCII_PRESETS } from './types'; |
| 36 | |
| 37 | function generateCharacterAtlas(charset, cellSize = 16) { |
| 38 | const canvas = document.createElement('canvas'); |
| 39 | const charCount = charset.length; |
| 40 | canvas.width = cellSize * charCount; |
| 41 | canvas.height = cellSize; |
| 42 | |
| 43 | const ctx = canvas.getContext('2d'); |
| 44 | ctx.fillStyle = '#000000'; |
| 45 | ctx.fillRect(0, 0, canvas.width, canvas.height); |
| 46 | |
| 47 | ctx.fillStyle = '#ffffff'; |
| 48 | ctx.font = `${cellSize * 0.9}px monospace`; |
| 49 | ctx.textAlign = 'center'; |
| 50 | ctx.textBaseline = 'middle'; |
| 51 | |
| 52 | for (let i = 0; i < charCount; i++) { |
| 53 | const x = i * cellSize + cellSize / 2; |
| 54 | const y = cellSize / 2; |
| 55 | ctx.fillText(charset[i], x, y); |
| 56 | } |
| 57 | |
| 58 | return canvas; |
| 59 | } |
| 60 | |
| 61 | export class WebGLRenderer { |
| 62 | constructor(canvas) { |
no outgoing calls
no test coverage detected