GeraudBourdin / Ti.SvgView

Create a view from an svg file (expose the androidsvg-1.2.1 lib and the SVGKit 2.X for IOS lib).
MIT License
50 stars 24 forks source link

Change color of SVG #5

Open yissachar opened 9 years ago

yissachar commented 9 years ago

It would be nice to be able to change the fill color of an SVG. For instance:

var svg = svgView.createView({
    image: "/thing.svg",
    color: "#fff"
});

Should display the SVG as white, even if the original SVG source is not white.

GeraudBourdin commented 9 years ago

svg file have multiples elements with colors. Which elements do you think the module should fill ?

yissachar commented 9 years ago

I was thinking that it would recursively change all elements to the specified color. If that doesn't make sense, can the elements be exposed so that I can manually change the color of each one myself?

My use case is pretty simple - I have an SVG that is completely black, and I sometimes want to change it to be white.

GeraudBourdin commented 9 years ago

this is not the goal of this module, but i'll look into it as soon as i have some time. But why d'ont you use a custom font for this or simply use 2 svg file with different colors ?

yissachar commented 9 years ago

I could use multiple SVGs but it seems a shame to do that and add the extra size to the app when I can do it programmatically.

I originally tried custom fonts but it turns out they are broken on Android in TiSDK 4.x (see TIMOB-18968).

GeraudBourdin commented 9 years ago

i will look into it as soon as i have some time for it.

falkolab commented 8 years ago

@yissachar look at https://github.com/falkolab/Ti.SVGProduct/blob/master/example.js#L35

GeraudBourdin commented 8 years ago

:+1: :)