导入后SVG变成黑色

时间:2018-07-29 11:42:37

标签: image svg import graphics adobe-illustrator

我附带的SVG在浏览器中看起来不错,但是如果我要将其导入到figma中,它只会显示一个黑框。

这不是导致问题的rgba语法。 (like in this answer
但是我不知道哪些元素也不被允许。

<?xml version="1.0" encoding="UTF-8"?>
<svg class="cracker-loading-logging" width="500px" viewBox="0 0 782 415" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <mask id="logo-logging">
      <!-- Outline -->
      <path d="M204.5,396.510452 C191.445231,396.510452 190.685044,406.440239 178.390463,404.821626 C166.095882,403.203014 167.931614,393.414826 155.321676,390.036003 C142.711738,386.65718 139.407435,396.051866 127.950709,391.306335 C116.493984,386.560804 120.800535,377.581263 109.494774,371.053879 C98.1890124,364.526494 92.5657773,372.745848 82.727664,365.196798 C72.8895508,357.647748 79.3734361,350.088795 70.1423206,340.857679 C60.9112051,331.626564 53.3522519,338.110449 45.8032021,328.272336 C38.2541522,318.434223 46.4735056,312.810988 39.9461212,301.505226 C33.4187369,290.199465 24.4391957,294.506016 19.6936646,283.049291 C14.9481335,271.592565 24.3428195,268.288262 20.9639968,255.678324 C17.585174,243.068386 7.79698582,244.904118 6.17837353,232.609537 C4.55976123,220.314956 14.4895476,219.554769 14.4895476,206.5 C14.4895476,193.445231 4.55976123,192.685044 6.17837353,180.390463 C7.79698582,168.095882 17.585174,169.931614 20.9639968,157.321676 C24.3428195,144.711738 14.9481335,141.407435 19.6936646,129.950709 C24.4391957,118.493984 33.4187369,122.800535 39.9461212,111.494774 C46.4735056,100.189012 38.2541522,94.5657773 45.8032021,84.727664 C53.3522519,74.8895508 60.9112051,81.3734361 70.1423206,72.1423206 C79.3734361,62.9112051 72.8895508,55.3522519 82.727664,47.8032021 C92.5657773,40.2541522 98.1890124,48.4735056 109.494774,41.9461212 C120.800535,35.4187369 116.493984,26.4391957 127.950709,21.6936646 C139.407435,16.9481335 142.711738,26.3428195 155.321676,22.9639968 C167.931614,19.585174 166.095882,9.79698582 178.390463,8.17837353 C190.685044,6.55976123 191.445231,16.4895476 204.5,16.4895476 C217.554769,16.4895476 218.314956,6.55976123 230.609537,8.17837353 C242.904118,9.79698582 241.068386,19.585174 253.678324,22.9639968 C266.288262,26.3428195 269.592565,16.9481335 281.049291,21.6936646 C292.506016,26.4391957 288.199465,35.4187369 299.505226,41.9461212 C310.810988,48.4735056 316.434223,40.2541522 326.272336,47.8032021 C336.110449,55.3522519 329.626564,62.9112051 338.857679,72.1423206 C348.088795,81.3734361 355.647748,74.8895508 363.196798,84.727664 C370.745848,94.5657773 362.526494,100.189012 369.053879,111.494774 C375.581263,122.800535 384.560804,118.493984 389.306335,129.950709 C394.051866,141.407435 384.65718,144.711738 388.036003,157.321676 C391.414826,169.931614 401.203014,168.095882 402.821626,180.390463 C404.440239,192.685044 394.510452,193.445231 394.510452,206.5 C394.510452,219.554769 404.440239,220.314956 402.821626,232.609537 C401.203014,244.904118 391.414826,243.068386 388.036003,255.678324 C384.65718,268.288262 394.051866,271.592565 389.306335,283.049291 C384.560804,294.506016 375.581263,290.199465 369.053879,301.505226 C362.526494,312.810988 370.745848,318.434223 363.196798,328.272336 C355.647748,338.110449 348.088795,331.626564 338.857679,340.857679 C329.626564,350.088795 336.110449,357.647748 326.272336,365.196798 C316.434223,372.745848 310.810988,364.526494 299.505226,371.053879 C288.199465,377.581263 292.506016,386.560804 281.049291,391.306335 C269.592565,396.051866 266.288262,386.65718 253.678324,390.036003 C241.068386,393.414826 242.904118,403.203014 230.609537,404.821626 C218.314956,406.440239 217.554769,396.510452 204.5,396.510452 Z" id="Base" fill="#FFFFFF" 
      style=".cracker-loading-logging {fill: #FFFFFF;}"></path>
      <!-- Mouth cut out -->
      <polygon class="cut" fill="#000000" points="204 206.5 411 405 411 8"></polygon>
      <!-- Dots in surface -->
      <circle fill="#000000" cx="147" cy="107" r="16"></circle>
      <circle fill="#000000" cx="261" cy="107" r="16"></circle>
      <circle fill="#000000" cx="261" cy="305" r="16"></circle>
      <circle fill="#000000" cx="147" cy="305" r="16"></circle>
      <circle fill="#000000" cx="80" cy="206" r="16"></circle>
    </mask>
  </defs>
  <rect mask="url(#logo-logging)" width="100%" height="100%"/>
</svg>

1 个答案:

答案 0 :(得分:0)

'style attribute is definitely wrong. You can't put CSS selectors in a style`元素。您仍然可以删除它,因为它似乎没有做任何有用的事情。也许Figma不喜欢它。我想可以删除它。

如果它仍然只显示一个黑色矩形,则表明Figma不支持mask元素,或者在解析或取消引用它时遇到麻烦。您的文档中是否还有其他的SVG可能具有相同的id="logo-logging"?如果存在,则此SVG可能使用了错误的掩码定义。

它不必是面具。实际上,您的图标是从矩形切出的饼形,这有点奇怪。如果您将其更改为饼形,我想它在Figma中会更好。

这是不使用遮罩的版本。应该可以导入。

<?xml version="1.0" encoding="UTF-8"?>
<svg class="cracker-loading-logging" width="500px" version="1.1" viewBox="0 0 782 415" xmlns="http://www.w3.org/2000/svg"><!-- Outline -->
 <path transform="matrix(1.564 0 0 1.564 0 -117)" d="m218.5 122.4c-0.5938-0.4203-1.193-0.8705-1.809-1.486-5.902-5.902-1.757-10.74-8.047-15.56s-9.885 0.4274-17.11-3.746c-7.229-4.174-4.476-9.915-11.8-12.95s-9.437 2.973-17.5 0.8125c-8.063-2.16-6.889-8.418-14.75-9.453-7.861-1.035-8.348 5.314-16.7 5.314s-8.832-6.349-16.69-5.314c-7.861 1.035-6.687 7.293-14.75 9.453-8.063 2.16-10.17-3.847-17.5-0.8125s-4.572 8.776-11.8 12.95c-7.229 4.174-10.82-1.081-17.12 3.746-6.29 4.827-2.145 9.66-8.047 15.56s-10.74 1.757-15.56 8.047c-4.827 6.29 0.4294 9.885-3.744 17.11-4.174 7.229-9.915 4.476-12.95 11.8-3.034 7.325 2.973 9.437 0.8125 17.5-2.16 8.063-8.418 6.889-9.453 14.75-1.035 7.861 5.312 8.348 5.312 16.7s-6.347 8.832-5.312 16.69c1.035 7.861 7.293 6.687 9.453 14.75 2.16 8.063-3.847 10.17-0.8125 17.5 3.034 7.325 8.776 4.572 12.95 11.8 4.174 7.229-1.083 10.82 3.744 17.12 4.827 6.29 9.66 2.145 15.56 8.047s1.757 10.74 8.047 15.56c6.29 4.827 9.886-0.4294 17.12 3.744 7.229 4.174 4.476 9.915 11.8 12.95 7.325 3.034 9.437-2.973 17.5-0.8125 8.063 2.16 6.889 8.418 14.75 9.453 7.861 1.035 8.346-5.312 16.69-5.312s8.834 6.347 16.7 5.312c7.861-1.035 6.687-7.293 14.75-9.453 8.063-2.16 10.17 3.847 17.5 0.8125 7.325-3.034 4.572-8.776 11.8-12.95s10.82 1.083 17.11-3.744 2.145-9.66 8.047-15.56c0.6155-0.6155 1.213-1.068 1.807-1.488l-88.03-84.42 88.03-84.42z" stroke-width=".6394"/>
 <g fill="#fff"><!-- Mouth cut out --><!-- Dots in surface -->
  <circle cx="147" cy="107" r="16"/>
  <circle cx="261" cy="107" r="16"/>
  <circle cx="261" cy="305" r="16"/>
  <circle cx="147" cy="305" r="16"/>
  <circle cx="80" cy="206" r="16"/>
 </g>
</svg>