public object?Convert(object value, Type targetType, object parameter, CultureInfo culture) { // Convert all colour types to Colour32 var colour = Colour32.Black; switch (value) { case Color col: { colour = col.ToColour32(); break; } case Colour32 col32: { colour = col32; break; } case uint u32: { colour = new Colour32(u32); break; } case int i32: { colour = new Colour32((uint)i32); break; } } if (parameter is string op) { var m = Regex.Match(op, @"lerp:\s*([0-9a-fA-F]{8})\s+(\d\.?\d*)"); if (m.Success && Colour32.TryParse(m.Groups[1].Value) is Colour32 target && double_.TryParse(m.Groups[2].Value) is double frac) { colour = Colour32.Lerp(colour, target, frac); } } return(new SolidColorBrush(colour.ToMediaColor())); }
/// <summary>Convert this colour to a media solid colour brush</summary> public static SolidColorBrush ToMediaBrush(this Colour32 col) { return(new SolidColorBrush(col.ToMediaColor())); }