【问题标题】:Fill a path node in Draw2d touch在 Draw2d touch 中填充路径节点
【发布时间】:2014-11-03 04:58:13
【问题描述】:

我正在尝试制作一个连接矩形和路径(三角形)的箭头。这是我的代码:

var svgCarga = [
  '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',
  '<rect opacity="0" height="50" width="50" y="0" x="0" stroke-width="0" stroke="#000" fill="#fff"/>',
  '<rect stroke="#000" height="29.875" width="4" y="6.3125" x="23" stroke-width="0" fill="#000000"/>',
  '<path fill="#000000" stroke="#000" d="m17.41375,36.090939l7.4375,10l7.4375,-10l-14.875,0z" stroke-width="1"/>',
  '</svg>',
].join();


Carga = draw2d.SVGFigure.extend({
  NAME: 'Carga',
  init: function() {
    this._super();
    this.width = 65;
    this.height = 65;
  },
  getSVG: function() {
    return svgCarga;
  }
});

如您所见,路径有一个属性:fill="#000000" 但渲染时显示 fill="none"...如果我手动更改此属性,则显示路径已填充。

【问题讨论】:

    标签: svg raphael draw2d-js


    【解决方案1】:

    我不知道你到底想做什么。

    我认为您目前无法在 Draw2D 中填充 SVG 路径(请记住,SVGFigure 导入目前非常有限

    '<path fill="#000000" stroke="#000" d="m17.41375,36.090939l7.4375,10l7.4375,-10l-14.875,0z" stroke-width="1"/>'
    

    您可以使用多边形来执行此操作,如下所示:

    '<polygon points="25,45 15,35 35,35" fill="#000000" stroke="#000" stroke-width="1" />'
    

    希望这是你想要的:)

    参考:

    http://draw2d.org/draw2d_touch/jsdoc_5/#!/guide/extending_svg_figure
    

    【讨论】:

      猜你喜欢
      • 2019-07-06
      • 2023-01-29
      • 1970-01-01
      • 2018-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-02
      • 2020-03-14
      相关资源
      最近更新 更多