Working with properties – ETC Unison Mosaic Designer v1.11.0 User Manual
Page 235

Custom Preset Programming Guide
-- 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)
if (mod(x,total_band_width)>=band_width) then
-- in band separator
return background_colour
end
-- get the band in which this pixel falls
local band = math.floor(x/total_band_width)
-- get the fraction through the effect
local t = frame/frames
-- get the height of the band in which this pixel falls
local band_height = (math.sin((band/bands+t)*math.pi*2)+1)/2
-- adjust y to be relative to the center of the effect
y = y-(height/2)+0.5
-- decide if this pixel is inside the band
local h = math.abs(y)/(height/2)
if (h<=band_height) then
return band_gradient:lookup(h)
else
return background_colour
end
end
The band_gradient variable is initialised as a red to yellow gradient, and we use band_gradient:lookup
(h)
to determine the colour of the band at height h.
Working with properties
Custom presets can have properties which will be exposed in Designer whenever the preset is placed on a
timeline. This allows a single custom preset to create a wide variety of effects. It also means that you do not have
to create near-identical copies of custom presets just to change one parameter, for example, a colour. You can
just expose a colour property and specify the desired colour when the preset is placed on a timeline.
To define a property, you would call the function:
property(name, type, default_value, ...)
This must be added to your script outside of any function call.
- 235 -