Home>Article>Web Front-end> Detailed explanation of image drawing examples in HTML5 canvas 9

Detailed explanation of image drawing examples in HTML5 canvas 9

高洛峰
高洛峰 Original
2017-01-11 17:00:17 1505browse

Draw an image

Var image=new Image();

image.src=” http://img4.duitang.com/uploads/item/201406/25/20140625182321_4MTau. thumb.700_0.jpeg”;

image.onload=function(){}

Context.drawImage(image,x,y);

Context.drawImage(image ,x,y,w,h);

Context.drawIamge(image,sx,sy,sw,sh,dx,dy,dw,dh);

Picture tiling

HTML5 canvas 9绘制图片实例详解

Var pat= context.createPattern(image,”repeat”);

Context.fillStyle=pat;

Context.fillRect(0 ,0,400,300);

Picture cropping

HTML5 canvas 9绘制图片实例详解

Draw the path first

Context.clip();

   绘制图片  

For more detailed explanations of HTML5 canvas 9 picture drawing examples and related articles, please pay attention to the PHP Chinese website!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn