PixaFlux attributes are named values that are attached to a node. These attributes are added to the user interface, and can be exposed to the node graph as node values to create complex projects.
Attributes are added to an Sprite It program with one set of functions, resolved in the node, and sent to the program to access the values with one function.
The SpriteIt Lua module has a set of functions that add attributes to the Sprite It node:
spriteIt.booleanAttribute(<name>, <default value true or false>)
Example
spriteIt.booleanAttribute("dark", true)
spriteIt.numberAttribute(<name>, <default>, <min>, <max>, <step>, <decimals>)
Example
spriteIt.numberAttribute("scale", 1.0, 0.0, 2.0, 0.1, 2)
spriteIt.pointAttribute(<name>, <default_x>, <default_y>, <min>, <max>, <step>, <decimals>)
Example
spriteIt.pointAttribute("scale", 1.0, 1.0, 0.0, 2.0, 0.1, 2)
spriteIt.rgboAttribute(<name>, <default red>, <default green>, <default blue>, <default opacity>)
Example
spriteIt.rgboAttribute("foreground", 0.5, 0.5, 0.5, 1.0)
spriteIt.choiceAttribute(<name>, <string table>)
Example
spriteIt.choiceAttribute("side", {"left","right"})
spriteIt.stringAttribute(<name>, <default string>)
Example
spriteIt.stringAttribute("pattern", "simple")
Attributes are evaluated and added to the Sprite It program for future access using the resolveAttributeValues funcion:
spriteIt.resolveAttributeValues()
This function needs to be called after the attributes have been added, and before reading them.
To read the evaluated attributes in the Lua program the Sprite It module has a getAttributeValue function:
scale = spriteIt.getAttributeValue("scale")
Since Lua can return variables of different types one single function work for all attribute types.