MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / _renderAscii

Method _renderAscii

src/tools/texture-lab/renderer.js:586–625  ·  view source on GitHub ↗
(params, inputTexture, width, height, flipY = 1.0, renderScale = 1.0)

Source from the content-addressed store, hash-verified

584 }
585
586 _renderAscii(params, inputTexture, width, height, flipY = 1.0, renderScale = 1.0) {
587 const gl = this.gl;
588 const program = this.programs.ascii;
589
590 const charset = params.charset || ASCII_PRESETS.STANDARD;
591 this._updateCharacterAtlas(charset);
592
593 this._useProgram(program, flipY);
594
595 gl.activeTexture(gl.TEXTURE0);
596 gl.bindTexture(gl.TEXTURE_2D, inputTexture);
597
598 gl.activeTexture(gl.TEXTURE1);
599 gl.bindTexture(gl.TEXTURE_2D, this.textures.charAtlas);
600
601 // Scale cellSize proportionally to render resolution so export matches preview
602 const scaledCellSize = params.cellSize * renderScale;
603
604 const charColor = this._hexToRgb(params.charColor || '#ffffff');
605 const bgColorRgb = this._hexToRgb(params.backgroundColor || '#000000');
606
607 gl.uniform1i(program.uniforms.u_image, 0);
608 gl.uniform1i(program.uniforms.u_charAtlas, 1);
609 gl.uniform1f(program.uniforms.u_cellSize, scaledCellSize);
610 gl.uniform1i(program.uniforms.u_color, params.color ? 1 : 0);
611 gl.uniform1i(program.uniforms.u_invert, params.invert ? 1 : 0);
612 gl.uniform1i(program.uniforms.u_charCount, charset.length);
613 gl.uniform2f(program.uniforms.u_resolution, width, height);
614 gl.uniform1f(program.uniforms.u_brightness, params.brightness ?? 1.0);
615 gl.uniform1f(program.uniforms.u_contrast, params.contrast ?? 1.0);
616 gl.uniform1f(program.uniforms.u_gamma, params.gamma ?? 1.0);
617 gl.uniform1f(program.uniforms.u_charBrightness, params.charBrightness ?? 1.0);
618 gl.uniform3f(program.uniforms.u_charColor, charColor[0], charColor[1], charColor[2]);
619 gl.uniform3f(program.uniforms.u_backgroundColor, bgColorRgb[0], bgColorRgb[1], bgColorRgb[2]);
620 gl.uniform1f(program.uniforms.u_backgroundBlend, params.backgroundBlend ?? 1.0);
621 gl.uniform1f(program.uniforms.u_edgeEnhance, params.edgeEnhance ?? 0.0);
622 gl.uniform1f(program.uniforms.u_cellGap, params.cellGap ?? 0.0);
623
624 gl.drawArrays(gl.TRIANGLES, 0, 6);
625 }
626
627 _renderOverlay(params, inputTexture, width, height, flipY = 1.0) {
628 const gl = this.gl;

Callers 1

_renderEffectMethod · 0.95

Calls 3

_updateCharacterAtlasMethod · 0.95
_useProgramMethod · 0.95
_hexToRgbMethod · 0.95

Tested by

no test coverage detected