Brush Class
The colors a shape is painted with: a SolidBrush, a GradientBrush, a PathGradientBrush, an ImageBrush or a PatternBrush.
public abstract class BrushRemarks
Brushes are immutable and thread-safe: create them once and reuse them (an ImageBrush refers to an image that is not, and a PatternBrush to a callback that draws). The type cannot be derived outside the library.
Brush colors are sample values in the color space of the image they are drawn on: no color profile is applied, unless the brush is used inside DrawingCanvas.PaintProfile, which says what profile the colors of the paints are colors of, and converts them. Before painting, a color is converted to the pixel format of the frame with the rules of Image.CloneAs (Rec. 709 luma on grayscale frames, rounding to 8 bits on 8-bit frames); its alpha stays the opacity of the paint, also on frames without alpha.
Properties
| Name | Description |
|---|---|
| BlendMode | Gets how the color of the paint is mixed with the color of the pixels it is drawn on, before it is composited. Defaults to BlendMode.Normal. |
| CompositeMode | Gets how the paint is combined with the pixels it is drawn on. Defaults to CompositeMode.SourceOver. |
| Opacity | Gets the opacity of the paint, from 0 (nothing is painted) to 1 (the default): globalAlpha of the HTML canvas. |
BlendMode
Brush.csGets how the color of the paint is mixed with the color of the pixels it is drawn on, before it is composited. Defaults to BlendMode.Normal.
public BlendMode BlendMode { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not a defined
BlendMode.
Remarks
The blend mode changes the color of the paint, and Brush.CompositeMode then combines the paint with the pixels: BlendMode.Multiply with the default operator darkens the pixels by the paint.
CompositeMode
Brush.csGets how the paint is combined with the pixels it is drawn on. Defaults to CompositeMode.SourceOver.
public CompositeMode CompositeMode { get; init; }Opacity
Brush.csGets the opacity of the paint, from 0 (nothing is painted) to 1 (the default): globalAlpha of the HTML canvas.
public double Opacity { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not between 0 and 1.
Remarks
The opacity multiplies the alpha of the paint at each pixel, at the precision of the frame it is drawn on: an alpha a becomes floor(a opacity + 1/2 + 2^-20), before the paint is combined with the pixels by its Brush.CompositeMode and its Brush.BlendMode.
Methods
| Name | Description |
|---|---|
| FromRgba32(Rgba32) | Creates a brush painting a single color. |
| FromRgba64(Rgba64) | Creates a brush painting a single color. |
FromRgba32(Rgba32)
Brush.csCreates a brush painting a single color.
FromRgba64(Rgba64)
Brush.csCreates a brush painting a single color.
Operators
| Name | Description |
|---|---|
| implicit operator Brush(Rgba32) | Creates a brush painting a single color. A new SolidBrush is allocated by each conversion. |
| implicit operator Brush(Rgba64) | Creates a brush painting a single color. A new SolidBrush is allocated by each conversion. |
op_Implicit overloads
implicit operator Brush(Rgba32)
Brush.csCreates a brush painting a single color. A new SolidBrush is allocated by each conversion.
implicit operator Brush(Rgba64)
Brush.csCreates a brush painting a single color. A new SolidBrush is allocated by each conversion.