beautypg.com

Custom preset programming guide, Basics, Listing 1 – ETC Unison Mosaic Designer v1.11.0 User Manual

Page 227: Listing 2, A real example, Listing 3

background image

Custom Preset Programming Guide

Custom Preset Programming Guide

Custom Presets use a Lua script to define an effect that can be played back on a Matrix. You can use this to cre-
ate effects that are not available as standard in Designer. Custom Presets are managed using the

Media

window.

Basics

Custom presets use Lua scripts to define an animation.

For each pixel (x,y) of each frame of that animation, a pixel function is called which returns three numbers,
between 0 and 255, which represent the red, green and blue components of the colour of that pixel. Pixel (0,0) is
in the top left of the frame, with the positive x axis pointing right and the positive y axis pointing down.

Here is the most simple example of a custom preset:

Listing 1

function pixel(frame,x,y)

return 255,0,0

end

This fills every pixel of every frame with red. If you do not return all three components of the pixel's colour, the
missing components are assumed to be 0, so the following function is equivalent to Listing 1:

Listing 2

function pixel(frame,x,y)

return 255

end

A real example

To demonstrate what can be achieved with custom presets, we are going to build up a real example as concepts
are introduced throughout this guide.

To start, we are going to create a preset that renders a series of vertical red bands:

Listing 3

-- width of the bands in pixels

band_width = 4

-- space between bands in pixels

band_spacing = 1

-- modulo operator (a%b)

function mod(a,b)

return a - math.floor(a/b)*b

end

-- the pixel function

function pixel(frame,x,y)

-- use the modulo operator to split the horizontal axis into bands

- 227 -