Is it possible to set a color property to be "currentColor" and to have inkscape render that color (presumably as black in a light theme)? I understand that I can edit the XML directly, but when I've done this Inkscape is no longer able to render the object.
No, I'm not. Admittedly, I don't know much about how currentColor works. But my two main use cases (in Emacs and in browsers) seem to set the color to the foreground color.
If you set the fill or stroke attribute for the element to currentColor, it looks to the parent element for the color style attribute and uses that colour - wow.
It requires the use of the Object>Selectors and CSS panel to do this.
In the example I have posted there is a group of two objects and a single object outside the group in the main document.
The main svg element has style="color:#FFCC00" set. So the single object (rectangle) fill set to currentColor inherits this, as the main document is its parent.
The group has a class #57 with
#g57 { color:#FF5555; }
and the fill of the star has colour set to currentColour, so it inherits the pinky color from it's parent.
In case it helps, I covered the use of currentColor to apply a theme colour to icons within a web page in part 81 of my tutorial series in Full CIrcle Magazine (free download): http://www.peppertop.com/blog/?p=1563
Thanks for that example @inklinea! Using the Object>Selectors and CSS panel ended up being the solution as you suggested. I didn't set any main svg element color, because I'd like the SVG image to inherit the color from the webpage or other environment rather than from another object in the SVG file. I set stroke and fill to currentColor for all of my symbols in the symbol file. Critically, doing this also for stop-color appears to cause inkscape to crash, so I didn't do that (I don't actually know what that's for, but fill and stroke sets the full color in my case). The symbols then retain the currentColor properties when used in other SVG files. Additionally, they still appear as black in inkscape. I also needed new bezier curves to use a currentColor stroke. This was possible to do by default by creating a bezier curve, editing the CSS with the Selectors and CSS panel, and then using "Take from Selection" to set the new default.
Hello,
Is it possible to set a color property to be "currentColor" and to have inkscape render that color (presumably as black in a light theme)? I understand that I can edit the XML directly, but when I've done this Inkscape is no longer able to render the object.
Thanks.
Matt
currentColour - Javascript camelcase - are you trying to malipulate the colours later using javascript ?
No, I'm not. Admittedly, I don't know much about how currentColor works. But my two main use cases (in Emacs and in browsers) seem to set the color to the foreground color.
Well I didn't know this feature existed in SVG :)
So I have learnt something today.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color
If you set the fill or stroke attribute for the element to currentColor, it looks to the parent element for the color style attribute and uses that colour - wow.
It requires the use of the Object>Selectors and CSS panel to do this.
In the example I have posted there is a group of two objects and a single object outside the group in the main document.
The main svg element has style="color:#FFCC00" set. So the single object (rectangle) fill set to currentColor inherits this, as the main document is its parent.
The group has a class #57 with
#g57 {
color:#FF5555;
}
and the fill of the star has colour set to currentColour, so it inherits the pinky color from it's parent.
In case it helps, I covered the use of currentColor to apply a theme colour to icons within a web page in part 81 of my tutorial series in Full CIrcle Magazine (free download): http://www.peppertop.com/blog/?p=1563
Thanks for that example @inklinea! Using the Object>Selectors and CSS panel ended up being the solution as you suggested. I didn't set any main svg element color, because I'd like the SVG image to inherit the color from the webpage or other environment rather than from another object in the SVG file. I set stroke and fill to currentColor for all of my symbols in the symbol file. Critically, doing this also for stop-color appears to cause inkscape to crash, so I didn't do that (I don't actually know what that's for, but fill and stroke sets the full color in my case). The symbols then retain the currentColor properties when used in other SVG files. Additionally, they still appear as black in inkscape. I also needed new bezier curves to use a currentColor stroke. This was possible to do by default by creating a bezier curve, editing the CSS with the Selectors and CSS panel, and then using "Take from Selection" to set the new default.