How to color SVG without path Fill?

Asked

Viewed 478 times

3

Well, I tracked an image and I need to color it. The point is that it is not a geometric shape (T-shirt collar) and I need to give the user the option to color it. However, when exporting svg, the Fill attribute does not appear, which you would use to do this coloring.. How to color this svg? Follows the svg code that is rendered:

<svg xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  preserveAspectRatio="xMidYMid" width="54" height="37" viewBox="0 0 54 37">
    <image xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAADYAAAAlCAMAAAA+2eraAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAB5lBMVEUAAACzzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB4AAAB1WLE/AAAAo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</svg>
  • How did you generate this svg? There’s something strange there, it looks like a Base64 inside the svg... As far as I know Base64 has no Fill and I did not allow to change colors like this...

  • @hugocsl is right. You are even using an svg tag, but the content is not referent. Therefore, it is not possible to color.

1 answer

2

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" 
preserveAspectRatio="xMidYMid" width="130" height="60" viewBox="0 0 130 60">
<desc>
Imagem de gola de camiseta, rasterizada, com opção de colorir.
(feColorMatrix hueRotate)
</desc>
<defs>
<filter id="filter">
<feColorMatrix id="matrix" type="hueRotate" values="0"/>
</filter>
</defs>
<image x="25%" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAADYAAAAlCAMAAAA+2eraAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAB5lBMVEUAAACzzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zzB6zz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C4GhpnQAF0wi3i7wAEzG1w3zEkiSRcQzAVWa5OJDQ0kEDNvPi4pAHQb17SBoGL0AAAAAElFTkSuQmCC" 
width="54" height="37" filter="url(#filter)"/>
<foreignObject y="65%" width="130" height="21">
<select xmlns="http://www.w3.org/1999/xhtml" 
onclick="matrix.setAttribute('values', event.target.value)">
<option value="0">yellowgreen</option>
<option value="45">mediumseagreen</option>
<option value="90">lightseagreen</option>
<option value="135">skyblue</option>
<option value="180">lightsteelblue</option>
<option value="225">violet</option>
<option value="270">lightpink</option>
</select>
</foreignObject>
</svg>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.