copyFrom method

void copyFrom({
  1. PImage? source,
  2. required Rect sourceRect,
  3. required Rect destRect,
})

Copies pixels into this PImage from the given source, or replicates a region of this PImage within itself if no source is provided.

The sourceRect is the area that is copied, and the destRect is the area within this PImage where the copy will painted.

Implementation

void copyFrom({
  PImage? source,
  required Rect sourceRect,
  required Rect destRect,
}) {
  source ??= this;

  final copyImage = source.copy(sourceRect);

  _add(copyImage, destRect.topLeft);
}