V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
salamanderMH
V2EX  ›  问与答

提取 SVG 中元素如何解决引用其他元素的问题?

  •  
  •   salamanderMH · Dec 3, 2020 · 989 views
    This topic created in 1975 days ago, the information mentioned may be changed or developed.

    就想提取 SVG 中第一层的元素,像下面的 SVG:

    <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
       <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="78" y1="269.543" x2="237" y2="269.543">......</linearGradient>
        <symbol  id="test" viewBox="-16.126 -14.41 32.251 28.819">...</symbol>
        <rect x="78" y="203.043" style="fill:url(#SVGID_1_);" width="159" height="133"/>
        <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" />
        <g>
            <use xlink:href="#test" width="32.251" height="28.819" x="-16.126" y="-14.41" transform="matrix(1 0 0 -1 402.9284 846.39)" style="overflow:visible;"></use>
        </g>
    </svg>
    

    要提取rectcircleg元素,但是rect引用了linearGradientg引用了symbol,这个问题咋解决呢?
    这个可以把元素转化为 svg 文本,但是没解决引用的问题。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1509 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 16:20 · PVG 00:20 · LAX 09:20 · JFK 12:20
    ♥ Do have faith in what you're doing.