35 lines
774 B
TypeScript
35 lines
774 B
TypeScript
import { MovingHeadState } from 'rust_native_module';
|
|
import { Pattern, Time } from './proto';
|
|
|
|
export class ChaserPattern implements Pattern {
|
|
render(time: Time): Array<MovingHeadState> {
|
|
let head_number = Math.ceil(time.beat_relative) % 4;
|
|
|
|
let template: MovingHeadState = {
|
|
startAddress: 0,
|
|
pan: 0,
|
|
tilt: 0,
|
|
brightness: {
|
|
type: 'dimmer',
|
|
value: 0.2,
|
|
},
|
|
rgbw: [255, 0, 0, 0],
|
|
speed: 1,
|
|
reset: false,
|
|
}
|
|
|
|
let result = [];
|
|
|
|
for (let [i, startAddress] of [1, 15, 29, 43].entries()) {
|
|
result[i] = template;
|
|
result[i].startAddress = startAddress;
|
|
|
|
if (i === head_number) {
|
|
result[i].brightness = { type: 'dimmer', value: 1 };
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|