Documentation / @ripl/canvas / canvasDrawImage
Function: canvasDrawImage() ​
canvasDrawImage(
ctx,image,x,y,width?,height?):void
Defined in: canvas/src/utilities.ts:384
Draws an image onto a canvas context, sizing it to the given width and height.
A dimension given on its own is honoured and the other taken from the image's intrinsic size — the destination-rectangle form of drawImage needs both. Supplying neither draws at intrinsic size; supplying 0 draws nothing, which is what a zero-sized element asks for.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
ctx | CanvasRenderingContext2D | The native context to draw into. |
image | CanvasImageSource | The image source to draw. |
x | number | Destination x coordinate. |
y | number | Destination y coordinate. |
width? | number | Destination width, defaulting to the image's intrinsic width. |
height? | number | Destination height, defaulting to the image's intrinsic height. |
Returns ​
void