代码之家  ›  专栏  ›  技术社区  ›  James Ives

自下而上填充SVG

svg
  •  1
  • James Ives  · 技术社区  · 7 年前

    我有一个SVG,我正在尝试用填充从下到上设置动画。我要从颜色代码开始 #ddd 我希望它以 #ccc

    这就是我目前掌握的情况。

    <svg width="30px" height="30px" viewBox="0 0 30 30" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
        <g id="Dashboard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <linearGradient id="lg" x1="0.5" y1="1" x2="0.5" y2="0">
                    <stop offset="0%"  stop-color="#ddd"/>
                    <stop offset="50%" stop-color="#ccc">
                      <animate attributeName="offset" values="0;1;0"  dur="1s" begin="0s"/>
                    </stop>
                    <stop offset="100%" stop-opacity="1" stop-color="#ccc">
                      <animate attributeName="offset" values="0;1;0"  dur="1s"  begin="0s"/>
                    </stop> 
                </linearGradient>
            <g transform="translate(-1161.000000, -558.000000)" fill="url(#lg)" id="current-net-wealth">
                <g transform="translate(437.000000, 475.000000)">
                    <g id="houses" transform="translate(340.000000, 83.000000)">
                        <g id="house" transform="translate(384.000000, 0.000000)">
                            <polygon id="Path" points="21 6.66002593 21 3 25 3 25 11.1000432 30 16.6500648 25.3846154 16.6500648 25.3846154 30 4.61538462 30 4.62306431 16.6500648 0 16.6500648 15 0"></polygon>
                        </g>
                    </g>
                </g>
            </g>
        </g>
    </svg>
    

    我需要在车站再加一站吗 linearGradiant 动画?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Robert Longson    7 年前

    像这样的。

    • 你的值使填充物又上又下
    • 你的颜色和你说的不相配

    <svg width="30px" height="30px" viewBox="0 0 30 30" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
        <g id="Dashboard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <linearGradient id="lg" x1="0.5" y1="1" x2="0.5" y2="0">
                    <stop offset="0%" stop-color="#ccc"/>
                    <stop offset="0%" stop-color="#ccc">
                      <animate attributeName="offset" to="100%" dur="1s" begin="0s" fill="freeze"/>
                    </stop>
                    <stop offset="0%" stop-color="#ddd">
                      <animate attributeName="offset" to="100%" dur="1s" begin="0s" fill="freeze"/>                </stop> 
                </linearGradient>
            <g transform="translate(-1161.000000, -558.000000)" fill="url(#lg)" id="current-net-wealth">
                <g transform="translate(437.000000, 475.000000)">
                    <g id="houses" transform="translate(340.000000, 83.000000)">
                        <g id="house" transform="translate(384.000000, 0.000000)">
                            <polygon id="Path" points="21 6.66002593 21 3 25 3 25 11.1000432 30 16.6500648 25.3846154 16.6500648 25.3846154 30 4.61538462 30 4.62306431 16.6500648 0 16.6500648 15 0"></polygon>
                        </g>
                    </g>
                </g>
            </g>
        </g>
    </svg>