CanvasDrawImage.drawImage( image: CanvasImageSource, dx: number, dy: number): void
drawImage(image: CanvasImageSource, dx: number, dy: number, dw: number, dh: number): void,
drawImage(image: CanvasImageSource, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number): void
参数
The CanvasRenderingContext2D.drawImage() method of the Canvas 2D API provides different ways to draw an image onto the canvas.
image – An element to draw into the context. The specification permits any canvas image source ( CanvasImageSource ), specifically, a CSSImageValue , an HTMLImageElement , an SVGImageElement , an HTMLVideoElement , an
HTMLCanvasElement , an ImageBitmap , or an OffscreenCanvas .
dx – The x-axis coordinate in the destination canvas at which to place the top-left corner of the source image .
dy – The y-axis coordinate in the destination canvas at which to place the top-left corner of the source image .
sx – The x-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context. Note that this argument is not included in the 3- or 5-argument syntax.
sy – The y-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context. Note that this argument is not included in the 3- or 5-argument syntax.
sWidth – The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used. Note that this argument is not included in the 3- or 5-argument syntax.
sHeight – The height of the sub-rectangle of the source image to draw into the destination context. Note that this argument is not included in the 3- or 5-argument syntax.
dWidth – The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn. Note that this argument is not included in the 3-argument syntax.
dHeight – The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn. Note that this argument is not included in the 3-argument syntax.
评论区