-
Notifications
You must be signed in to change notification settings - Fork 18
WidgetModifiers
ben-mkiv edited this page Jun 15, 2019
·
8 revisions
widget.addColor(Double: red, Double:green, Double:blue, Double:alpha):Integer:index
widget.addColor(1, 0, 0, 0.5)
-- adds red color with 50% opacitywidget.addRotation(Double:degree, Double:x, Double:y, Double:z):Integer:index
widget.addRotation(90, 0, 1, 0)
-- rotates the widget by 90° on the Y-Axiswidget.addScale(Double:scaleX, Double:scaleY, Double:scaleZ):Integer:index
widget.addScale(2, 2, 2)
-- scales widget by factor 2 on all axiswidget.addTranslation(Double:x, Double:y, Double:z):Integer:index
widget.addTranslation(0, 1, 0)
-- moves widget on y axis by 1widget.addAutoTranslation(Double:percentX, Double:percentY):Integer:index
-- allows alignment for overlay widgets in percent
widget.addAutoTranslation(50, 50)
-- moves widget to the center of the screenversion 2.1+
widget.modifiers()[index].set(1, 0, 0)
-- updates the values of a modifier, r/g/b for color or x/y/z for translate/scale modifiers
widget.modifiers()[index].set(10, 0, 0, 1)
-- updates the values of a modifier, r/g/b/a for color or deg/x/y/z for rotate modifierwidget.modifiers()[index].get()
-- returns the current values of a modifierwidget.modifiers()[index].type()
-- returns the type of a modifier-- create a cube
widget = require("component").glasses.addCube3D()
-- add black color to the cube
myColorModifier = widget.addColor(0, 0, 0, 0)
-- set the color modifier from before to green
widget.modifiers()[myColorModifier].set(0, 1, 0)
os.sleep(5)
-- set the color modifier from before to red
widget.modifiers()[myColorModifier].set(1, 0, 0)version 2.0+ (old syntax is still supported by new versions)
widget.updateModifier(index, 0, 1, 0)
-- updates red/green/blue or x/y/z
widget.updateModifier(index, 1, 0, 1, 0)
-- updates red/green/blue/alpha or deg/x/y/z-- create a cube
widget = require("component").glasses.addCube3D()
-- add black color to the cube
myColorModifier = widget.addColor(0, 0, 0, 0)
-- set the color modifier from before to green
widget.updateModifier(myColorModifier, 0, 1, 0)
os.sleep(5)
-- set the color modifier from before to red
widget.updateModifier(myColorModifier, 1, 0, 0)Widgets can be animated by binding an easing function to a modifier. So you can animate color / scale changes, movement and rotation with a simple syntax
widget.setEasing(Integer:modifierIndex, String:easingFunction, String:easingType, Double:duration, String:variableName, Double:minValue, Double:maxValue, String:mode)rotModifier = widget.addRotation(0, 0, 1, 0)
widget.setEasing(rotModifier, "LINEAR", "IN", 3000, "deg", 0, 360, "repeat")
-- rotate widget around the y-axis, one rotation takes 3secondswidget.removeEasing(Integer:modifierIndex, String:variableName)
-- removes easing from a modifierwidget.removeEasing(4, "x")
-- removes easing from list "x" of modifier 4easing function names previews
-
BACK,BOUNCE,CIRC,CUBIC,ELASTIC,EXPO,LINEAR,QUAD,QUART,QUINT,SINE
-
IN,OUT,INOUT
-
DEFAULTonly run once -
LOOPloop/playback the easing back and forth -
REPEATrepeat the easing