通过 containsPoint 方法坐标是否在某个元素内

const rect = new fabric.Rect({
    width: 100,
    height: 100,
    fill: 'red',
  })
  canvas.add(rect);
  canvas.on('mousee:down', (event) => {
    let point = new fabric.Point(event.e.offsetX, event.e.offsetY);
    console.log(rect.containsPoint(point));
  })

 

posted on 2023-08-21 18:43  浅唱年华1920  阅读(273)  评论(0编辑  收藏  举报