Prismatica is a J-inspired array language for shader programming. Evaluation is right-to-left with no precedence rules. Each program outputs a vec3 color (RGB 0–1). The last expression becomes the pixel color.
sin t not sin(t). Write d glow 0.05 not glow(d, 0.05). Parens are for grouping only.There is no operator precedence. Everything evaluates right-to-left:
| Name | Type | Description |
|---|---|---|
p | vec2 | Pixel position (0–1 each axis) |
t | scalar | Time in seconds (animates) |
m | vec2 | Mouse position over canvas (0–1) |
pi | scalar | π ≈ 3.14159 |
tau | scalar | τ = 2π ≈ 6.28318 |
name =: expr — assign. Also accept ← and <-.
Adjacent number literals form an array automatically — no brackets needed:
| Verb | Monadic (one arg) | Dyadic (two args) |
|---|---|---|
+ | identity | add |
- | negate | subtract |
* | signum (−1/0/1) | multiply |
% | reciprocal (1/y) | divide |
^ | exp (eʸ) | power (xʸ) |
| | abs | modulo |
, | ravel (flatten) | append/concatenate |
<. | floor | min |
>. | ceil | max |
<: | decrement (y−1) | less-or-equal |
>: | increment (y+1) | greater-or-equal |
~: | complement (1−y) | not-equal |
< | — | less-than |
> | — | greater-than |
= | — | equal |
{ | first element | index: i { arr |
# | tally (count) | scale (x * y) |
i. | iota: i. 4 → [0,1,2,3] | — |
| Name | Monadic | Dyadic x verb y |
|---|---|---|
sin cos tan | trig (component-wise) | sin(x+y) |
sqrt log exp fract | component-wise | — |
wave | sin(y·τ)·0.5+0.5 | — |
noise | 2D value noise → 0–1 | — |
polar | [angle,radius] from center | — |
mirror | 1−2·|y−0.5| | — |
length | Euclidean length | — |
atan2 | atan2(y,0) | atan2(x,y) |
dot_ | dot(y,y) | dot product x·y |
glow | glow(y, 0.05) | d glow k = exp(−max(d,0)/k) |
tile | tile(y, 4) | p tile n = fract(p·n) |
rotate | — | p rotate angle |
hsv | hsv from vec3 [h,s,v] | h hsv s,v |
hsl | hsl from vec3 [h,s,l] | — |
circle | circle at center | p circle cx,cy,r |
box | — | p box cx,cy,w,h |
ring | — | p ring cx,cy,r |
step | step(0.5, y) | edge step x |
smooth | smooth(0,1,y) | lo,hi smooth x |
mix | — | t mix a,b = lerp(a,b,t) |
clamp | clamp(y,0,1) | x clamp lo,hi |
Adverbs modify verbs. They are written after the verb:
| Adverb | Name | Example | Meaning |
|---|---|---|---|
/ | reduce | +/ 0.3 0.3 0.3 | fold array with verb → 0.9 |
~ | reflex | dot_~ v | apply verb to (y, y) → self-dot |
f @ g creates a new verb meaning "apply g first, then f":
Use .x .y .z or .r .g .b to extract components from a vector:
condition ? then : else — condition > 0 is truthy.
NB. comment or ⍝ comment — rest of line ignored.