addTransform method

void addTransform({
  1. required Rect source,
  2. RSTransform? transform,
  3. Color? color,
})

Add a new batch item using a RSTransform.

The source parameter is the source location on the atlas.

You can position, rotate and scale it on the canvas using the transform parameter.

The color parameter allows you to render a color behind the batch item, as a background color.

The add method may be a simpler way to add a batch item to the batch. However, if there is a way to factor out the computations of the sine and cosine of the rotation so that they can be reused over multiple calls to this constructor, it may be more efficient to directly use this method instead.

Implementation

void addTransform({
  required Rect source,
  RSTransform? transform,
  Color? color,
}) {
  final batchItem = BatchItem(
    source: source,
    transform: transform ??= defaultTransform ?? RSTransform(1, 0, 0, 0),
    color: color ?? defaultColor,
  );

  _batchItems.add(batchItem);

  _sources.add(batchItem.source);
  _transforms.add(batchItem.transform);
  _colors.add(batchItem.color);
}