package de.fullrisk.citrusDev.UIHelper;

import io.wispforest.owo.ui.core.Animatable;
import net.minecraft.util.Mth;

public record ColorValue(int argb) implements Animatable<ColorValue> {
    @Override
    public ColorValue interpolate(ColorValue next, float delta) {
        int a1 = (this.argb >> 24) & 0xFF, r1 = (this.argb >> 16) & 0xFF, g1 = (this.argb >> 8) & 0xFF, b1 = this.argb & 0xFF;
        int a2 = (next.argb >> 24) & 0xFF, r2 = (next.argb >> 16) & 0xFF, g2 = (next.argb >> 8) & 0xFF, b2 = next.argb & 0xFF;

        int a = Mth.floor(Mth.lerp(delta, a1, a2));
        int r = Mth.floor(Mth.lerp(delta, r1, r2));
        int g = Mth.floor(Mth.lerp(delta, g1, g2));
        int b = Mth.floor(Mth.lerp(delta, b1, b2));

        return new ColorValue((a << 24) | (r << 16) | (g << 8) | b);
    }
}