Hi, I will start to apologize if my english (and ideas ;)) sound a little “wacky”, this isn’t my main language.
I’m a little fresh on haxe/openfl so bear with me if make some bad basic assumptions or coding mistakes.
In my current cross-platform project I’m using a lot of SVG assets in openfl and I stumbled with the need to do color transformation to some of them. I know that right now the colorTransform in display objects only work for the Flash target, due to “technical details” (@singmajesty own words) that affect performance on others targets. My idea for a workaround for a colorTransform to a SVG asset is to create a method in the SVG class that allows to “tint” all fills and strokes of the SVG before render. I don’t know exactly how the parse is made in that particular importer, but I think that maybe it’s not that hard to add some channel increments to all colors when the render method is called
If this is possible, I think this method makes little to none performance impact when we need to do a color transformation before render the asset (pearhaps I’m doing all sort of crazy assumptions in this idea, if so correct me ;))
Another thing that I’m struggling to acomplish with SVG asset is to change dynamically a color of a particular fill (or stroke for that matter). The two workarounds that I’ve came up with are:
-
Divide the vector art in layers, and then save each layer in it’s own SVG, import them directly to their own sprite and the layer that has the fill that I want to change dynamically, draw it to bitmapdata and then color transform it (ugly process and only doable to a few assets);
-
Parse the SVG XML before hand, and find the fill by the path id, change it and then feed it again to the SVG instance to be rendered again (much better process, but still a little “ugly”);
My second sugestion is a method that enables to feed an id of a path and a color to the SVG object and it changes it before render to a display object.
Is this two ideas too out of place, or are they doable? Is anyone out there that faces the same problems that I have? @singmajesty, what do you think of this?
Best regards.