Draw pictures
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
Var pat= context.createPattern(image,"repeat");
Context.fillStyle=pat;
Context.fillRect(0,0,400,300);
Image cropping
Draw the path first
Context.clip();
<html> <head> <meta charset="UTF-8"> <title>Draw pictures</title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> </head> <body> <canvas id="canvas"></canvas> <script type="text/javascript"> var oCanvas = document.getElementById("canvas"); var context = oCanvas.getContext("2d"); context.fillStyle = "#ededed"; context.fillRect(0, 0, 500, 500); //Draw the image var img = new Image(); //Create img.src = "img/01.jpg"; //Image address img.onload = function() { //Detect all image information loading page context.drawImage(img, 0, 0); //img object; 0,0:img coordinate starting point}; </script> </body></html>