Class ImagePaint
An image as a paint: shapes are filled with the image's pixels, pixel (0, 0) covering the paint-space square from 0 to 1, under LocalMatrix and the canvas transform. TileX and TileY say what lies past its edges, so it tiles as a pattern, and Decal leaves the outside transparent, as image masks and stencils need. When the paint shrinks the image, sampling reads the nearest smaller level of a MipChain.
public sealed record ImagePaint : Paint, ITextPaint, IEquatable<Paint>, IEquatable<ImagePaint>
- Inheritance
-
ImagePaint
- Implements
- Inherited Members
Examples
// Fill a shape with a photo tiled as a pattern, half size, turned 15 degrees.
using Raster photo = Raster.Load("duck.png");
using Raster<Rgba8> raster = Raster.Create(400, 300, Rgba8.White);
using (RasterCanvas<Rgba8> canvas = raster.CreateCanvas())
{
ImagePaint pattern = new(photo, TileMode.Mirror, TileMode.Mirror)
{
LocalMatrix = Matrix3x2.CreateScale(0.5f) * Matrix3x2.CreateRotation(MathF.PI / 12),
};
canvas.FillPath(Path.Star(new Vector2(200, 150), 140, 60, 5), pattern);
}
Constructors
ImagePaint(Raster, TileMode, TileMode, SamplingOptions?)
Initializes a new instance of the ImagePaint class.
public ImagePaint(Raster image, TileMode tileX = TileMode.Clamp, TileMode tileY = TileMode.Clamp, SamplingOptions? sampling = null)
Parameters
imageRasterThe image; its first frame is used, read when a call draws, so later changes to it show.
tileXTileModeWhat lies left and right of the image.
tileYTileModeWhat lies above and below it.
samplingSamplingOptionsThe filter and color space; Egami's default sampling when null. Its edge mode and background are not used: the tile modes decide the edges.
Examples
// Fill a shape with a photo tiled as a pattern, half size, turned 15 degrees.
using Raster photo = Raster.Load("duck.png");
using Raster<Rgba8> raster = Raster.Create(400, 300, Rgba8.White);
using (RasterCanvas<Rgba8> canvas = raster.CreateCanvas())
{
ImagePaint pattern = new(photo, TileMode.Mirror, TileMode.Mirror)
{
LocalMatrix = Matrix3x2.CreateScale(0.5f) * Matrix3x2.CreateRotation(MathF.PI / 12),
};
canvas.FillPath(Path.Star(new Vector2(200, 150), 140, 60, 5), pattern);
}
Exceptions
- ArgumentNullException
imageis null.- ArgumentOutOfRangeException
A tile mode is not defined.
Properties
Image
Gets the image.
public Raster Image { get; init; }
Property Value
Exceptions
- ArgumentNullException
The value is null.
Sampling
Gets the filter and color space the image is sampled with.
public SamplingOptions Sampling { get; init; }
Property Value
Exceptions
- ArgumentNullException
The value is null.
TileX
Gets what lies left and right of the image.
public TileMode TileX { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not defined.
TileY
Gets what lies above and below the image.
public TileMode TileY { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not defined.