drawRawAtlas method

void drawRawAtlas (Image atlas, Float32List rstTransforms, Float32List rects, Int32List colors, BlendMode blendMode, Rect cullRect, Paint paint)

Draws part of an image - the atlas - onto the canvas.

This method allows for optimization when you only want to draw part of an image on the canvas, such as when using sprites or zooming. It is more efficient than using clips or masks directly.

The rstTransforms argument is interpreted as a list of four-tuples, with each tuple being (RSTransform.scos, RSTransform.ssin, RSTransform.tx, RSTransform.ty).

The rects argument is interpreted as a list of four-tuples, with each tuple being (Rect.left, Rect.top, Rect.right, Rect.bottom).

The colors argument, which can be null, is interpreted as a list of 32-bit colors, with the same packing as Color.value.

See also:

  • drawAtlas, which takes its arguments as objects rather than typed data lists.

Implementation

void drawRawAtlas(Image atlas,
                  Float32List rstTransforms,
                  Float32List rects,
                  Int32List colors,
                  BlendMode blendMode,
                  Rect cullRect,
                  Paint paint) {
  assert(atlas != null); // atlas is checked on the engine side
  assert(rstTransforms != null);
  assert(rects != null);
  assert(colors != null);
  assert(blendMode != null);
  assert(paint != null);

  final int rectCount = rects.length;
  if (rstTransforms.length != rectCount)
    throw ArgumentError('"rstTransforms" and "rects" lengths must match.');
  if (rectCount % 4 != 0)
    throw ArgumentError('"rstTransforms" and "rects" lengths must be a multiple of four.');
  if (colors != null && colors.length * 4 != rectCount)
    throw ArgumentError('If non-null, "colors" length must be one fourth the length of "rstTransforms" and "rects".');

  _drawAtlas(
    paint._objects, paint._data, atlas, rstTransforms, rects,
    colors, blendMode.index, cullRect?._value32
  );
}