HTML5 canvas isPointInPath() ·½·¨

ʵÀý

»æÖÆÒ»¸ö¾ØÐΣ¬Èç¹ûµã 20,50 λÓÚµ±Ç°Â·¾¶ÖУº

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rect(20,20,150,100);
if (ctx.isPointInPath(20,50))
   {
   ctx.stroke();
   };

Ç××ÔÊÔÒ»ÊÔ

ä¯ÀÀÆ÷Ö§³Ö

Internet Explorer 9¡¢Firefox¡¢Opera¡¢Chrome ÒÔ¼° Safari Ö§³Ö isPointInPath() ·½·¨¡£

×¢ÊÍ£ºInternet Explorer 8 »ò¸üÔçµÄä¯ÀÀÆ÷²»Ö§³Ö <canvas> ÔªËØ¡£

¶¨ÒåºÍÓ÷¨

isPointInPath() ·½·¨·µ»Ø true£¬Èç¹ûÖ¸¶¨µÄµãλÓÚµ±Ç°Â·¾¶ÖУ»·ñÔò·µ»Ø false¡£

JavaScript Óï·¨£º

context.isPointInPath(x,y);

²ÎÊýÖµ

²ÎÊý ÃèÊö
x ²âÊ﵀ x ×ø±ê
y ²âÊ﵀ y ×ø±ê
VUE