// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Drawing.Brushes { using System; using System.Numerics; using Processors; /// /// Provides an implementation of a solid brush for painting solid color areas. /// /// The pixel format. public class SolidBrush : IBrush where TColor : struct, IPixel { /// /// The color to paint. /// private readonly TColor color; /// /// Initializes a new instance of the class. /// /// The color. public SolidBrush(TColor color) { this.color = color; } /// /// Gets the color. /// /// /// The color. /// public TColor Color => this.color; /// public BrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region) { return new SolidBrushApplicator(this.color); } /// /// The solid brush applicator. /// private class SolidBrushApplicator : BrushApplicator { /// /// The solid color. /// private readonly TColor color; /// /// Initializes a new instance of the class. /// /// The color. public SolidBrushApplicator(TColor color) { this.color = color; } /// /// Gets the color for a single pixel. /// /// The x. /// The y. /// /// The color /// public override TColor this[int x, int y] => this.color; /// public override void Dispose() { // noop } } } }