From 2df7d28d43e6db57a4058b9de2705fa3102ed979 Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Thu, 17 Jul 2025 15:16:07 +0300 Subject: [PATCH] New operators for Palette With these it would be easier to create more complicated timelines without repeating yourself over and over again. --- MuzikaGromche/Plugin.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index 86aeedf..0ffe420 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -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 op) + { + return op.Invoke(this); + } } public class Track