Why does the clip method work wrong into last versions of Chrome?

馋奶兔 提交于 2019-12-25 04:34:21

问题


I have a codepen http://codepen.io/artzub/pen/oXaVpz, which demonstrates how to use the clip method of Canvas with images.

// some code before
// ...

l = nodes.length;  
ctx.save();
while(l--) {
  item = nodes[l];    
  ctx.beginPath();    
  ctx.arc(item.x, item.y, 30, 0, 2*Math.PI);    
  ctx.closePath();
  ctx.stroke();
  ctx.fill();
  if (groupImg[item.group]) {      
    ctx.save();
    ctx.clip();
    ctx.drawImage(groupImg[item.group], item.x - 30, item.y - 30, 60, 60);
    ctx.restore();
  }        
}

ctx.restore();

But into the last versions of Chrome it does not work correct.

Do you have ideas why it is and how does it fix?

Also it works correct in Firefox.

来源:https://stackoverflow.com/questions/36756073/why-does-the-clip-method-work-wrong-into-last-versions-of-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!