led-bot/lights/light_parser.js

50 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-11-07 23:12:27 +00:00
class Target {
constructor(channel) {
this.channel = channel;
}
channel;
value;
}
const available_targets = {
r: new Target("r"),
g: new Target("g"),
b: new Target("b")
};
class Instruction {
constructor(t1ets, args) {
let valid_targets = [];
targets.forEach(t => {
if (t instanceof Target) {
let match = Object.keys(available_targets).find(key => available_targets[key].channel === t.channel);
if (match) {
valid_targets.push(t);
}
}
});
this.targets = valid_targets;
this.args = args;
}
name;
targets;
args;
transform(index, time, channel_target, channel_in) {}
transformAll(index, time) {
let new_targets = [];
this.targets.forEach(target => {
this.transform(index, time, target, this.args);
});
}
}
class ConstantColor extends Instruction {
name = "CONSTANT";
transform(index, time, channel_target) {}
}
export const instructions = [ConstantColor];
export default function parse(str) {
return [{}];
}