import { MovingHeadState } from "rust_native_module";
import { Pattern, PatternOutput, RenderUpdate } from "./proto";
import { left, right, panForward, startAddresses, tiltUp, down } from "./stage";
import { Tuple4 } from "./types";

export const TARGETS: Tuple4<[number, number]> = [
  [panForward + Math.atan(1) * left, tiltUp + Math.atan(1 / 3) * down],
  [panForward + Math.atan(1 / 3) * left, tiltUp + Math.atan(1 / 3) * down],
  [panForward + Math.atan(1 / 3) * right, tiltUp + Math.atan(1 / 3) * down],
  [panForward + Math.atan(1) * right, tiltUp + Math.atan(1 / 3) * down],
]

export class StroboInsGesichtPattern implements Pattern {
  render(_update: RenderUpdate): PatternOutput {
    return startAddresses.map(((address, index) => {

      const [pan, tilt] = TARGETS[index];

      const state: MovingHeadState = {
        startAddress: address,
        pan: pan,
        tilt: tilt,
        brightness: {
          type: "strobe",
          value: 1,
        },
        rgbw: [0, 0, 0, 255],
        speed: 1,
        reset: false
      }

      return state;
    })) as PatternOutput
  }
}
