canvas如何实现流泪
展开全部
指定两个canvas的postion:absolution,然后设置者两个canvas的left与top属性,需要注意的是建议把小的canvas放到上面,方法是设置两个canvas的z-index为不同的值,值大的在上面。
绘图的过程可以参考一下代码:
var mycanvas=document.getElementByIdx_x_x_x("mycanvas");
var context = mycanvas.getContext("2d");
var imageObj = new Image();
imageObj.onload = function(){
// draw cropped image
var sourceX = 350;
var sourceY = 50;
var sourceWidth = 350;
var sourceHeight = 350;
var destWidth = sourceWidth;
var destHeight = sourceHeight;
var destX = mycanvas.width / 2 - destWidth / 2;
var destY = mycanvas.height / 2 - destHeight / 2;
context.drawImage(imageObj, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight);
绘图的过程可以参考一下代码:
var mycanvas=document.getElementByIdx_x_x_x("mycanvas");
var context = mycanvas.getContext("2d");
var imageObj = new Image();
imageObj.onload = function(){
// draw cropped image
var sourceX = 350;
var sourceY = 50;
var sourceWidth = 350;
var sourceHeight = 350;
var destWidth = sourceWidth;
var destHeight = sourceHeight;
var destX = mycanvas.width / 2 - destWidth / 2;
var destY = mycanvas.height / 2 - destHeight / 2;
context.drawImage(imageObj, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询