【发布时间】:2018-01-17 15:10:05
【问题描述】:
我知道我可以通过使用以下模板绘制形状来向 MxGraph 添加形状:
<shape name="or" aspect="variable">
<background>
<path>
<move x="0" y="0"/>
<quad x1="100" y1="0" x2="100" y2="50"/>
<quad x1="100" y1="100" x2="0" y2="100"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
或用 JavaScript 绘制为:
BoxShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
{
var dy = this.extrude * this.scale;
var dx = this.extrude * this.scale;
path.moveTo(0, dy);
path.lineTo(w - dx, dy);
path.lineTo(w, 0);
path.moveTo(w - dx, dy);
path.lineTo(w - dx, h);
};
我觉得这两个选项太原始而无法创建复杂的形状。 Draw.io 使用像下面这样的花哨的图形,我觉得用下面的代码来绘制它们会有点矫枉过正,有人可能会使用一些转换器直接从 SVG 中做到这一点。
我检查了那些是绘图(渲染为 SVG)的元素,而不是可以轻松放在 MxGraph 中的顶点顶部的普通图像
是否有任何简单的方法来创建自定义对象而无需手动编写代码,如下所示?
【问题讨论】:
标签: javascript svg mxgraph