drawImageArea method

  1. @override
void drawImageArea(
  1. PCanvasImage image,
  2. int srcX,
  3. int srcY,
  4. int srcWidth,
  5. int srcHeight,
  6. num dstX,
  7. num dstY,
  8. num dstWidth,
  9. num dstHeight,
)
override

Draw an image part (srcX,srcY , srcWidth x srcHeight) to a destiny area (dstX,dstY , dstWidth x dstHeight).

Implementation

@override
void drawImageArea(PCanvasImage image, int srcX, int srcY, int srcWidth,
    int srcHeight, num dstX, num dstY, num dstWidth, num dstHeight) {
  checkImageLoaded(image);

  dstX = transform.x(dstX);
  dstY = transform.y(dstY);

  dstX = canvasX(dstX);
  dstY = canvasY(dstY);
  dstWidth = canvasX(dstWidth);
  dstHeight = canvasY(dstHeight);

  if (image is _PCanvasImageElement) {
    _ctx.drawImageScaledFromSource(image.imageElement, srcX, srcY, srcWidth,
        srcHeight, dstX, dstY, dstWidth, dstHeight);
  } else {
    throw ArgumentError("Can't handle image type: $image");
  }
}