Helpers are useful functions that you can use anywhere in your scripts.
clamp
( value, min, max )
Ensures that an input value is within the range of minimum and maximum values.
Arguments |
|
Return value |
Number
If |
Example |
clamp(1, 2, 6)
// Returns 2
clamp(10, 2, 6)
// Returns 6
clamp(-42, -100, 0)
// Return -42
|
cmykColor
( c, m, y, k )
Creates a color object with keys containing the values of CMYK color components.
Arguments |
|
Return value |
Object
An object containing the matching |
counter
( id )
Creates a counter (if it doesn't exist yet) that increments by 1 everytime the function is called.
Arguments |
|
Return value |
Number
The current counter value |
Example |
let myCounter = counter()
// myCounter = 0
myCounter = counter()
// myCounter = 1
|
counterLimit
( limit, id )
Creates a counter (if it doesn't exist yet) that increments by 1 everytime the function is called, and returns true when it reaches or exceeds the limit value.
Arguments |
|
Return value |
Boolean
|
Example |
let result = counterLimit(2)
// result = false
result = counterLimit(2)
// result = false
result = counterLimit(2)
// result = true
|
counterReset
( id )
Resets a counter to its initial value of 0.
Arguments |
|
counterResetAll
()
Resets all the script's counters to their initial value of 0.
degToRad
( degrees )
Converts a value in degrees to a value in radians.
Arguments |
|
Return value |
Number
The corresponding value in radians |
easeInBack
( progress )
Generates a "overshoot" easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInBounce
( progress )
Generates a "bouncing" easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInCirc
( progress )
Generates a circular easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInCubic
( progress )
Generates a cubic (3rd order) easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInElastic
( progress )
Generates a "elastic" easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInExpo
( progress )
Generates a exponential easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutBack
( progress )
Generates a "overshoot" easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutBounce
( progress )
Generates a "bouncing" easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutCirc
( progress )
Generates a circular easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutCubic
( progress )
Generates a cubic (3rd order) easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutElastic
( progress )
Generates a "elastic" easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutExpo
( progress )
Generates a exponential easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutQuad
( progress )
Generates a quadratic (2nd order) easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutQuart
( progress )
Generates a quartic (4th order) easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutQuint
( progress )
Generates a quintic (5th order) easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInOutSine
( progress )
Generates a sine easing at both start and end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInQuad
( progress )
Generates a quadratic (2nd order) easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInQuart
( progress )
Generates a quartic (4th order) easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInQuint
( progress )
Generates a quintic (5th order) easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeInSine
( progress )
Generates a sine easing at start of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutBack
( progress )
Generates a "back overshoot" easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutBounce
( progress )
Generates a "bouncing" easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutCirc
( progress )
Generates a circular easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutCubic
( progress )
Generates a cubic (3rd order) easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutElastic
( progress )
Generates a "elastic" easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutExpo
( progress )
Generates a exponential easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutQuad
( progress )
Generates a quadratic (2nd order) easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutQuart
( progress )
Generates a quartic (4th order) easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutQuint
( progress )
Generates a quintic (5th order) easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
easeOutSine
( progress )
Generates a sine easing at end of period.
Arguments |
|
Return value |
Number
An eased, normalized value from |
highByte
( value )
Extracts the value of the higher byte of a 16-bit value. Useful for getting the "coarse" value of a 16-bit DMX parameter.
Arguments |
|
Return value |
Number
The higher byte value of the input value |
isBeatDivision
( beat, division, allowFirst )
Check if a pulse-per-quarter-note value from Kodtrol's engine is divisible by a value.
Arguments |
|
Return value |
Boolean
Returns true if the pulse-per-quarter-note is divisible, false otherwise. |
isEven
( value )
Arguments |
|
Return value |
Boolean
Returns |
isOdd
( value )
Arguments |
|
Return value |
Boolean
Returns |
log
( args )
Sends data to Kodtrol's console window.
Arguments |
|
Example |
log("Hello World")
// Displays "Hello World" in the console window
log(1, 2, 3, "four", 5)
// Displays "1 2 3 four 5" in the console window
|
lowByte
( value )
Extracts the value of the lower byte of a 16-bit value. Useful for getting the "fine" value of a 16-bit DMX parameter.
Arguments |
|
Return value |
Number
The lower byte value of the input value |
map
( value, valueMin, valueMax, outMin, outMax )
Using a source value and its known range, re-maps that value to a new target range. Note that the result is not clamped, so you may end up with under or over-shooting output values.
Arguments |
|
Return value |
Number
The mapped value |
Example |
map(75, 50, 100, 0, 1)
// Returns 0.5
map(0.5, 0, 1, 0, 100)
// Returns 50
|
mix
( a, b, percent )
Arguments |
|
Return value | Number |
noise
( id, seed )
Arguments |
|
Return value | * |
noise2d
( x, y, id, seed )
Arguments |
|
Return value | Number |
noise3d
( x, y, z, id, seed )
Arguments |
|
Return value | Number |
noise4d
( x, y, z, w, id, seed )
Arguments |
|
Return value | Number |
onceWhenFalse
( value, id, callback )
Invokes a callback once for each time that the checked value
becomes false
.
Arguments |
|
onceWhenOne
( value, id, callback )
Invokes a callback once for each time that the checked value
becomes exactly 1
.
Arguments |
|
onceWhenTrue
( value, id, callback )
Invokes a callback once for each time that the checked value
becomes true
.
Arguments |
|
onceWhenZero
( value, id, callback )
Invokes a callback once for each time that the checked value
becomes exactly 0
.
Arguments |
|
radToDeg
( radians )
Converts a value in radians to a value in degrees.
Arguments |
|
Return value |
Number
The corresponding value in degrees |
randomBetween
( min, max )
Arguments |
|
Return value | Number |
randomIndex
( arr, except )
Arguments |
|
Return value | Number |
randomIndexWhere
( arr, predicate )
Arguments |
|
Return value | Number |
randomTrueFalse
( bias )
Arguments |
|
Return value |
Boolean
A random |
randomValue
( arr, except )
Arguments |
|
Return value | * |
randomValueWhere
( arr, predicate )
Arguments |
|
Return value | * |
rgbColor
( r, g, b )
Creates a color object with keys containing the values of RGB color components.
Arguments |
|
Return value |
Object
An object containing the matching |
rgbFromHsv
( h, s, v )
Arguments |
|
Return value | Object |
rgbMix
( color1, color2, percent )
Arguments |
|
Return value | Object |
rgbToCmyk
( rgb )
Arguments |
|
Return value |
Object
The CMYK color object of the converted |
sequence
( arr, id )
Arguments |
|
Return value | * |
sequenceIndex
( id )
Arguments |
|
Return value | Number |
sequenceReset
( id )
Arguments |
|
smoothFollow
( device, varName, divider, value, initValue )
Arguments |
|
Return value | * |
smoothReset
( device, varName, value )
Arguments |
|
Return value | * |
smoothValue
( device, varName )
Arguments |
|
Return value | * |
smoothVarName
( device, varName )
Arguments |
|
Return value | String |
square
( x )
Arguments |
|
Return value | Number |
step
( value, step )
Arguments |
|
Return value | Number |
timer
( id )
Arguments |
|
timerValue
( id )
Arguments |
|
Return value | Number |
timerLimit
( limit, id )
Arguments |
|
Return value | Boolean |
timerReset
( id )
Arguments |
|
timerResetAll
()
tri
( x )
Arguments |
|
Return value | Number |
wave
( position, percent, frequency, func )
Arguments |
|
Return value | Number |