Page 1 of 1

Change SVG Color Via Action?

Posted: Sat Jan 12, 2019 9:06 pm
by TheRealMojoJojo
Hi All,

Is it possible to change the colors of the SVG files with an action such as "on click"? I am doing all I can to keep the tour file sizes down so would like to simply change the color instead of creating additional graphics.

Thanks!

Re: Change SVG Color Via Action?

Posted: Sat Jan 12, 2019 10:18 pm
by Hopki
Hi,
You can't dynamically change the colour of an SVG but if its file size and performance you're concerned about then did you know If a graphic is under 5K then it gets coded inline with the skin.js file.
This means the loading will be far better.
Only images larger than this will get placed into the images folder.
Regards,
Hopki

Re: Change SVG Color Via Action?

Posted: Sun Jan 13, 2019 1:15 am
by TheRealMojoJojo
Hi Hopki,

Thanks for the quick response and no, I did not know that. That's good to know and thanks for sharing :-)

Re: Change SVG Color Via Action?

Posted: Mon Jan 14, 2019 5:34 am
by mbb
Inline SVGs can be altered via javascript. Haven't had the need to do this myself yet, but here's a page on stackoverflow discussing it which may lead you to what you need?

https://stackoverflow.com/questions/987 ... javascript

Re: Change SVG Color Via Action?

Posted: Mon Jan 14, 2019 8:54 pm
by TheRealMojoJojo
mbb wrote: Mon Jan 14, 2019 5:34 am Inline SVGs can be altered via javascript. Haven't had the need to do this myself yet, but here's a page on stackoverflow discussing it which may lead you to what you need?

https://stackoverflow.com/questions/987 ... javascript
Very interesting stuff. It's a little outa my league but maybe someone with more coding experience can whip together a working script for us :-) Thanks for sharing!

Re: Change SVG Color Via Action?

Posted: Tue Jan 15, 2019 2:13 am
by Tony
Here's a cute little coloring script that I found online. It's implemented as an html page loaded via an iFrame in a text box. The link will take you to a page with the code.

Link: https://s3-ap-southeast-2.amazonaws.com ... index.html


svg-0.jpg
svg-0.jpg (62.55 KiB) Viewed 5667 times


Tony

Re: Change SVG Color Via Action?

Posted: Mon Jan 21, 2019 7:41 pm
by TheRealMojoJojo
That's actually pretty cool. Thanks for sharing Tony! I'll see if I can figure out a way incorporate the concept into my tours :-)