如何获取Fabric JS canvas中元素可见部分的坐标?

时间:2019-07-05 14:47:31

标签: html5-canvas fabricjs

因此,我需要在viewport元素的可见部分(在fabric内部)绘制内嵌边框:

So I need to draw inline border on the visible (inside <code>viewport</code>) part of a <code>fabric</code> element.

我尝试了stroke的元素,但正如预期的那样,它与图像一起被裁剪了:

I tried <code>stroke</code> on the element but as expected, it's getting cropped along with the image

我希望在悬停时在所选元素上显示1型边框,并在其上显示2型边框。我为悬停事件尝试了类似的方法:

canvas.on('mouse:over', function(e) { e.target.set('strokeWidth', 4); canvas.renderAll(); });
canvas.on('mouse:out', function(e) { e.target.set('strokeWidth', 0); canvas.renderAll(); });
canvas.loadFromJSON(json,canvas.renderAll.bind(canvas),
function(o, object){
    object.set('stroke', '#59fee8');
    object.set('strokeWidth', 0);
});

0 个答案:

没有答案