setPixels method

  1. @override
void setPixels(
  1. PCanvasPixels pixels, {
  2. int x = 0,
  3. int y = 0,
  4. int? width,
  5. int? height,
})
override

Sets the canvas pixels.

Implementation

@override
void setPixels(PCanvasPixels pixels,
    {int x = 0, int y = 0, int? width, int? height}) {
  var w = width ?? this.width;
  if (x + w > this.width) w = this.width - x;

  var h = height ?? this.height;
  if (y + h > this.height) h = this.height - y;

  if (w <= 0 || h <= 0) return;

  for (var y1 = 0; y1 < h; ++y1) {
    for (var x1 = 0; x1 < w; ++x1) {
      var p = pixels.getImageColor(x, y);
      _bitmap.setPixel(x + x1, y + y1, p);
    }
  }
}