drawImageScaled method
- @JSName('drawImage')
- CanvasImageSource source,
- num destX,
- num destY,
- num destWidth,
- num destHeight
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:
- CanvasImageSource for more information on what data is retrieved
from
source
. - drawImage from the WHATWG.
Implementation
@JSName('drawImage')
void drawImageScaled(CanvasImageSource source, num destX, num destY,
num destWidth, num destHeight) native;