asafefe.dev
Lab

Lab/20

ASCII Video

Each cell picks a character by brightness from a ramp, drawn from a prebuilt glyph atlas so dense grids stay fast. Swap the source, the character set, and the cell size.

  • Canvas
  • Image
  • Generative
Move to tilt and light it
10px

Installation

Add ASCII Video to your project with the shadcn CLI. The files land in components/lab, ready to edit.

$ pnpm dlx shadcn@latest add @soultel/lab-ascii-video

Or by URL: https://asafefe.dev/r/lab-ascii-video.json

Brings along

  • utils
  • @soultel/lab-canvas

Usage

example.tsx10 lines
import { AsciiVideo } from "@/components/lab/ascii-video"

export function Example() {
  return (
    <div className="grid h-[420px] gap-4 sm:grid-cols-2">
      <AsciiVideo />
      <AsciiVideo src="/avatar.png" charset="blocks" cellSize={8} label="My avatar in ASCII" />
    </div>
  )
}

Props

PropTypeDefaultDescription
srcstring-Image to render. Leave it out for the generated torus scene.
charset"standard" | "blocks" | "binary" | "dense" | string"standard"A preset or your own ramp, from empty to full.
cellSizenumber10Font size of one cell in px. Smaller is denser.
fit"contain" | "cover""contain"How the image fits the canvas.
contrastnumber1.3Contrast boost for images.
speednumber1Animation speed multiplier.
lens / lensRadiusboolean, numbertrue, 90Brighten and recolor the cells around the pointer.
color / accentColorstring"var(--foreground)", "var(--primary)"Character color, and the lens and highlight color.
backgroundstring"var(--background)"What sits behind it. On light pages, dark areas draw dense.
fontstring"var(--font-mono, ui-monospace)"Monospace font family.
labelstring-Accessible description. Without it the canvas is hidden from screen readers.