From 3dff7438b3aa28aae555eb0bf61dbf5e465f69c4 Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Tue, 24 Dec 2024 22:10:31 +0300 Subject: [PATCH] Add gradient brushes. --- Dashboard.Drawing/Brush.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Dashboard.Drawing/Brush.cs b/Dashboard.Drawing/Brush.cs index 929ef74..1c69508 100644 --- a/Dashboard.Drawing/Brush.cs +++ b/Dashboard.Drawing/Brush.cs @@ -14,26 +14,36 @@ namespace Dashboard.Drawing { } - public readonly struct SolidBrush : IBrush + public readonly struct SolidBrush(Color Color) : IBrush { public IDrawExtension Kind { get; } = SolidBrushExtension.Instance; - public Color Color { get; } - - public SolidBrush(Color color) - { - Color = color; - } - public override int GetHashCode() { return HashCode.Combine(Kind, Color); } } + public readonly struct GradientBrush(Gradient Gradient) : IBrush + { + public IDrawExtension Kind { get; } = GradientBrushExtension.Instance; + + public override int GetHashCode() + { + return HashCode.Combine(Kind, Gradient); + } + } + public class SolidBrushExtension : DrawExtension { private SolidBrushExtension() : base("DB_Brush_solid", new[] { BrushExtension.Instance }) { } public static readonly SolidBrushExtension Instance = new SolidBrushExtension(); } + + public class GradientBrushExtension : DrawExtension + { + private GradientBrushExtension() : base("DB_Brush_gradient", new[] { BrushExtension.Instance }) { } + + public static readonly GradientBrushExtension Instance = new GradientBrushExtension(); + } }