Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SVG定义继承_Svg - Fatal编程技术网

SVG定义继承

SVG定义继承,svg,Svg,请看eaExperiment。我想做一个定义,它接受星行的定义并将其旋转180度 <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#

请看
eaExperiment
。我想做一个定义,它接受星行的定义并将其旋转180度

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="450" height="400" version="1.1">
  <style type="text/css">
    <![CDATA[
      rect {fill:white; stroke: black; stroke-width: 1;}
      text {fill: black; font-family: sans-serif; font-size: 10pt}
      line {stroke:black; stroke-width:2}
    ]]>
  </style>
  <defs>
    <marker orient="auto" refY="0.0" refX="0.0" id="StartArrow" style="overflow:visible;">
      <path style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " />
    </marker>
    <use id="eaExperiment" href="#StartArrow" transform="rotate(180)" />
    <marker orient="auto" refY="0.0" refX="0.0" id="EndArrow" style="overflow:visible;">
      <path style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " transform="rotate(180)" />
    </marker>
    <svg id="Box">
      <rect width="100" height="85" x="1" y="1" />
      <text x="5" y="20">The box</text>
      <svg x="10" y="25">
        <rect width="70" height="50" x="1" y="1" />
        <text x="5" y="20">Box</text>
        <text x="5" y="40">Contents</text>
      </svg>
    </svg>
  </defs>
  <svg>
    <svg x="10" y="120">
      <rect width="100" height="50" x="1" y="1" />
      <text x="5" y="20">Data</text>
      <text x="5" y="40">source</text>
    </svg>
    <svg x="150">
      <use href="#Box" y="1" />
      <use href="#Box" y="100" />
      <use href="#Box" y="200" />
    </svg>
    <svg x="300" y="120">
      <rect width="100" height="50" x="1" y="1" />
      <text x="5" y="20">Database</text>
      <text x="5" y="40">server</text>
    </svg>
    <line x1="100" y1="120" x2="148" y2="40" style="marker-end:url(#EndArrow)" />
    <line x1="110" y1="150" x2="147" y2="150" style="marker-end:url(#EndArrow)" />
    <line x1="100" y1="170" x2="148" y2="240" style="marker-end:url(#EndArrow)" />
    <line x1="254" y1="40" x2="297" y2="120" style="marker-start:url(#StartArrow); marker-end:url(#EndArrow)" />
    <line x1="250" y1="150" x2="297" y2="150" style="marker-start:url(#eaExperiment); marker-end:url(#EndArrow)" />
    <line x1="250" y1="240" x2="297" y2="170" style="marker-end:url(#EndArrow)" />
  </svg>
</svg>

盒子
盒子
目录
资料
来源
数据库
服务器
我肯定做错了,但正确的方法是什么?

您需要单独的
元素,但它们的内容可以与
元素一起重用。例如:

<defs>
  <path id="arrow" style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " />
  <marker orient="auto" refY="0.0" refX="0.0" id="StartArrow" style="overflow:visible;">
    <use xlink:href="#arrow" />
  </marker>
  <marker orient="auto" refY="0.0" refX="0.0" id="EndArrow" style="overflow:visible;">
    <use xlink:href="#arrow" transform="rotate(180)" />
  </marker>
</defs>

(虽然将
xlink
名称空间与
href
一起使用已被弃用,而且从实用角度来看,当前浏览器不再需要它,但我倾向于为了其他渲染器(例如Inkscape)而使用它。)