Scripts
A script is a tree of <seq> tags. A sequence either plots a formula, or contains other
sequences, which are layered back to front in the order written. Every sequence has a start time
(debut, in seconds, relative to its parent) and a duration; a container lasts as long
as its children need. Children inherit all of their parent's properties.
// a two-second movie, 320x240 at 24 fps, oversampled <seq fw=320 fh=240 framerate=24 oversample> <seq id=a debut=0 duration=1 center width=4 min=-1 mono="fnoise(x,y,t)" /> <seq debut=last duration=1 hsv=".6, $a, 1-$a" /> </seq>
Values are numbers, bare words or quoted strings; a formula goes in quotes. debut=last means
"when the previous sibling ends". Times may be written mm:ss. Comments start with //.
Sequence properties
| id=name | lets other formulas sample this sequence as $name |
| debut, duration | start (seconds, or last) and length |
| mono="f" | plot a grey value |
| rgb="r,g,b" | plot red, green, blue |
| hsv="h,s,v" | plot hue (0–1 around the wheel), saturation, value |
| pix="f" / triple="f" | plot a formula that returns a colour (a sample, rgb(), hsv(), or a grey value) |
| min, max | the range of the formula's result that maps to black..white (default 0..1); formulas |
| wrap | values outside min..max wrap around instead of clipping |
| left, top, width, height | the field of x,y the picture covers (default 0,0 to 1, with height keeping the aspect); formulas, evaluated per frame |
| center | left,top are the centre instead of the corner |
| endwidth | width at the end of the sequence: a zoom |
| zoom, zoomfunc | zoom factor per frame (instead of endwidth) and a curve of t for it (default t) |
| oversample | average four samples per pixel |
| cycle | rotate the values by 1/256 per frame |
| tile | when sampled by another sequence, coordinates wrap |
| image="file" | the picture for sample(), r[x,y] and iw, ih (PNG, JPEG, GIF, BMP; add your own with Images…) |
| recurse | iteration limit for the fractal functions (default 64) |
| p0, q0 (jx, jy) | the Julia constant |
| chop=mode | how this layer combines with what is below: normal, multiply, screen, overlay, lighten, darken, difference, exclusion, softlight, hardlight |
| fw, fh | frame size in pixels (on the outer sequence) |
| framerate | frames per second (default 12) |
<map> is a sequence that is only ever sampled, never drawn.
Formulas
Ordinary arithmetic with + - * / ^ (or **), %/mod, comparisons
< <= = == != <> >= > (giving 1 or 0), &&/and,
||/or, bitwise & | xor ~, and cond ? a : b.
Case does not matter. pi, pi2 (2π) and e are constants.
Variables
| x, y | the point being plotted, in the sequence's field (0..1 across a default field) |
| a, d | polar coordinates about the field's centre: angle (0..2π) and distance |
| t | time within the sequence, 0..1 |
| gt | time within the whole movie, 0..1 |
| n, gn | frame number within the sequence / the movie |
| w, h, left, top, cx, cy | the field's size, corner and centre |
| px, py, pw, ph | pixel coordinates and the picture's size in pixels |
| fw, fh | the frame size |
| sx, sy, sz | the pixel mapped onto a sphere |
| iw, ih | the image's size |
| r, g, b | the image's red, green (0–255) and blue (0–1) at this pixel; r[x,y] etc. at a point |
| z, zoom, recurse, duration, minval, maxval, p0, q0 | the sequence's settings |
| ? | a random number 0..1 |
Sampling other sequences
| $a | sequence a at this point and time |
| $a[x, y] | at the point x,y (0..1 across a's field; wraps if a is tiled) |
| $a{d, a} | at polar coordinates about a's centre |
| $a[t] | at time t (0..1 of a's duration) |
| $a[x, y, t] | both |
| sample(), sample(x,y) | the image at this point / at x,y (0..1); samptile is a synonym |
| samplep(), samplep(x,y) | the image by pixel |
Functions
| sin cos tan asin acos atan sinh cosh tanh | and sin2, cos2, sin3, cos3 (squared, cubed) |
| sqrt log log10 exp pow(x,y) pow2(x) | |
| int abs sign | |
| min(a,b) max(a,b) clamp(x,lo,hi) limit(x,lo,hi) | |
| angle(x,y) dist(x,y) | polar coordinates of a vector |
| terp(a,b) terp(a,b,x) | interpolate a→b over the sequence's time, or by x (0..1); works on colours |
| ease(x) ease() | smoothstep of x / of t |
| bias(x,p) gain(x,p) | Perlin's bias and gain curves; bias(p) applies to t |
| pinch(x) pinch(x,p) | 1-(1-x)^p |
| noise() noise(x,y) noise(x,y,z) | gradient noise, −1..1 |
| fnoise(...) | 1/f noise: 8 octaves of noise |
| turb(...) | turbulence: 8 octaves of |noise| |
| fbm(x,y,z,H,lacunarity,octaves) fbmt(...) | fractional Brownian motion with full control (noise/fnoise/turb with 6 arguments do the same) |
| noise2(x,y) noise2(x,y,p) | noise with a gain() interpolation curve |
| wnoise1() wnoise2() | Worley (cell) noise: distance to the nearest and second-nearest feature point |
| mand() mand(x,y) | Mandelbrot escape count at this point (0 inside the set); mandel too |
| mandc() | continuous-potential Mandelbrot |
| mand3() | the cubic Mandelbrot |
| mandq() mandq(y,z) | the quaternion Mandelbrot |
| julia() julia(p,q) julia(x,y,p,q) | Julia set escape count, with the sequence's p0,q0 or the given constant |
| dragon() | the dragon iteration |
| zebra(n,width,step,offset) | stripes |
| fib(n) prime(n) | Fibonacci number; 1 if prime |
| linen(t,attack,dur,decay) linenr(t,attack,decay,ratio) | envelopes (from Syd) |
| rgb(r,g,b) hsv(h,s,v) triple(a,b,c) | make a colour |
Notes
- This is the renderer of QTS (2001–2003), the last version of Pixel Magic, ported from its C++ source; the sample scripts are the originals and render as they did then, quirks included.
- Renders are deterministic: the same script gives the same pixels here and in the native
qtstool. - Rendering uses every core in your machine, but it is still a formula per pixel per frame: long movies take minutes.