You can create persistent UI controls that appear when a pattern is active. These allow users to change pattern behavior without editing code. Controls are created by exporting functions with specific name prefixes.
Input Controls
These functions are called when the user interacts with the UI. You should typically store the incoming value in a variable to use in your pattern.
| Prefix | Example Function | Description |
|---|
slider | sliderMySlider(v) | A slider returning a value between 0.0 and 1.0. |
hsvPicker | hsvPickerColor(h, s, v) | A color well returning Hue, Saturation, and Value (0.0 to 1.0). |
rgbPicker | rgbPickerColor(r, g, b) | A color well returning Red, Green, and Blue (0.0 to 1.0). |
toggle | toggleEnabled(isEnabled) | A switch returning true (1) or false (0). |
trigger | triggerFire() | A button that triggers a function call (no parameters). |
inputNumber | inputNumberScale(v) | A numeric input for any decimal or integer value. |
Output Controls
These functions are called frequently to display information in the UI. They must return a value.
| Prefix | Example Function | Description |
|---|
showNumber | showNumberEnergy() | Displays a number with 4 decimal places. |
gauge | gaugeLightLevel() | Displays a percentage gauge (clamped between 0.0 and 1.0). |
Note: Controls are persistent and their settings are preserved across restarts.
var mySetting = 0.5
export function sliderMySetting(v) {
mySetting = v
}
export function hsvPickerPrimaryColor(h, s, v) {
// Use h, s, v to set colors
}
export function gaugeLightLevel() {
return light / 100; // Example return
}