Changing the color of an SVG icon

I have go.Picture with an SVG file as a source.
I need to change its color depending on some state change.
Any ideas ?

You could have a second SVG file – just set or bind Picture.source to refer to the other file. This would allow for changes other than just color.

You could change the Picture’s GraphObject.background.

You could position one or more Shapes in front of the Picture; then you could change the fill and or stroke of the Shape(s).

There are probably other possibilities.


Is it possible to have a “transparent” fill color, namely, if i put a shape in front of the picture, could it be transparent, so that the picture will still be shown, but with some color ?

You can literally use the CSS color “transparent” if you do not want the user to see anything for that GraphObject.background or Shape.fill or Shape.stroke or TextBlock.stroke.

Or if you are actually talking about translucency, you can use a translucent CSS color, such as #00ff0080 or rgba(34, 12, 64, 0.3) or hsla(30, 100%, 50%, 0.3).

Or if you want to control the translucency of any GraphObject, including any Panel and all its elements, you can set GraphObject.opacity to a value other than the default 1.0.

Thanks a lot !!!