On this page
drawImage method
- @DomName('CanvasRenderingContext2D.drawImage')
Draws an image from a CanvasImageSource to this canvas.
The entire image from source
will be drawn to this context with its top left corner at the point (destX
, destY
). 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');
ctx.drawImage(img, 100, 100);
VideoElement video = document.query('video');
ctx.drawImage(video, 0, 0);
CanvasElement otherCanvas = document.query('canvas');
otherCanvas.width = 100;
otherCanvas.height = 100;
ctx.drawImage(otherCanvas, 590, 590); // will get clipped
See also:
- CanvasImageSource for more information on what data is retrievedfrom
source
. - drawImagefrom the WHATWG.
Source
@DomName('CanvasRenderingContext2D.drawImage')
void drawImage(CanvasImageSource source, num destX, num destY) {
_drawImage(source, destX, destY);
}
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-html/CanvasRenderingContext2D/drawImage.html