Method AddSprite
- Namespace
- PaintDotNet.Direct2D1
- Assembly
- PaintDotNet.Windows.dll
AddSprite(ISpriteBatch, RectFloat, in RectInt32?, in ColorRgba128Float?, in Matrix3x2Float?)
Adds a single sprite to the end of this sprite batch.
public static void AddSprite(this ISpriteBatch spriteBatch, RectFloat destinationRectangle, in RectInt32? sourceRectangle, in ColorRgba128Float? color, in Matrix3x2Float? transform)
Parameters
spriteBatch
ISpriteBatchThe sprite batch object.
destinationRectangle
RectFloatThe destination rectangle specifying where to draw the sprite.
sourceRectangle
RectInt32?The source rectangle specifying the region of the source bitmap to draw as a sprite. The entire source bitmap will be used if this parameter is null or RectInt32.LogicallyInfinite.
color
ColorRgba128Float?The color to apply to the sprite. The output color is the result of component-wise multiplication of the source bitmap color and the provided color. The output color is not clamped. Direct2D will not change the color of the sprite if null is provided.
transform
Matrix3x2Float?The transform to apply to the sprite's destination rectangle. Direct2D will not transform the destination rectangle of any sprite that is assigned a null value.
Remarks
Always use a null value for properties you do not wish to use. This allows Direct2D to avoid storing values for those properties and to skip their handling entirely, which improves drawing speed. For example, suppose you have a batch of 500 sprites, and you do not wish to transform any of their destination rectangles. Rather than passing an array of identity matrices, simply omit the transforms parameter. This allows Direct2D to avoid storing any transforms and will yield the fastest drawing performance. On the other hand, if any sprite in the batch has any value set for a property, then internally Direct2D must allocate space for that property array and assign every sprite a value for that property (even if it’s just the default value).