var myImage=document.getElementByIdx_x("myCanvas");
var cxt=myImage.getContext("2d");
var img=new Image();
img.src="200.jpg";
cxt.drawImage(img,50,50);
var myImage=document.getElementByIdx_x("myCanvas");
var cxt=myImage.getContext("2d");
var img=new Image();
img.src="200.jpg";
cxt.drawImage(img,50,50,100,100);
7、图片裁剪:drawImage方法的功用是对图像进行裁剪。drawImage(image,sourceX,sourceY,sourceWidth,sourceHeight,destX,destY,destWidth, destHeight) 8、参数很多,但基本上你可以把它想成从原图中取出一个矩形区域,然后把它画到画布上目标区域里。 9、代码如下: var myImage=document.getElementByIdx_x("myCanvas");
var cxt=myImage.getContext("2d");
var img=new Image();
img.src="200.jpg";
cxt.drawImage(img,0,0,50,50,25,25,100,100);
cxt.drawImage(img,125,125,100,100,125,125,150,150);
var myImage=document.getElementByIdx_x("myCanvas");
var cxt=myImage.getContext("2d");
var img=new Image();
img.src="200.jpg";
cxt.drawImage(img,50,50);
var myImage=document.getElementByIdx_x("myCanvas");
var cxt=myImage.getContext("2d");
var img=new Image();
img.src="200.jpg";
cxt.drawImage(img,50,50,100,100);
7、图片裁剪:drawImage方法的功用是对图像进行裁剪。drawImage(image,sourceX,sourceY,sourceWidth,sourceHeight,destX,destY,destWidth, destHeight) 8、参数很多,但基本上你可以把它想成从原图中取出一个矩形区域,然后把它画到画布上目标区域里。 9、代码如下: var myImage=document.getElementByIdx_x("myCanvas");
var cxt=myImage.getContext("2d");
var img=new Image();
img.src="200.jpg";
cxt.drawImage(img,0,0,50,50,25,25,100,100);
cxt.drawImage(img,125,125,100,100,125,125,150,150);