-- fps
Prismatica Source
Ready
Controls
Prismatica Language Reference

Overview

Prismatica is a J-inspired array language for pixel art. The pixel buffer is a tableX and Y hold every pixel's coordinates at once. All operations map over the entire table automatically. The last expression becomes the image.

💡 Think in tables, not pixels. sin X computes sin of every x-coordinate at once. X , Y , 0.5 builds an RGB table. No loops needed — that's array programming.

Right-to-Left Evaluation

There is no operator precedence. Everything evaluates right-to-left:

3 + 4 * 5 NB. = 3 + (4 * 5) = 23, NOT 35 sin 2 * t NB. = sin (2 * t) a + b * c - d NB. = a + (b * (c - d))

Built-in Tables & Values

NameTypeDescription
XtableEach pixel's x-coordinate (0–1). A table of scalars.
YtableEach pixel's y-coordinate (0–1). A table of scalars.
PtablePosition table — each pixel holds [x, y]. Same as p.
tscalarTime in seconds (broadcasts to all pixels)
mvec2Mouse position over canvas (0–1)
piscalarπ ≈ 3.14159
tauscalarτ = 2π ≈ 6.28318
💡 X and Y are separate scalar tables. P is a 2-channel table. Use P for SDF functions, X/Y for per-axis math.

Assignment

name =: expr — assign a table to a name. Also accepts and <-.

r =: 0.15 + 0.05 * sin 3 * t d =: P circle 0.5 0.5 , r

Strand Arrays

Adjacent number literals form an array automatically — no brackets needed:

0.5 0.3 0.1 NB. → [0.5, 0.3, 0.1] _1 0 1 NB. → [-1, 0, 1] (_N is negative N) X , Y , 0.5 NB. , appends: builds 3-channel color table

Primitive Verbs

VerbMonadic (one arg)Dyadic (two args)
+identityadd
-negatesubtract
*signum (−1/0/1)multiply
%reciprocal (1/y)divide
^exp (eʸ)power (xʸ)
|absmodulo
,ravel (flatten)append/concatenate
<.floormin
>.ceilmax
<:decrement (y−1)less-or-equal
>:increment (y+1)greater-or-equal
~:complement (1−y)not-equal
<less-than
>greater-than
=equal
{first elementindex: i { arr
#tally (count)scale (x * y)
i.iota: i. 4 → [0,1,2,3]

Named Verbs

NameMonadicDyadic x verb y
sin cos tantrig (component-wise)sin(x+y)
sqrt log exp fractcomponent-wise
wavesin(y·τ)·0.5+0.5
noise2D value noise → 0–1
polar[angle,radius] from center
mirror1−2·|y−0.5|
lengthEuclidean length
atan2atan2(y,0)atan2(x,y)
dot_dot(y,y)dot product x·y
glowglow(y, 0.05)d glow k = exp(−max(d,0)/k)
tiletile(y, 4)p tile n = fract(p·n)
rotatep rotate angle
hsvhsv from vec3 [h,s,v]h hsv s,v
hslhsl from vec3 [h,s,l]
circlecircle at centerp circle cx,cy,r
boxp box cx,cy,w,h
ringp ring cx,cy,r
stepstep(0.5, y)edge step x
smoothsmooth(0,1,y)lo,hi smooth x
mixt mix a,b = lerp(a,b,t)
clampclamp(y,0,1)x clamp lo,hi

Adverbs

Adverbs modify verbs. They are written after the verb:

AdverbNameExampleMeaning
/reduce+/ 0.3 0.3 0.3fold array with verb → 0.9
~reflexdot_~ vapply verb to (y, y) → self-dot
+/ 1 2 3 NB. = 1+2+3 = 6 */ 2 3 4 NB. = 2*3*4 = 24 dot_~ p - 0.5 NB. = dot(p-0.5, p-0.5) = squared distance

Conjunction @

f @ g creates a new verb meaning "apply g first, then f":

(sin @ *) t NB. = sin(signum(t)) (glow @ length) p - 0.5 NB. = glow(length(p - 0.5))

Component Access

Use .x .y .z or .r .g .b to extract components from a vector:

p.x NB. horizontal position q =: polar p q.x NB. angle component q.y NB. radius component

Ternary

condition ? then : else — condition > 0 is truthy.

p.x > 0.5 ? 1 0 0 : 0 0 1

Comments

NB. comment or ⍝ comment — rest of line ignored.

Widgets

Declare interactive controls that appear below the canvas. Widget values persist while you edit code; load a new example to reset them.

SyntaxControlArguments
name =: @float min max defaultFloat sliderRange and default. Optional 4th arg: step (default 0.01).
name =: @int min max defaultInteger sliderInteger range and default.
name =: @color r g bColor pickerRGB values 0–1.
name =: @bool defaultToggle0 or 1.
radius =: @float 0.05 0.4 0.2 col =: @color 1 0.3 0.8 d =: p circle 0.5 0.5 , radius d glow 0.03 * col
💡 Try the 🎛 Widget Demo example to see all widget types in action.

Full Example: Pulsing Glow

NB. Glowing circle — tables, right-to-left r =: 0.15 + 0.05 * sin 3 * t d =: P circle 0.5 0.5 , r g =: d glow 0.03 h =: fract 0.08 * t g * hsv h , 0.8 , 1