Table of Contents

Method AddSprites

Namespace
PaintDotNet.Direct2D1
Assembly
PaintDotNet.Windows.dll

AddSprites(int, ReadOnlySpan<RectFloat>, ReadOnlySpan<RectInt32>, ReadOnlySpan<ColorRgba128Float>, ReadOnlySpan<Matrix3x2Float>)

Adds the given sprites to the end of this sprite batch. You may use a 1-length span for any of the properties to use the same value for each sprite. You may use a 0-length span (using the C# default keyword, or ReadOnlySpan<T>.Empty) for sourceRectangles, colors, or transforms in order to use the default policy associated with that property. This can reduce memory usage and increase performance.

void AddSprites(int spriteCount, ReadOnlySpan<RectFloat> destinationRectangles, ReadOnlySpan<RectInt32> sourceRectangles, ReadOnlySpan<ColorRgba128Float> colors, ReadOnlySpan<Matrix3x2Float> transforms)

Parameters

spriteCount int

The number of sprites to be added.

destinationRectangles ReadOnlySpan<RectFloat>

The destination rectangles specifying where to draw the sprites.

sourceRectangles ReadOnlySpan<RectInt32>

The source rectangles specifying the regions of the source bitmap to draw as sprites. Direct2D will use the entire source bitmap for sprites that are assigned a null value or if RectInt32.LogicallyInfinite is used. If this span is empty, Direct2D will use the entire source bitmap for all of the added sprites.

colors ReadOnlySpan<ColorRgba128Float>

The colors to apply to each 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 sprites that are assigned a null value. If this span is empty, then Direct2D will not change the color of any of the added sprites.

transforms ReadOnlySpan<Matrix3x2Float>

The transforms to apply to each sprite's destination recangle. Direct2D will not transform the destination rectangle of any sprites that are assigned a null value. If this span is empty then Direct2D will not transform the destination rectangle of any of the added sprites.

Remarks

Always use an empty span 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).