问答详情
源自:4-1 适应移动端屏幕尺寸

cxt.arc(clipArea.x,clipArea.y,clipArea.r,0,Math.PI*2,true);报ubdefindcuo

var canWidth = 1500;

var canHeight = 800;

var can =  document.getElementById('canvas');

var cxt = can.getContext('2d');

var clipArea = {x:750,y:400,r:80};

var img = new Image();

window.onload = function(){

initCanvas();

}

can.width = canWidth;

can.height = canHeight;

img.src = "img/fpic410.jpg";

img.onload = function(e){

initCanvas()

}

function initCanvas(){

draw(img);

}

function setClipArea(clipArea){

cxt.beginPath();

cxt.arc(clipArea.x,clipArea.y,clipArea.r,0,Math.PI*2,true);

cxt.clip();

}


function draw(image,clipArea){

cxt.clearRect(0,0,can.width,can.height);

cxt.save();

setClipArea(clipArea);

cxt.drawImage(img,0,0);

cxt.restore();

}


提问者:qq_驦之锿殤_0 2016-03-31 21:38

个回答

  • 湛瞳
    2016-09-19 10:49:18

    你的draw函数定义的是有两个参数,可是传递的时候你只给了一个参数,它肯定找不到clipArea的

    http://img.mukewang.com/57df51e00001d0e005430389.jpg


  • qq_驦之锿殤_0
    2016-04-18 18:27:34

    .........


  • 不惧亢龙
    2016-04-05 21:19:25

    看不懂