package me.koba1.led.animations.idle;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import me.koba1.led.animations.ColoredAnimation;
import me.koba1.led.model.LedStrip;
import me.koba1.led.model.colors.AnimationColor;
import me.koba1.led.model.colors.AnimationColorType;
import me.koba1.led.model.colors.KobaOutputColor;
import me.koba1.led.utils.ColorUtils;

import java.util.Map;

@Setter
@Getter
@ToString(callSuper = true)
public class SolidAnimation extends ColoredAnimation implements Idle {

    @Override
    public KobaOutputColor getColors(LedStrip ledStrip) {
        outputColors.clear();
        outputColors.fill(this.colors.get(AnimationColorType.MAIN).getColor(ledStrip.getLedCount()));

        KobaOutputColor difference = ColorUtils.getDifference(this.previousColors, outputColors);
        this.previousColors.set(this.outputColors);
        return difference;
    }

    public SolidAnimation() {
        super(0);
    }

    // @JsonCreator
    public SolidAnimation(/*@JsonProperty("colors")*/ Map<AnimationColorType, AnimationColor> colors) {
        super(0, colors);
    }

    static {
        register(() -> new SolidAnimation(Map.of(AnimationColorType.MAIN, new AnimationColor())));
    }
}
