为了账号安全,请及时绑定邮箱和手机立即绑定

context.isPointInPath(x, y) 和想象中的不一样啊?

context.isPointInPath(x, y) 和想象中的不一样啊?

繁花不似锦 2018-09-11 09:46:38
<!DOCTYPE html><html><head>    <meta charset="UTF-8">     <title>Canvas: Point In Path</title></head><body>   <canvas id="canvas"></canvas>    <script>    var canvas = document.getElementById('canvas');        var context = canvas.getContext('2d');    canvas.width = 600;    canvas.height = 400;        context.fillStyle = "#efefef";    context.fillRect(0, 0, canvas.width, canvas.height);        context.beginPath();    context.strokeStyle = "blue";    context.lineWidth = 3;        context.moveTo(30, 30);    context.lineTo(300, 300);    context.stroke();    context.closePath();        console.log(context.isPointInPath(30, 30)); // true    console.log(context.isPointInPath(100, 100)); // false        console.log(context.isPointInPath(300, 300)); // true    </script></body></html>(100, 100)为什么判断不在path上,奇怪啊,是哪里遗漏了什么吗?
查看完整描述

1 回答

?
慕虎7371278

TA贡献1802条经验 获得超4个赞

没有遗漏,浏览器的问题,Chrome上有问题Safari上没事

https://img1.sycdn.imooc.com//5bcae316000166df11640622.jpg

https://img1.sycdn.imooc.com//5bcae3220001861c17230653.jpg


查看完整回答
反对 回复 2018-10-20
  • 1 回答
  • 0 关注
  • 456 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信