Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: What is the best way to color SVG? #6503

Closed
alexdi220 opened this issue Dec 20, 2021 · 5 comments
Closed

Question: What is the best way to color SVG? #6503

alexdi220 opened this issue Dec 20, 2021 · 5 comments
Labels

Comments

@alexdi220
Copy link
Contributor

Hi, how can I color the SVG? I want to use one SVG and change it's colors depending on the state: Dark\Light theme, Hover, Pressed, etc.
WinAppSDK 1.0 Desktop

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Dec 20, 2021
@alexdi220
Copy link
Contributor Author

Any news month later?

@codendone
Copy link
Contributor

Similar to #3941 or #3974. Combining my comments from those: The current svg support is static with no object model support. The only option I can think of is to load the svg file into a buffer, lookup the color RGB values you need, search and replace them in the svg buffer, and then put that buffer in a stream to load it. Of course, you'll need to listen for theme changes and repeat this process when that happens.

For more frequent changes, like hover and pressed, you'd likely want to save SvgImageSources for the manipulated SVGs.

@alexdi220
Copy link
Contributor Author

Thanks. Do you have any plans to implement the coloring of SVGs at the runtime? It would be powerful feature for icons.

@codendone
Copy link
Contributor

We don't currently have any plans for that. I'd like to expose an SVG object model so that you could at least have some code to go poke some values rather than fully reparse the SVG. But for a case like this you'd probably also want <Style> to work, which also isn't supported. I expect we won't have time to get to this for quite a while.

You might want to consider AnimatedIcon, which can change states (and animate). I'm not super familiar with this, but I believe it supports colors and you could set different states depending on the theme. High contrast theme likely would require more work to get and set the right RGB values.

@gabbybilka
Copy link
Member

Closing as answered.

@ghost ghost removed the needs-triage Issue needs to be triaged by the area owners label Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants