Creates a WebGL context without a window for headless rendering and server-side graphics
Overall
score
96%
Build a utility that renders a simple colored rectangle to an offscreen WebGL context and extracts the pixel color data for analysis.
Your implementation must:
width: The width of the captured regionheight: The height of the captured regionpixels: The raw pixel data as a Uint8Array bufferaverageColor: An object with r, g, b, a properties representing the average color values (0-255 range)@generates
/**
* Creates a WebGL context, renders a colored rectangle, and extracts pixel data
* @param {number} width - Width of the rendering context
* @param {number} height - Height of the rendering context
* @param {number} r - Red component (0.0 to 1.0)
* @param {number} g - Green component (0.0 to 1.0)
* @param {number} b - Blue component (0.0 to 1.0)
* @param {number} a - Alpha component (0.0 to 1.0)
* @returns {Object} Result object with width, height, pixels, and averageColor
*/
function analyzeColor(width, height, r, g, b, a);
module.exports = { analyzeColor };Provides headless WebGL rendering context creation.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-gldocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10