Open tinchodias opened 5 months ago
I'm not sure it is on purpose but one can make it possible to change the "color" of an svg image. This is necessary to implement skin correctly in Toplo. It is already the case for png image. the inner form color can be changed by the skin (we already discussed about that if I remember well)
@plantec you made me remember once I found how to render this icons in colors, using cairo masks. I think with @labordep.
For the record, this is a way to see an Ant SVG icon in a web browser:
svgString := ToAntDesignIconProvider outlined_moon.
iconColor := Color purple.
htmlRef writeStreamDo: [ :stream |
stream << '<!doctype html><html lang=en>
<head><meta charset=utf-8><title></title></head>
<body style="color:#'.
stream << iconColor asHexString.
stream << ';">'.
stream << svgString.
stream << '</body></html>' ].
WebBrowser openOn: htmlRef asUrl
Note: BlSvgColor fromString: 'currentColor'
was returning Color white
. But since the merge of svgEnh2 yesterday, this signals an error. I'm working on a solution.
A good solution will close this issue, but I may push faster solution before. I would return Color black
to be more similar to what a user gets in a web browser, but maybe I make it answer white to be compatible with previous behavior... maybe it breaks the Toplo skin else.
@plantec
That commit wasn't really a fix. It was a mere workaround
SVGs can have
fill="currentColor"
andstroke="currentColor"
attribute/values to specify that a SVG shape inherits the color from the HTML element that contains the SVG tag. I think thecurrentColor
value is useful for Bloc-SVG. For example, for theme an icon. In fact, I0ve discovered it at the "outlined moon" icon at Ant icon set.See:
This behavior would be a responsibility of
BlSvgFactory
. But note that: