Slider
A linear component that slides from one end to the other to set numerical values.
Similar to the Knob in functionality.
Properties
The value returned by the position of the slider, ranging from 0 to 100.
Returns
true
if the user is moving the slider.
Events
SliderValueChangeEvent : { Value number, Type string }
Triggered when the slider is moved.
*Value
is the respective value given by the slider's position
*Type
is"SliderValueChangeEvent"
Examples
A simple code using some math to map the slider's value into the hue of a LED's color:
-- a function that maps "value"
-- from a scale of "src_from" to "src_to"
-- into a scale of "tgt_from" to "tgt_to"
function map(value, src_from, src_to, tgt_from, tgt_to)
return ((value - src_from) / (src_to - src_from) * (tgt_to - tgt_from)) + tgt_from
end
-- turn LED on at startup
gdt.Led0.State = true
function update()
-- map slider 0-100 to hue 0-360
local hue = map(gdt.Slider0.Value, 0, 100, 0, 360)
-- set LED color to hue
gdt.Led0.Color = ColorHSV(hue, 100, 100)
end