RotateModifier¶
RotateModifier is a coordinate modifier that rotates the layer buffer around the Z-axis (2D rotation in the X-Y plane). It can operate as a static baked transform or as a per-frame dynamic rotation.
Purpose¶
At speed = 0 the modifier is static: DriverLayer bakes the index transform into its PhysMap at setup, so the rotation has zero per-frame cost. When speed != 0 the angle advances each frame and modifyXYZ runs per pixel per frame, producing an animated spinning effect.
The layer buffer is automatically expanded to the axis-aligned bounding box of the rotated rectangle so no pixels are clipped. Physical LEDs that fall in the bounding box corners but outside the original rectangle boundary are output as black.
Controls¶
| Key | UI type | Min | Max | Default | Description |
|---|---|---|---|---|---|
angle |
slider | 0 | 359 | 0 | Static rotation angle in degrees |
speed |
slider | -360 | 360 | 0 | Rotation speed in degrees per frame; 0 = static |
enabled |
toggle | -- | -- | true | When false the modifier is bypassed |
Wiring¶
Add as a child of an EffectsLayer:
{ "type": "RotateModifier", "id": "rotate1", "parent_id": "effects1" }
Behaviour¶
- Static (
speed == 0,isStatic() == true):DriverLayerbakes the physical-to-layer index table at setup. Runtimeanglechanges trigger an automatic rebuild. - Dynamic (
speed != 0,isStatic() == false):modifyXYZruns per pixel per frame. Trig is computed once per frame per unique (dims, effective-angle) combination and cached, so there is onecosf/sinfcall per frame regardless of LED count. - Dim expansion: buffer width and height expand to
round(W * |cos| + H * |sin|)andround(W * |sin| + H * |cos|)respectively. At 0/180 degrees the dims are unchanged; at 90/270 degrees width and height swap. - Z-axis: the
zcoordinate is passed through unchanged. Rotation affects only X and Y.
Test coverage¶
See Modifiers: isStatic transitions, modifyDims at 0/90/45 degrees, modifyXYZ identity, 180-degree corner mapping, 90-degree corner checks, center-to-center mapping, dynamic tick advancement.