ASCII Field
NewCustomize
Color
flow
Cell size14px
Scale1.00
Density0.70
Fade0.60
Glow0.60
Twinkle0.50
Speed1.0
Seed0
Radius100px
Magnify0.60
Wake0.70
Installation
npx shadcn@latest add https://uibrik.com/r/ascii-field.jsonAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/ascii-field/ascii-field.tsx"use client"; import { useEffect, useRef, useState } from "react"; import { ShaderSurface, type ShaderBackgroundProps, type Prepass } from "../_shader-background/ShaderSurface"; import { paletteOf, type ShadeStep } from "../_shader-background/shades"; // A slow field of light drawn as type: the page is split into a grid of character cells, and each // cell shows the glyph from `characters` that matches how bright the field is there, tinted with // the same ramp. Sparse marks fade into the page, dense ones carry the colour, and a faint glow sits // under the busiest areas so the grid blends in rather than sitting on top. The pointer brings a lens // that enlarges the field under it and leaves a fading wake of reshuffled type; a click sends a ring // of type outward. // glyph cells in the atlas, texels; width over height matches the cells on screen const ATLAS_W = 60; const ATLAS_H = 96; const ASPECT = ATLAS_W / ATLAS_H; const SHADER = /* glsl */ ` uniform sampler2D u_tex; // glyph atlas: one row of cells, white on black uniform float u_glyphs; // glyphs in the atlas uniform float u_cell; // row height, css px uniform float u_scale; // size of the shapes uniform float u_density; // how much of the field carries glyphs
Adds the files to
components/uibrik/ascii-field. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/ascii-field.Usage
import { AsciiField } from "@/components/uibrik/ascii-field/ascii-field";<AsciiField color="#3f6bff" pattern="flow" characters=" .:-=+*#%@" cellSize={14} scale={1} density={0.7} fade={0.6} glow={0.6} twinkle={0.5} speed={1} seed={0} animate interactive radius={100} magnify={0.6} wake={0.7} // background="…"> …</AsciiField>Props
AsciiField- color
- Type string
- "#3f6bff"
- Colour of the glyphs; drawn in shades of it.
- colors
- Type string[]
- ["#1b2a4a","#2f6df6","#38c6d9","#c4f5e4"]
- Hex colours, 2 to 6, from the faintest glyphs to the densest. Overrides color.
- pattern
- Type "flow" | "waves" | "rings"
- "flow"
- Shape of the field: drifting banks, crossing swells, or spreading rings.
- characters
- Type string
- " .:-=+*#%@"
- Glyphs from empty to dense; the first is usually a space. Up to 24.
- cellSize
- Type number
- 14
- Height of a row of type.
- scale
- Type number
- 1
- Size of the shapes; larger is calmer.
- density
- Type number
- 0.7
- How much of the field carries glyphs.
- fade
- Type number
- 0.6
- How far the glyphs fade toward the edges.
- glow
- Type number
- 0.6
- Tint under the dense areas.
- twinkle
- Type number
- 0.5
- Odd cells that flare now and then.
- speed
- Type number
- 1
- Animation speed; 1 is the designed pace.
- seed
- Type number
- 0
- Shifts the composition, so two fields with the same settings still differ.
- animate
- Type boolean
- true
- Move on its own. Off draws one still frame.
- interactive
- Type boolean
- true
- A lens follows the pointer and leaves a fading trail; a click sends a ring of type outward.
- radius
- Type number
- 100
- How far the pointer lens reaches.
- magnify
- Type number
- 0.6
- How much the lens enlarges the field under it.
- wake
- Type number
- 0.7
- Strength of the fading trail the pointer leaves.
- background
- Type string
- –
- Base colour behind the glyphs; empty follows the page.
- children
- Type ReactNode
- –
- Content shown on top of the background.
- className
- Type string
- –
- Classes for the box; it fills whatever size you give it.