lattice

banner

A banner is a scalar field frozen at an instant and read across a rectangle. The package ships no fields of its own: field is a function you write.

import { bannerSvg } from "@mariovagomarzal/lattice/banner";

const field = (x: number, y: number, t: number) => Math.sin(2 * Math.hypot(x, y) - 1.5 * t);

const svg = bannerSvg({ field, width: 1500, height: 500 });
bannerSvg
source
time0.00
span7
size
width
px
height
px
pitch63×21 cells
px
weight1.00
fill0.46
alpha min0.06
alpha span0.72
polarity
ink#e8e1cf
paper#151b17
accentnone
scatter0.18
seed

Options

optiontypedefaultwhat it does
fieldFieldrequiredThe field the banner draws.
timenumber0The instant of the field that is drawn, in field time.
rangeRange | nullnullRange the field is rescaled against, or null to estimate it with calibrate.
widthnumber1500Width of the banner, in pixels.
heightnumber500Height of the banner, in pixels.
pitchnumber24Distance between cell centers, in pixels. The cell count follows from the banner size.
spannumber7Field units the short side of the grid spans.
fillnumber0.46Share of its cell a glyph covers, in [0, 1]. At 1 the glyphs touch, at 0 there is nothing to draw.
weightnumber1Ink gain, as a gamma. The field is normalized against its own range first, so 1 is a neutral that holds whatever field it is handed.
alphabetreadonly string[]rampThe ramp the levels are quantized with, from empty to full ink.
typefaceTypeface | nullspaceMonoOutlines the glyphs are drawn with, or null to set them as text.
fontFamilystring"Space Mono, monospace"The mono family the glyphs are named as. Used only when typeface is null.
inkstringmeet.colors.textColor of the glyphs.
alphaAlpha | null{ min: 0.06, span: 0.72 }Ink opacity, as a floor and the span above it. Null draws every glyph solid.
paperstring | nullmeet.colors.baseColor behind them, or null for none.
accentstring | nullnullColor the accented cells take, or null to keep the banner monochrome.
scatternumber0.18Share of the banner's cells the accent lands on, in [0, 1].
seednumber1The seed the scatter is drawn from. Equal seeds accent the same cells.