drawImage method

void drawImage(
  1. int argumentCount,
  2. Image? img,
  3. double sx,
  4. double sy,
  5. double sWidth,
  6. double sHeight,
  7. double dx,
  8. double dy,
  9. double dWidth,
  10. double dHeight,
)

Implementation

void drawImage(int argumentCount, Image? img, double sx, double sy, double sWidth, double sHeight, double dx, double dy, double dWidth, double dHeight) {
  if (img == null) return;

  addAction((Canvas canvas, Size size) {
    // ctx.drawImage(image, dx, dy);
    if (argumentCount == 3) {
      canvas.drawImage(img, Offset(dx, dy), Paint());
    } else {
      if (argumentCount == 5) {
        // ctx.drawImage(image, dx, dy, dWidth, dHeight);
        sx = 0;
        sy = 0;
        sWidth = img.width.toDouble();
        sHeight = img.height.toDouble();
      }

      canvas.drawImageRect(img,
          Rect.fromLTWH(sx, sy, sWidth, sHeight),
          Rect.fromLTWH(dx, dy, dWidth, dHeight),
          Paint());
    }
  });
}