I can easily add a fill on the element (<path fill="#FF0000">), but my problem is, that it is not always a path element, it can also be <rect>, <ellipse> and so on.
but what if i want to change the color of all the elements in the svg file? no matter what type it is?
My solutions:
-
Find all elements that support the fill attribute, and then loop through them.
-
Just to put a fill tag on everything, not matter what tag, but not all tags support it, and wont that cause problems?
I don’t like any of these solutions… The first is not dynamic, and the other is not dynamic is dirty¨
Is there something smarter i can do here? can i define a global color or something? Or does svg.codeplex have some functionality that i can use (which i can’t find)?
Use css to set the colours. If you remove the fill styles from the elements themselves then you can just add
or alternatively in an external stylesheet and everything that accepts a fill colour will be red. You can manipulate the styles using document.styleSheets[1]