侧边栏壁纸
  • 累计撰写 781 篇文章
  • 累计创建 1 个标签
  • 累计收到 1 条评论
标签搜索

drawImage

Dettan
2022-01-09 / 0 评论 / 0 点赞 / 39 阅读 / 1,916 字
温馨提示:
本文最后更新于 2022-04-30,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

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.

0

评论区