tags:

views:

35

answers:

2
+1  Q: 

Change SVG Colour

I've never used SVG so I'm wondering if this is even possible, but can you change the color of a shape inside? Currently I'm using a PNG that I have to manually create in photoshop for each different menu and I'm wondering if I can make the whole process dynamic.

Thanks!

A: 

Can't you just use style="background-color: #------;" (or maybe color:)?

EDIT: My mistake, the one you need is fill, so style="fill:#------;", and it should work with any shape.

Brendan Long
The shape isn't a simple rectangle or circle or anything like that, see here: http://imgur.com/D9aFo.png - I'm trying to change the blue to red or whatever.
Rick
A: 

You could use a hue-rotate filter, or you could fix the colors as suggested above. Probably more compatible to change the colors to what you need, but in any case, here's an example of the filter variant:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"&gt;
  <filter id="h200" x="0" y="0" width="1" height="1">
    <feColorMatrix type="hueRotate" values="200"/>
  </filter>
  <image xlink:href="http://imgur.com/D9aFo.png" width="207" height="46" filter="url(#h200)"/>
</svg>

You can see it live here if you use a browser that supports svg filters, e.g Opera or Firefox.

Erik Dahlström