Class PicturePaint
A Picture as a paint: a tiling pattern, the shape of PDF's and SVG's tiling patterns and Skia's picture shader. The Tile rectangle of the picture, in its own coordinates, is repeated by TileX and TileY under LocalMatrix and the canvas transform. The raster backend renders one tile at the device scale the paint is drawn at and keeps it with the picture, so a pattern stays sharp when zoomed and is rendered once for repeated fills at one scale. A tile is at most 4096 pixels a side.
public sealed record PicturePaint : Paint, ITextPaint, IEquatable<Paint>, IEquatable<PicturePaint>
- Inheritance
-
PicturePaint
- Implements
- Inherited Members
Examples
// A tile drawn once as vectors fills any shape, repeated, and stays sharp when the canvas is zoomed.
PictureRecorder tile = new(new RectF(0, 0, 20, 20));
tile.FillCircle(new Vector2(10, 10), 4, new Rgba8(220, 60, 60, 255));
tile.StrokeRect(new RectF(0.5f, 0.5f, 19, 19), new Stroke(1), new Rgba8(230, 230, 230, 255));
PicturePaint dots = new(tile.Finish(), TileMode.Repeat, TileMode.Repeat) { LocalMatrix = Matrix3x2.CreateRotation(MathF.PI / 8) };
using (RasterCanvas<Rgba8> canvas = raster.CreateCanvas())
{
canvas.FillRoundRect(new RoundRect(new RectF(10, 10, 280, 180), 24), dots);
}
Constructors
PicturePaint(Picture, TileMode, TileMode, RectF?)
Initializes a new instance of the PicturePaint class.
public PicturePaint(Picture picture, TileMode tileX = TileMode.Repeat, TileMode tileY = TileMode.Repeat, RectF? tile = null)
Parameters
picturePictureThe picture.
tileXTileModeWhat lies left and right of the tile.
tileYTileModeWhat lies above and below it.
tileRectF?The tile, in the picture's coordinates; the picture's bounds when null.
Examples
// A tile drawn once as vectors fills any shape, repeated, and stays sharp when the canvas is zoomed.
PictureRecorder tile = new(new RectF(0, 0, 20, 20));
tile.FillCircle(new Vector2(10, 10), 4, new Rgba8(220, 60, 60, 255));
tile.StrokeRect(new RectF(0.5f, 0.5f, 19, 19), new Stroke(1), new Rgba8(230, 230, 230, 255));
PicturePaint dots = new(tile.Finish(), TileMode.Repeat, TileMode.Repeat) { LocalMatrix = Matrix3x2.CreateRotation(MathF.PI / 8) };
using (RasterCanvas<Rgba8> canvas = raster.CreateCanvas())
{
canvas.FillRoundRect(new RoundRect(new RectF(10, 10, 280, 180), 24), dots);
}
Exceptions
- ArgumentNullException
pictureis null.- ArgumentException
tileis empty or not finite.- ArgumentOutOfRangeException
A tile mode is not defined.
Properties
Picture
Gets the picture.
public Picture Picture { get; init; }
Property Value
Exceptions
- ArgumentNullException
The value is null.
Tile
Gets the tile, in the picture's coordinates: the part of the picture repeated, which may be larger than its bounds to space the copies.
public RectF Tile { get; init; }
Property Value
Exceptions
- ArgumentException
The value is empty or not finite.
TileX
Gets what lies left and right of the tile.
public TileMode TileX { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not defined.
TileY
Gets what lies above and below the tile.
public TileMode TileY { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not defined.