如何将多路径svg转换为一条路径

时间:2018-11-11 05:27:46

标签: xml svg graphics

.png中的图像很少。使用Adobe illustrator,我已将它们转换为黑白模式的.svg。 在生成的svg文件中,有多个路径标签。

    <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<g>
    <g>
        <path style="fill:#FFFFFF;" d="M514,514c-170.7,0-341.3,0-512,0C2,343.4,2,172.7,2,2c170.7,0,341.3,0,512,0
            C514,172.7,514,343.4,514,514z M257.6,6.4C119.5,6.2,7,117.9,6.5,255.8C6,394.1,118.3,507.2,256.5,507.5
            c137.8,0.3,250.6-111.9,251.1-249.6C508.1,119.4,395.9,6.6,257.6,6.4z"/>
        <path d="M257.6,6.4c138.3,0.2,250.5,113.1,250,251.6c-0.5,137.7-113.3,249.9-251.1,249.6C118.3,507.2,6,394.1,6.5,255.8
            C7,117.9,119.5,6.2,257.6,6.4z M256.6,358.8c0.3,4.2,0.6,7.6,0.7,10.9c0.2,27.6,0.3,55.3,0.4,82.9c0,15.1-4.2,18.9-19.1,17.6
            C127,461,41.4,366.1,42.9,253.3C44.3,141.9,133.4,49.1,244.6,43c102.4-5.6,194.8,61.7,219.9,160.4
            C490,303.1,441.8,406,348.6,450.5c-3.7,1.8-7.8,2.9-11,5.4c-1.9,1.5-3.8,5.5-3.1,7.4c0.7,1.8,5,3.7,7.2,3.2
            c4.6-0.9,9-3.2,13.3-5.2C454,414,504.5,302,474.9,195.8C445.3,90,344.1,21.3,234.1,32.3C103.7,45.4,11.8,166.1,34.1,295.2
            C51.8,397.9,133.3,472.6,238.6,483c4.9,0.5,10,3.2,14.2,6c7.2,4.9,14.2,5.7,20.5-0.2c6.4-6,5.9-12.9,1.2-20.3
            c-2.5-4-4.7-9.1-4.8-13.7c-0.7-29.3-0.6-58.7-1.3-88c-0.2-8.2,2.4-12.5,10-16.3c25.9-13,39.5-40.1,35.9-68.8
            c-3.6-28-23.8-50.9-51.4-57.2c-6.9-1.6-14.2-1.8-21.3-2.5c-29.7-3.1-50.5-27.4-49.2-57.7c1.1-27.7,24.6-50.7,52.7-51.4
            c29.4-0.8,53.7,20.6,56.4,49.7c0.3,3.6,0.7,7.3,1.1,12c13.2,0,25.4-0.2,37.7,0c41.2,0.7,77.3,31.4,83.3,71
            c6.5,42.3-17,81.8-56.6,95.6c-6.2,2.2-11.4,3.7-17.4-2.5c-6.8-7-18.6-4.6-24.4,3.1c-5.7,7.5-4.6,17.8,2.5,24
            c7.1,6.1,17.1,5.2,24.3-0.9c4.9-4.1,10.5-8.1,16.5-10c40.8-13.1,69.4-51.2,69.7-93.9c0.3-42.2-27.1-81.6-67.6-94
            c-13.7-4.2-28.8-4.7-43.4-5.2c-9-0.3-12.6-2.4-14.9-11.7c-9.4-37.2-47.8-58.3-84.7-47.5c-36,10.6-56.6,49.1-45.4,85.3
            c8.9,29,32.5,45.8,67.7,48c23.5,1.5,42.5,16.3,49.3,38.3c6.8,21.9-0.6,45.7-18.8,59.6c-3,2.3-6.6,4-11.3,6.8
            c-0.3-5.7-0.6-9.4-0.8-13c-1.7-27.1-21.1-50.3-47.4-56.2c-7-1.5-14.3-1.4-21.3-2.6c-21.4-3.4-38.3-13.7-49.2-32.9
            c-3.2-5.7-3.7-10.4,1.4-16.5c3.4-4,4.5-12.6,2.5-17.5c-1.7-4.3-9.3-9-14-8.8c-5.3,0.2-10.6,5.4-15.3,9.2c-3.7,3-6,8.1-10,10.5
            c-27.5,16.8-43.1,48.1-38.5,78c6.4,40.8,37.8,68,79.4,68.2C189.1,359,222.2,358.8,256.6,358.8z"/>
        <path style="fill:#FFFFFF;" d="M256.6,358.8c-34.4,0-67.5,0.1-100.6,0c-41.5-0.2-73-27.4-79.4-68.2c-4.7-29.9,11-61.3,38.5-78
            c4-2.4,6.2-7.5,10-10.5c4.7-3.8,10.1-9,15.3-9.2c4.8-0.2,12.3,4.5,14,8.8c2,4.9,0.8,13.5-2.5,17.5c-5.1,6.1-4.7,10.7-1.4,16.5
            c10.8,19.2,27.8,29.5,49.2,32.9c7.1,1.1,14.4,1,21.3,2.6c26.3,5.9,45.7,29.1,47.4,56.2c0.2,3.7,0.4,7.3,0.8,13
            c4.7-2.8,8.2-4.4,11.3-6.8c18.2-13.9,25.6-37.7,18.8-59.6c-6.8-22-25.8-36.8-49.3-38.3c-35.2-2.3-58.8-19.1-67.7-48
            c-11.1-36.2,9.4-74.7,45.4-85.3c36.9-10.8,75.3,10.3,84.7,47.5c2.3,9.2,6,11.4,14.9,11.7c14.5,0.5,29.6,1,43.4,5.2
            c40.5,12.5,67.9,51.8,67.6,94c-0.3,42.7-28.9,80.8-69.7,93.9c-6,1.9-11.7,5.9-16.5,10c-7.2,6.1-17.2,7-24.3,0.9
            c-7.1-6.2-8.2-16.5-2.5-24c5.8-7.6,17.6-10.1,24.4-3.1c6,6.2,11.2,4.6,17.4,2.5c39.6-13.8,63.1-53.3,56.6-95.6
            c-6-39.6-42.1-70.4-83.3-71c-12.2-0.2-24.5,0-37.7,0c-0.4-4.7-0.8-8.4-1.1-12c-2.7-29.1-27-50.5-56.4-49.7
            c-28,0.8-51.5,23.7-52.7,51.4c-1.2,30.3,19.5,54.6,49.2,57.7c7.1,0.7,14.4,0.9,21.3,2.5c27.5,6.4,47.8,29.2,51.4,57.2
            c3.7,28.8-9.9,55.9-35.9,68.8c-7.6,3.8-10.2,8.1-10,16.3c0.7,29.3,0.6,58.7,1.3,88c0.1,4.6,2.3,9.7,4.8,13.7
            c4.7,7.4,5.2,14.3-1.2,20.3c-6.4,5.9-13.3,5.1-20.5,0.2c-4.2-2.8-9.3-5.5-14.2-6C133.3,472.6,51.8,397.9,34.1,295.2
            c-22.3-129.1,69.6-249.8,200-262.9c110.1-11,211.2,57.7,240.8,163.5C504.5,302,454,414,355.1,461.3c-4.3,2.1-8.7,4.3-13.3,5.2
            c-2.2,0.5-6.5-1.4-7.2-3.2c-0.7-1.9,1.1-5.9,3.1-7.4c3.1-2.5,7.3-3.6,11-5.4C441.8,406,490,303.1,464.6,203.4
            C439.4,104.7,347,37.4,244.6,43C133.4,49.1,44.3,141.9,42.9,253.3C41.4,366.1,127,461,238.5,470.3c14.9,1.2,19.1-2.6,19.1-17.6
            c-0.1-27.6-0.2-55.3-0.4-82.9C257.3,366.4,256.9,363,256.6,358.8z M198.8,345.6c0-0.1,0-0.2,0-0.3c16.4,0,32.7-0.1,49.1,0
            c6.8,0,9.7-2.7,9.4-9.9c-0.5-12.9-2.9-25-11.2-35.4c-11.1-13.8-25.9-18.9-43.1-19.7c-30.9-1.4-56.7-21.1-66.7-50.3
            c-3.2-9.1-6.6-10.4-15.2-5.4c-24.2,13.9-36.8,43.9-29.9,71.4c7,28.3,32.2,48.7,61.7,49.5C168.1,346,183.5,345.6,198.8,345.6z"/>
        <path d="M198.8,345.6c-15.3,0-30.7,0.3-46-0.1c-29.4-0.8-54.7-21.3-61.7-49.5c-6.8-27.5,5.8-57.5,29.9-71.4
            c8.6-4.9,12.1-3.7,15.2,5.4c10.1,29.1,35.8,48.8,66.7,50.3c17.2,0.8,32.1,5.9,43.1,19.7c8.3,10.4,10.8,22.5,11.2,35.4
            c0.3,7.1-2.6,9.9-9.4,9.9c-16.4-0.1-32.7,0-49.1,0C198.8,345.4,198.8,345.5,198.8,345.6z"/>
    </g>
</g>
</svg>

当我通过将内容保留在d属性中组合所有这些路径时,会得到图像,但它只有一种填充颜色。

如何将这些svg路径转换为单个计算路径,并以黑白填充保留原始图像。 我需要单个路径将其作为对象放入自定义js文件中,在该文件中我们正在注册图标并将它们与font-awsome-icon vue组件一起使用。 通过使用格式

的变量来注册图标
var faSnd = {
    prefix: 'fac',
    iconName: 'snd-coin',
    icon: [512, 512, [], "E023", "M514,514c-170.7,0-341.3,0-512,0C2,343.4,2,172.7,2,2c170.7,0,341.3,0,512,0C514,172.7,514,343.4,514,514z M257.6,6.4C119.5,6.2,7,117.9,6.5,255.8C6,394.1,118.3,507.2,256.5,507.5c137.8,0.3,250.6-111.9,251.1-249.6C508.1,119.4,395.9,6.6,257.6,6.4zM257.6,6.4c138.3,0.2,250.5,113.1,250,251.6c-0.5,137.7-113.3,249.9-251.1,249.6C118.3,507.2,6,394.1,6.5,255.8C7,117.9,119.5,6.2,257.6,6.4z M256.6,358.8c0.3,4.2,0.6,7.6,0.7,10.9c0.2,27.6,0.3,55.3,0.4,82.9c0,15.1-4.2,18.9-19.1,17.6C127,461,41.4,366.1,42.9,253.3C44.3,141.9,133.4,49.1,244.6,43c102.4-5.6,194.8,61.7,219.9,160.4C490,303.1,441.8,406,348.6,450.5c-3.7,1.8-7.8,2.9-11,5.4c-1.9,1.5-3.8,5.5-3.1,7.4c0.7,1.8,5,3.7,7.2,3.2c4.6-0.9,9-3.2,13.3-5.2C454,414,504.5,302,474.9,195.8C445.3,90,344.1,21.3,234.1,32.3C103.7,45.4,11.8,166.1,34.1,295.2C51.8,397.9,133.3,472.6,238.6,483c4.9,0.5,10,3.2,14.2,6c7.2,4.9,14.2,5.7,20.5-0.2c6.4-6,5.9-12.9,1.2-20.3c-2.5-4-4.7-9.1-4.8-13.7c-0.7-29.3-0.6-58.7-1.3-88c-0.2-8.2,2.4-12.5,10-16.3c25.9-13,39.5-40.1,35.9-68.8c-3.6-28-23.8-50.9-51.4-57.2c-6.9-1.6-14.2-1.8-21.3-2.5c-29.7-3.1-50.5-27.4-49.2-57.7c1.1-27.7,24.6-50.7,52.7-51.4c29.4-0.8,53.7,20.6,56.4,49.7c0.3,3.6,0.7,7.3,1.1,12c13.2,0,25.4-0.2,37.7,0c41.2,0.7,77.3,31.4,83.3,71c6.5,42.3-17,81.8-56.6,95.6c-6.2,2.2-11.4,3.7-17.4-2.5c-6.8-7-18.6-4.6-24.4,3.1c-5.7,7.5-4.6,17.8,2.5,24c7.1,6.1,17.1,5.2,24.3-0.9c4.9-4.1,10.5-8.1,16.5-10c40.8-13.1,69.4-51.2,69.7-93.9c0.3-42.2-27.1-81.6-67.6-94c-13.7-4.2-28.8-4.7-43.4-5.2c-9-0.3-12.6-2.4-14.9-11.7c-9.4-37.2-47.8-58.3-84.7-47.5c-36,10.6-56.6,49.1-45.4,85.3c8.9,29,32.5,45.8,67.7,48c23.5,1.5,42.5,16.3,49.3,38.3c6.8,21.9-0.6,45.7-18.8,59.6c-3,2.3-6.6,4-11.3,6.8c-0.3-5.7-0.6-9.4-0.8-13c-1.7-27.1-21.1-50.3-47.4-56.2c-7-1.5-14.3-1.4-21.3-2.6c-21.4-3.4-38.3-13.7-49.2-32.9c-3.2-5.7-3.7-10.4,1.4-16.5c3.4-4,4.5-12.6,2.5-17.5c-1.7-4.3-9.3-9-14-8.8c-5.3,0.2-10.6,5.4-15.3,9.2c-3.7,3-6,8.1-10,10.5c-27.5,16.8-43.1,48.1-38.5,78c6.4,40.8,37.8,68,79.4,68.2C189.1,359,222.2,358.8,256.6,358.8z M256.6,358.8c-34.4,0-67.5,0.1-100.6,0c-41.5-0.2-73-27.4-79.4-68.2c-4.7-29.9,11-61.3,38.5-78c4-2.4,6.2-7.5,10-10.5c4.7-3.8,10.1-9,15.3-9.2c4.8-0.2,12.3,4.5,14,8.8c2,4.9,0.8,13.5-2.5,17.5c-5.1,6.1-4.7,10.7-1.4,16.5c10.8,19.2,27.8,29.5,49.2,32.9c7.1,1.1,14.4,1,21.3,2.6c26.3,5.9,45.7,29.1,47.4,56.2c0.2,3.7,0.4,7.3,0.8,13c4.7-2.8,8.2-4.4,11.3-6.8c18.2-13.9,25.6-37.7,18.8-59.6c-6.8-22-25.8-36.8-49.3-38.3c-35.2-2.3-58.8-19.1-67.7-48c-11.1-36.2,9.4-74.7,45.4-85.3c36.9-10.8,75.3,10.3,84.7,47.5c2.3,9.2,6,11.4,14.9,11.7c14.5,0.5,29.6,1,43.4,5.2c40.5,12.5,67.9,51.8,67.6,94c-0.3,42.7-28.9,80.8-69.7,93.9c-6,1.9-11.7,5.9-16.5,10c-7.2,6.1-17.2,7-24.3,0.9c-7.1-6.2-8.2-16.5-2.5-24c5.8-7.6,17.6-10.1,24.4-3.1c6,6.2,11.2,4.6,17.4,2.5c39.6-13.8,63.1-53.3,56.6-95.6c-6-39.6-42.1-70.4-83.3-71c-12.2-0.2-24.5,0-37.7,0c-0.4-4.7-0.8-8.4-1.1-12c-2.7-29.1-27-50.5-56.4-49.7c-28,0.8-51.5,23.7-52.7,51.4c-1.2,30.3,19.5,54.6,49.2,57.7c7.1,0.7,14.4,0.9,21.3,2.5c27.5,6.4,47.8,29.2,51.4,57.2c3.7,28.8-9.9,55.9-35.9,68.8c-7.6,3.8-10.2,8.1-10,16.3c0.7,29.3,0.6,58.7,1.3,88c0.1,4.6,2.3,9.7,4.8,13.7c4.7,7.4,5.2,14.3-1.2,20.3c-6.4,5.9-13.3,5.1-20.5,0.2c-4.2-2.8-9.3-5.5-14.2-6C133.3,472.6,51.8,397.9,34.1,295.2c-22.3-129.1,69.6-249.8,200-262.9c110.1-11,211.2,57.7,240.8,163.5C504.5,302,454,414,355.1,461.3c-4.3,2.1-8.7,4.3-13.3,5.2c-2.2,0.5-6.5-1.4-7.2-3.2c-0.7-1.9,1.1-5.9,3.1-7.4c3.1-2.5,7.3-3.6,11-5.4C441.8,406,490,303.1,464.6,203.4C439.4,104.7,347,37.4,244.6,43C133.4,49.1,44.3,141.9,42.9,253.3C41.4,366.1,127,461,238.5,470.3c14.9,1.2,19.1-2.6,19.1-17.6c-0.1-27.6-0.2-55.3-0.4-82.9C257.3,366.4,256.9,363,256.6,358.8z M198.8,345.6c0-0.1,0-0.2,0-0.3c16.4,0,32.7-0.1,49.1,0c6.8,0,9.7-2.7,9.4-9.9c-0.5-12.9-2.9-25-11.2-35.4c-11.1-13.8-25.9-18.9-43.1-19.7c-30.9-1.4-56.7-21.1-66.7-50.3c-3.2-9.1-6.6-10.4-15.2-5.4c-24.2,13.9-36.8,43.9-29.9,71.4c7,28.3,32.2,48.7,61.7,49.5C168.1,346,183.5,345.6,198.8,345.6z M198.8,345.6c-15.3,0-30.7,0.3-46-0.1c-29.4-0.8-54.7-21.3-61.7-49.5c-6.8-27.5,5.8-57.5,29.9-71.4c8.6-4.9,12.1-3.7,15.2,5.4c10.1,29.1,35.8,48.8,66.7,50.3c17.2,0.8,32.1,5.9,43.1,19.7c8.3,10.4,10.8,22.5,11.2,35.4c0.3,7.1-2.6,9.9-9.4,9.9c-16.4-0.1-32.7,0-49.1,0C198.8,345.4,198.8,345.5,198.8,345.6z"]
  };

之前我看到的一些svg工作正常,其中包含Capitals的属性值。

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="512" height="512" viewBox="0, 0, 512, 512">
  <g id="Layer_1">
    <path d="M148.4,118.8 L148.4,118.8 L148.4,118.8 L148.4,118.8 L148.4,118.8 C148.856,122.528 148.656,120.661 149,124.4 C149.1,146.1 149.3,167.7 149.2,189.4 C149.2,191 147.3,193.2 145.7,194 C141.3,196.2 140.7,198.9 141.8,203.6 C149.5,236.2 162.4,266.8 176.7,296.9 C189.4,323.5 202.9,349.7 216,376 C216.9,377.8 217.7,379.5 218.7,381.7 C207.7,385.6 197,389.2 186.4,393 C180.1,395.2 173.8,397.4 167.7,400 C155.1,405.4 144.6,413 139.8,427.7 C135.1,418.6 131,410.5 126.9,402.4 C114.3,377.4 101.5,352.6 92.7,326 C83.5,298.3 84.6,271.3 95.8,244.2 C109.6,210.7 122.1,176.6 135.4,142.9 C138.1,136.1 141.8,129.7 145.1,123.2 C146.06,121.634 147.272,120.245 148.4,118.8 L148.4,118.8 z M376.3,90.7 L376.3,90.7 C371.6,102.9 362.3,110.2 350.9,114.9 C340.5,119.3 329.7,122.9 319.1,126.8 C312,129.3 304.8,131.7 297.2,134.4 C299.1,138.3 300.7,141.6 302.4,144.8 C321.5,182.1 341.1,219.2 356.5,258.3 C363.8,276.8 370.6,295.6 374.3,315.3 C374.9,318.4 374.5,320.6 371.5,321.8 C367.6,323.4 366.9,326.3 366.9,330.2 C367.1,350.9 367,371.5 367,392.2 C367,394 367.3,395.7 367.4,397.5 C368.1,397.8 368.8,398 369.5,398.1 C373.5,390.1 378.1,382.4 381.4,374.2 C394.1,342.2 405.8,309.8 418.9,278 C430.7,249.4 431.4,220.9 422.1,191.7 C410.9,156.6 393.8,124.2 377.7,91.4 C377.5,91.1 376.9,91 376.3,90.7 z" fill="#000000"/>
  </g>
</svg>

3 个答案:

答案 0 :(得分:3)

这是只有一条路径的SVG。 这就是我要做的:我消除了白色路径,加入了两条黑色路径。看到我的代码中的差距了吗?是第一条路径结束而最后一条路径开始的地方。

现在唯一的问题是,以前是白色的路径现在是透明区域。如果您将SVG用作背景,则会在空白处看到它。

svg{background:gold;width:90vh}
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">

        <path d="M257.6,6.4c138.3,0.2,250.5,113.1,250,251.6c-0.5,137.7-113.3,249.9-251.1,249.6C118.3,507.2,6,394.1,6.5,255.8
            C7,117.9,119.5,6.2,257.6,6.4z M256.6,358.8c0.3,4.2,0.6,7.6,0.7,10.9c0.2,27.6,0.3,55.3,0.4,82.9c0,15.1-4.2,18.9-19.1,17.6
            C127,461,41.4,366.1,42.9,253.3C44.3,141.9,133.4,49.1,244.6,43c102.4-5.6,194.8,61.7,219.9,160.4
            C490,303.1,441.8,406,348.6,450.5c-3.7,1.8-7.8,2.9-11,5.4c-1.9,1.5-3.8,5.5-3.1,7.4c0.7,1.8,5,3.7,7.2,3.2
            c4.6-0.9,9-3.2,13.3-5.2C454,414,504.5,302,474.9,195.8C445.3,90,344.1,21.3,234.1,32.3C103.7,45.4,11.8,166.1,34.1,295.2
            C51.8,397.9,133.3,472.6,238.6,483c4.9,0.5,10,3.2,14.2,6c7.2,4.9,14.2,5.7,20.5-0.2c6.4-6,5.9-12.9,1.2-20.3
            c-2.5-4-4.7-9.1-4.8-13.7c-0.7-29.3-0.6-58.7-1.3-88c-0.2-8.2,2.4-12.5,10-16.3c25.9-13,39.5-40.1,35.9-68.8
            c-3.6-28-23.8-50.9-51.4-57.2c-6.9-1.6-14.2-1.8-21.3-2.5c-29.7-3.1-50.5-27.4-49.2-57.7c1.1-27.7,24.6-50.7,52.7-51.4
            c29.4-0.8,53.7,20.6,56.4,49.7c0.3,3.6,0.7,7.3,1.1,12c13.2,0,25.4-0.2,37.7,0c41.2,0.7,77.3,31.4,83.3,71
            c6.5,42.3-17,81.8-56.6,95.6c-6.2,2.2-11.4,3.7-17.4-2.5c-6.8-7-18.6-4.6-24.4,3.1c-5.7,7.5-4.6,17.8,2.5,24
            c7.1,6.1,17.1,5.2,24.3-0.9c4.9-4.1,10.5-8.1,16.5-10c40.8-13.1,69.4-51.2,69.7-93.9c0.3-42.2-27.1-81.6-67.6-94
            c-13.7-4.2-28.8-4.7-43.4-5.2c-9-0.3-12.6-2.4-14.9-11.7c-9.4-37.2-47.8-58.3-84.7-47.5c-36,10.6-56.6,49.1-45.4,85.3
            c8.9,29,32.5,45.8,67.7,48c23.5,1.5,42.5,16.3,49.3,38.3c6.8,21.9-0.6,45.7-18.8,59.6c-3,2.3-6.6,4-11.3,6.8
            c-0.3-5.7-0.6-9.4-0.8-13c-1.7-27.1-21.1-50.3-47.4-56.2c-7-1.5-14.3-1.4-21.3-2.6c-21.4-3.4-38.3-13.7-49.2-32.9
            c-3.2-5.7-3.7-10.4,1.4-16.5c3.4-4,4.5-12.6,2.5-17.5c-1.7-4.3-9.3-9-14-8.8c-5.3,0.2-10.6,5.4-15.3,9.2c-3.7,3-6,8.1-10,10.5
            c-27.5,16.8-43.1,48.1-38.5,78c6.4,40.8,37.8,68,79.4,68.2C189.1,359,222.2,358.8,256.6,358.8z
                 
                 
                 
                 M198.8,345.6c-15.3,0-30.7,0.3-46-0.1c-29.4-0.8-54.7-21.3-61.7-49.5c-6.8-27.5,5.8-57.5,29.9-71.4
            c8.6-4.9,12.1-3.7,15.2,5.4c10.1,29.1,35.8,48.8,66.7,50.3c17.2,0.8,32.1,5.9,43.1,19.7c8.3,10.4,10.8,22.5,11.2,35.4
            c0.3,7.1-2.6,9.9-9.4,9.9c-16.4-0.1-32.7,0-49.1,0C198.8,345.4,198.8,345.5,198.8,345.6z"/>
  

</svg>

答案 1 :(得分:0)

您可以将Inkscape(开源svg编辑器)中的svg路径与[路径] [组合]组合在一起。这可能会强制所有路径使用相同的颜色。

如果已将图像(例如,位图)导入到Inkscape中,请首先使用[Path] [Trace位图]创建路径,然后可以合并。

答案 2 :(得分:0)

如果您不介意使用Python语言,请参阅以下内容:

from svgpathtools import svg2paths, wsvg  # you need ``pip install svgpathtools``
from svgpathtools.path import Path as CombinePath
from pathlib import Path


TEST_SVG = Path('test.svg')


def main():
    path_list, data_list = svg2paths(str(Path(TEST_SVG)))

    if not 'analysis path':
        for idx, cur_path in enumerate(path_list):
            wsvg(cur_path, filename=f'result_{idx}.svg',
                 attributes=[dict(fill="#000000", stroke="none", stroke_width=1)])

    path_list = [path_list[idx] for idx in (1, 3)]  # After analyzing the paths, we find that the paths index 1 and 3 seem to be redundant.
    single_path = CombinePath()  # combine: 0, 2 together.
    for combine_path in path_list:
        for curve in combine_path:
            single_path.append(curve)

    wsvg(single_path, filename=f'result.svg',
         attributes=[dict(fill="#000000", stroke="none", stroke_width=1)],
         openinbrowser=True  # default is False,
         )


if __name__ == '__main__':
    main()

result.svg

<?xml version="1.0" ?>
<svg baseProfile="full" height="600px" version="1.1" viewBox="-43.86259639916139 -43.9709554283007 601.8251942724853 601.9422429052738" width="600px" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<path d="M 257.6,6.4 C 395.90000000000003,6.6000000000000005 508.1,119.5 507.6,258.0 C 507.1,395.7 394.3,507.9 256.5,507.6 C 118.3,507.2 6.0,394.1 6.5,255.8 C 7.0,117.9 119.5,6.2 257.6,6.4 M 256.6,358.8 C 256.90000000000003,363.0 257.20000000000005,366.40000000000003 257.3,369.7 C 257.5,397.3 257.6,425.0 257.7,452.6 C 257.7,467.70000000000005 253.5,471.5 238.6,470.20000000000005 C 127.0,461.0 41.4,366.1 42.9,253.3 C 44.3,141.9 133.4,49.1 244.6,43.0 C 347.0,37.4 439.4,104.7 464.5,203.4 C 490.0,303.1 441.8,406.0 348.6,450.5 C 344.90000000000003,452.3 340.8,453.4 337.6,455.9 C 335.70000000000005,457.4 333.8,461.4 334.5,463.29999999999995 C 335.2,465.09999999999997 339.5,466.99999999999994 341.7,466.49999999999994 C 346.3,465.59999999999997 350.7,463.29999999999995 355.0,461.29999999999995 C 454.0,414.0 504.5,302.0 474.9,195.8 C 445.3,90.0 344.1,21.3 234.1,32.3 C 103.7,45.4 11.8,166.1 34.1,295.2 C 51.8,397.9 133.3,472.6 238.6,483.0 C 243.5,483.5 248.6,486.2 252.79999999999998,489.0 C 260.0,493.9 267.0,494.7 273.29999999999995,488.8 C 279.69999999999993,482.8 279.19999999999993,475.90000000000003 274.49999999999994,468.5 C 271.99999999999994,464.5 269.79999999999995,459.4 269.69999999999993,454.8 C 268.99999999999994,425.5 269.0999999999999,396.1 268.3999999999999,366.8 C 268.19999999999993,358.6 270.7999999999999,354.3 278.3999999999999,350.5 C 304.2999999999999,337.5 317.8999999999999,310.4 314.2999999999999,281.7 C 310.6999999999999,253.7 290.4999999999999,230.79999999999998 262.8999999999999,224.5 C 255.99999999999991,222.9 248.69999999999993,222.7 241.5999999999999,222.0 C 211.89999999999992,218.9 191.0999999999999,194.6 192.39999999999992,164.3 C 193.49999999999991,136.60000000000002 216.99999999999991,113.60000000000001 245.0999999999999,112.9 C 274.4999999999999,112.10000000000001 298.7999999999999,133.5 301.4999999999999,162.60000000000002 C 301.7999999999999,166.20000000000002 302.1999999999999,169.90000000000003 302.5999999999999,174.60000000000002 C 315.7999999999999,174.60000000000002 327.9999999999999,174.40000000000003 340.2999999999999,174.60000000000002 C 381.4999999999999,175.3 417.5999999999999,206.00000000000003 423.5999999999999,245.60000000000002 C 430.0999999999999,287.90000000000003 406.5999999999999,327.40000000000003 366.9999999999999,341.20000000000005 C 360.7999999999999,343.40000000000003 355.5999999999999,344.90000000000003 349.5999999999999,338.70000000000005 C 342.7999999999999,331.70000000000005 330.9999999999999,334.1 325.19999999999993,341.80000000000007 C 319.49999999999994,349.30000000000007 320.5999999999999,359.6000000000001 327.69999999999993,365.80000000000007 C 334.79999999999995,371.9000000000001 344.79999999999995,371.00000000000006 351.99999999999994,364.9000000000001 C 356.8999999999999,360.80000000000007 362.49999999999994,356.80000000000007 368.49999999999994,354.9000000000001 C 409.29999999999995,341.80000000000007 437.9,303.7000000000001 438.19999999999993,261.0000000000001 C 438.49999999999994,218.80000000000013 411.0999999999999,179.40000000000012 370.5999999999999,167.0000000000001 C 356.8999999999999,162.80000000000013 341.7999999999999,162.30000000000013 327.19999999999993,161.80000000000013 C 318.19999999999993,161.5000000000001 314.5999999999999,159.40000000000012 312.29999999999995,150.10000000000014 C 302.9,112.90000000000013 264.49999999999994,91.80000000000014 227.59999999999997,102.60000000000014 C 191.59999999999997,113.20000000000013 170.99999999999997,151.70000000000013 182.19999999999996,187.90000000000015 C 191.09999999999997,216.90000000000015 214.69999999999996,233.70000000000016 249.89999999999998,235.90000000000015 C 273.4,237.40000000000015 292.4,252.20000000000016 299.2,274.20000000000016 C 306.0,296.10000000000014 298.59999999999997,319.90000000000015 280.4,333.8000000000002 C 277.4,336.1000000000002 273.79999999999995,337.8000000000002 269.09999999999997,340.6000000000002 C 268.79999999999995,334.9000000000002 268.49999999999994,331.2000000000002 268.29999999999995,327.6000000000002 C 266.59999999999997,300.50000000000017 247.19999999999996,277.3000000000002 220.89999999999995,271.4000000000002 C 213.89999999999995,269.9000000000002 206.59999999999994,270.0000000000002 199.59999999999994,268.8000000000002 C 178.19999999999993,265.4000000000002 161.29999999999995,255.1000000000002 150.39999999999992,235.90000000000018 C 147.19999999999993,230.2000000000002 146.69999999999993,225.50000000000017 151.79999999999993,219.40000000000018 C 155.19999999999993,215.40000000000018 156.29999999999993,206.80000000000018 154.29999999999993,201.90000000000018 C 152.59999999999994,197.60000000000016 144.99999999999991,192.90000000000018 140.29999999999993,193.10000000000016 C 134.99999999999991,193.30000000000015 129.69999999999993,198.50000000000017 124.99999999999993,202.30000000000015 C 121.29999999999993,205.30000000000015 118.99999999999993,210.40000000000015 114.99999999999993,212.80000000000015 C 87.49999999999993,229.60000000000016 71.89999999999992,260.90000000000015 76.49999999999993,290.8000000000002 C 82.89999999999993,331.6000000000002 114.29999999999993,358.8000000000002 155.89999999999992,359.00000000000017 C 189.1,359.0 222.2,358.8 256.6,358.8 M 198.8,345.6 C 183.5,345.6 168.10000000000002,345.90000000000003 152.8,345.5 C 123.4,344.7 98.10000000000001,324.2 91.10000000000001,296.0 C 84.30000000000001,268.5 96.9,238.5 121.0,224.6 C 129.6,219.7 133.1,220.9 136.2,230.0 C 146.29999999999998,259.1 172.0,278.8 202.89999999999998,280.3 C 220.09999999999997,281.1 234.99999999999997,286.2 245.99999999999997,300.0 C 254.29999999999998,310.4 256.79999999999995,322.5 257.2,335.4 C 257.5,342.5 254.6,345.29999999999995 247.79999999999998,345.29999999999995 C 231.39999999999998,345.19999999999993 215.09999999999997,345.29999999999995 198.7,345.29999999999995 C 198.8,345.4 198.8,345.5 198.8,345.6" fill="#000000" stroke="none" stroke-width="1"/>
</svg>