Listing 16, Listing 17 – ETC Unison Mosaic Designer v1.11.0 User Manual
Page 237
Custom Preset Programming Guide
The default value of a gradient is a list of fractions and colours, where fraction is in the range [0-1] and spe-
cifies where in the gradient the colour is, and red, green and blue is the colour at that position and are in the
range [0-255]. You can specify multiple points. For example:
property("gradient", GRADIENT, 0.0, 255, 0, 0, 1.0, 0, 0, 255)
creates a red (255,0,0) point at the start (0.0) and a blue ((0,0,255) point at the end (1.0).
To demonstrate a real example of using properties in scripts:
Listing 16
property("g", GRADIENT, 0.0, 255, 0, 0, 1.0, 0, 0, 255)
function pixel(frame,x,y)
return g:lookup(x/(width-1))
end
This, by default, creates a horizontal gradient from red to blue, as we saw in Listing 13. However, when this pre-
set is placed on a timeline, there will be a gradient editor available, and you will be able to alter the gradient to be
any colour you wish, without having to recompile the script or having to duplicate the custom preset with some
small alterations.
We will now modify our vertical band example to expose some properties to make a very versatile effect:
Listing 17
-- width of the bands in pixels
property("band_width", INTEGER, 4, 1)
-- space between bands in pixels
property("band_spacing", INTEGER, 1, 0)
-- the wavelength of the ripple (in terms of current width)
property("wavelength", FLOAT, 1, 0, 16, 2)
-- the direction of the ripple
property("reverse", BOOLEAN, false)
-- the colour of the band
property("band_gradient", GRADIENT, 0, 255, 0, 0, 1, 255, 255, 0)
-- the colour of the space between bands
property("background_colour", COLOUR, 0, 0, 0)
-- get the combined width of band and separator
local total_band_width = band_width+band_spacing
-- get the number of visible bands
local bands = width/total_band_width
-- modulo operator (a%b)
function mod(a,b)
return a - math.floor(a/b)*b
end
-- the pixel function
function pixel(frame,x,y)
- 237 -