New operators for Palette

With these it would be easier to create more complicated timelines
without repeating yourself over and over again.
This commit is contained in:
ivan tkachenko 2025-07-17 15:16:07 +03:00
parent 43d1565dbe
commit 2df7d28d43
1 changed files with 22 additions and 0 deletions

View File

@ -263,6 +263,28 @@ namespace MuzikaGromche
}
return new Palette(colors);
}
public static Palette operator +(Palette before, Palette after)
{
return new Palette([.. before.Colors, .. after.Colors]);
}
public static Palette operator *(Palette palette, int repeat)
{
var colors = Enumerable.Repeat(palette.Colors, repeat).SelectMany(x => x).ToArray();
return new Palette(colors);
}
public Palette Stretch(int times)
{
var colors = Colors.SelectMany(color => Enumerable.Repeat(color, times)).ToArray();
return new Palette(colors);
}
public Palette Use(Func<Palette, Palette> op)
{
return op.Invoke(this);
}
}
public class Track