asciipaint

Paint anything as coloured ASCII.

~6 KB · ZERO DEPENDENCIESZERO DEPS · WEBGL2

Any image, video, canvas or three.js scene, painted in coloured glyphs. Move across the picture above to resolve it.

Try your pictureTry it ↓

Install

01 INSTALL

$ npm i asciipaint

02 PAINT

import { asciipaint } from "asciipaint";
const paint = asciipaint(canvas);
paint.draw(picture);

No bundler? Import it from a CDN →

WHAT THOSE THREE LINES PAINT · LIVE

03 PLAYGROUND

Drop your own picture onto the stage. It is painted on your machine and never uploaded.

— × — CELLS

DROP A PICTURE ANYWHERE

SOURCE

2.4 × 3.4 PX

RAMP DARK → BRIGHT

BACKGROUND

SPARKLE

YOUR SETTINGSupdates as you drag

import { asciipaint, autoRender } from "asciipaint";

const paint = asciipaint(canvas, { cell: [2.4, 3.4], ramp: "-=+*#%@", background: "#000000", sparkle: true });
autoRender(paint, () => paint.draw(sketch));

04 ONE TAG

Import the element once, then use it like <img>. Every <ascii-img> on the page shares one WebGL context, so a whole wall of them costs one GPU setup.

LOGOS.HTML

import "asciipaint/element";

<ascii-img src="orbit.svg"></ascii-img>
<ascii-img src="chevrons.png"></ascii-img>
  • SVG with only a viewBox, or a transparent PNG
  • Transparent pixels stay paper
  • One shared WebGL context for every tag
  • Fires paint and error events, like <img>

05 THREE.JS

Swap renderer.render for pass.render. Same scene, same camera, painted in the same frame.

pass.render(scene, camera)

SCENE.TS

import { asciipaintThree }
  from "asciipaint/three";

const pass = asciipaintThree(renderer);
pass.render(scene, camera);

Graded with ACES Filmic and output as sRGB, so lit scenes keep their highlights.