Files
the-nexus/modules/utils/canvas-utils.js
Alexander Whitestone 75e51619df WIP: Claude Code progress on #414
Automated salvage commit — agent session ended (exit 124).
Work in progress, may need continuation.
2026-03-24 18:22:39 -04:00

35 lines
1.1 KiB
JavaScript

// modules/utils/canvas-utils.js — Shared canvas texture creation helpers
import * as THREE from 'three';
/**
* Creates a canvas with a dark background and neon border.
*
* @param {number} width
* @param {number} height
* @param {string} bgColor - CSS color string for background
* @param {string} borderColor - CSS color string for border
* @returns {{ canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D }}
*/
export function createBorderedCanvas(width, height, bgColor = 'rgba(0,6,20,0.85)', borderColor = '#4488ff') {
const canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');
ctx.fillStyle = bgColor;
ctx.fillRect(0, 0, width, height);
ctx.strokeStyle = borderColor;
ctx.lineWidth = 2;
ctx.strokeRect(1, 1, width - 2, height - 2);
return { canvas, ctx };
}
/**
* Wraps a canvas in a THREE.CanvasTexture.
*
* @param {HTMLCanvasElement} canvas
* @returns {THREE.CanvasTexture}
*/
export function canvasToTexture(canvas) {
return new THREE.CanvasTexture(canvas);
}