Dither

Ordered dithering of a tone into a palette: Bayer matrices, a blue-noise tile built by void-and-cluster, or white noise, over a ramp, a radial, drifting noise or the backdrop.

<Fx effect="dither" preset="Bayer" />

Features

  • Bayer 2, 4 and 8, a void-and-cluster blue-noise tile, white noise.
  • Inputs: a ramp, a radial, drifting noise or the backdrop.

Use it for

  • Retro and handheld looks.
  • Print-like posters.

Installation

  1. Get runets.
    git clone https://github.com/ziyam-khan/runets
  2. Copy these files into your project, keeping their folders.
  3. Install what they use.
    pnpm add react

Usage

import { Fx } from 'runets'

<div className="card"> {/* position: relative */}
  <Fx effect="dither" />
</div>

API

PropTypeWhat it does
effectstringThe effect’s id, as in the address of this page.
presetstringOne of the presets above; the first by default.
paramsParamsAny parameter from the table, over the preset.
place'under' | 'over'Under the parent’s content (fills, halos) or over it (sparkles, glass). Default under.
radiusnumberCorner radius in points; the parent’s own border radius by default.
backdropstring | PaintWhat glass and distortion read: an image URL, or a function that paints a canvas the size of the parent.
maskPaintAn alpha mask for mask glow and text sheen.
hotbooleanDrives heat: the layer lights in 60 ms and cools over half a second instead of cutting off.
triggernumberChange it to fire a one-shot now (ping, ripple, burst, shockwave, zap).
wakenumberChange it to redraw for a second when something the layer reads, such as its occluders, moves on its own.
shape(time, w, h) => RectThe effect’s shape inside the parent, per frame: a lens that drifts.

Parameters

NameRangeDefault
pattern Patternbayer2, bayer4, bayer8, blue, whitebayer4
input Inputlinear, radial, noise, backdroplinear
colors Colourscolors2 colours
pixel Pixel0.5 to 162
angle Angle-3.141592653589793 to 3.1415926535897930.6
scale Noise scale8 to 40090
speed Speed0 to 20.2
bias Bias-1 to 10
contrast Contrast0.2 to 41
border Border0 to 240
intensity Intensity0 to 11

Accessibility

Source

The code is in src/fx/glsl/surface.ts in runets, MIT licensed.