QTS language reference

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=namelets other formulas sample this sequence as $name
debut, durationstart (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, maxthe range of the formula's result that maps to black..white (default 0..1); formulas
wrapvalues outside min..max wrap around instead of clipping
left, top, width, heightthe field of x,y the picture covers (default 0,0 to 1, with height keeping the aspect); formulas, evaluated per frame
centerleft,top are the centre instead of the corner
endwidthwidth at the end of the sequence: a zoom
zoom, zoomfunczoom factor per frame (instead of endwidth) and a curve of t for it (default t)
oversampleaverage four samples per pixel
cyclerotate the values by 1/256 per frame
tilewhen 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…)
recurseiteration limit for the fractal functions (default 64)
p0, q0 (jx, jy)the Julia constant
chop=modehow this layer combines with what is below: normal, multiply, screen, overlay, lighten, darken, difference, exclusion, softlight, hardlight
fw, fhframe size in pixels (on the outer sequence)
framerateframes 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, ythe point being plotted, in the sequence's field (0..1 across a default field)
a, dpolar coordinates about the field's centre: angle (0..2π) and distance
ttime within the sequence, 0..1
gttime within the whole movie, 0..1
n, gnframe number within the sequence / the movie
w, h, left, top, cx, cythe field's size, corner and centre
px, py, pw, phpixel coordinates and the picture's size in pixels
fw, fhthe frame size
sx, sy, szthe pixel mapped onto a sphere
iw, ihthe image's size
r, g, bthe 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, q0the sequence's settings
?a random number 0..1

Sampling other sequences

$asequence 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 tanhand 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