41 lines
928 B
TypeScript
41 lines
928 B
TypeScript
import { MovingHeadState } from "rust_native_module";
|
|
import { Pattern, PatternOutput, RenderUpdate } from "./proto";
|
|
import { startAddresses } from "./stage";
|
|
import { Tuple4 } from "./types";
|
|
|
|
export class TestPattern implements Pattern {
|
|
|
|
rgbw = [
|
|
[255, 0, 0, 0],
|
|
[0, 255, 0, 0],
|
|
[0, 0, 255, 0],
|
|
[0, 0, 0, 255],
|
|
]
|
|
|
|
render(update: RenderUpdate): PatternOutput {
|
|
let t = update.absolute % this.rgbw.length;
|
|
let second = Math.floor(t);
|
|
let brightness = 1 - (t % 1);
|
|
|
|
return startAddresses.map((startAddress) => {
|
|
|
|
let [r, g, b, w] = this.rgbw[second];
|
|
|
|
let state: MovingHeadState = {
|
|
startAddress: startAddress,
|
|
pan: 0,
|
|
tilt: 0,
|
|
brightness: {
|
|
type: "dimmer",
|
|
value: brightness,
|
|
},
|
|
rgbw: [r, g, b, w],
|
|
speed: 1,
|
|
reset: false
|
|
}
|
|
return state;
|
|
}) as Tuple4<MovingHeadState>;
|
|
}
|
|
|
|
}
|