【问题标题】:Fabric: can´t acces pathpoints anymoreFabric:无法再访问路径点
【发布时间】:2023-04-01 05:31:01
【问题描述】:

我写了一个小程序,我在其中移动路径点。这没问题,直到我更新到新的 Fabrics 2.x。

代码如下:

var boardpath = new fabric.Path('M '+eval(points[0][0]+versatzx)+' '+eval(points[0][1]+versatzy)+
                            ' Q '+eval(manis[0][0]+versatzx)+' '+eval(manis[0][1]+versatzy)+' '+eval(points[1][0]+versatzx)+' '+eval(points[1][1]+versatzy)+
                            ' Q '+eval(manis[1][0]+versatzx)+' '+eval(manis[1][1]+versatzy)+' '+eval(points[2][0]+versatzx)+' '+eval(points[2][1]+versatzy)+
                            ' Q '+eval(manis[2][0]+versatzx)+' '+eval(manis[2][1]+versatzy)+' '+eval(points[3][0]+versatzx)+' '+eval(points[3][1]+versatzy)+
                            ' Q '+eval(manis[3][0]+versatzx)+' '+eval(manis[3][1]+versatzy)+' '+eval(points[4][0]+versatzx)+' '+eval(points[4][1]+versatzy)+
                            ' Q '+eval(manis[4][0]+versatzx)+' '+eval(manis[4][1]+versatzy)+' '+eval(points[5][0]+versatzx)+' '+eval(points[5][1]+versatzy)+
                            ' Q '+eval(versatzx-manis[4][0])+' '+eval(manis[4][1]+versatzy)+' '+eval(versatzx-points[4][0])+' '+eval(points[4][1]+versatzy)+
                            ' Q '+eval(versatzx-manis[3][0])+' '+eval(manis[3][1]+versatzy)+' '+eval(versatzx-points[3][0])+' '+eval(points[3][1]+versatzy)+
                            ' Q '+eval(versatzx-manis[2][0])+' '+eval(manis[2][1]+versatzy)+' '+eval(versatzx-points[2][0])+' '+eval(points[2][1]+versatzy)+
                            ' Q '+eval(versatzx-manis[1][0])+' '+eval(manis[1][1]+versatzy)+' '+eval(versatzx-points[1][0])+' '+eval(points[1][1]+versatzy)+
                            ' Q '+eval(versatzx-manis[0][0])+' '+eval(manis[0][1]+versatzy)+' '+eval(points[0][0]+versatzx)+' '+eval(points[0][1]+versatzy)); //Bezier kurve, keine quadritische

  boardpath.set({ fill: 'white', stroke: 'black', strokeWidth: 2, opacity: 0.5, selectable: false});
  canvas.add(boardpath);

这就是我访问路径点的方式。

boardpath.path[2][3] = 120;
boardpath.path[2][4] = 120;

如前所述,我使用的是 Fabrics 1.6.4。它有效。但是更新到 2.x 最终会带来灾难。
加载 SVG 也不适用于新版本。 任何想法? 刚刚意识到,它不适用于 Fabric 1.7。在。所以改变一定是1.7。我将深入研究旧的 Fabric 更改日志。

【问题讨论】:

  • “总灾难”究竟是什么意思? “不工作”是什么意思。浏览器控制台中是否有错误消息?
  • 你好罗伯特,不,没有错误信息。彻底的灾难意味着,什么都没有了。我刚刚意识到它不适用于 1.7 版。没有了。
  • 您可以查看更改日志herehere
  • 这是1.7版本引入的对象缓存问题。问题解决了。至少这个问题,还有更多。

标签: javascript svg path fabricjs


【解决方案1】:

这是使更改在路径中可见所需要的。 Fabricjs 中尚不支持路径更改,因此如果您不通知对象他需要绘制操作,将脏标志设置为 true,则修改数组的嵌套属性不会对排序产生任何影响。

boardpath.path[2][3] = 120;
boardpath.path[2][4] = 120;
boardpath.dirty = true;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-19
    • 1970-01-01
    • 1970-01-01
    • 2019-07-06
    • 2014-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多