drawImageScaled method

  1. @JSName('drawImage')
void drawImageScaled (
  1. CanvasImageSource source,
  2. num destX,
  3. num destY,
  4. num destWidth,
  5. num destHeight
)
@JSName('drawImage')

Draws an image from a CanvasImageSource to an area of this canvas.

The image will be drawn to this context with its top left corner at the point (destX, destY) and will be scaled to be destWidth wide and destHeight tall.

If the image is larger than canvas will allow, the image will be clipped to fit the available space.

CanvasElement canvas = new CanvasElement(width: 600, height: 600);
CanvasRenderingContext2D ctx = canvas.context2D;
ImageElement img = document.query('img');
img.width = 100;
img.height = 100;

// Scale the image to 300x50 at the point (20, 20)
ctx.drawImageScaled(img, 20, 20, 300, 50);

See also:

Implementation

@JSName('drawImage')
void drawImageScaled(CanvasImageSource source, num destX, num destY,
    num destWidth, num destHeight) native;

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-html/CanvasRenderingContext2D/drawImageScaled.html