Display vectors as spritenode?
Does anyone know how I can display a vector as a normal spritenode?
Thanks in advance :)
what would "displaying a vector" look like to you? Printing the numbers? Drawing an arrow?
@JonB Perhaps vector graphics instead of bitmap?
look at ShapeNode its a subclass of spritenode and it draws vectors
@JonB preferably I would like to display vector graphics that I designed myself
Reslly, you need to add a few more words so people can help you...
... are you trying to display SVGs?
PDF vector graphics?
Draw your own using ui.Path (line_to, move_to,stroke/fill and the like)?
@JonB sorry if i wasn't precise enough, I thought it would be enough information. I'm trying to display .svg graphics, as they take up less storage than high resolution images
got it. ios really has no native support for svg.
PNG, JPG or PDF are what you will want to use.
For single color, one option is to use a font creation tool (there are many) that let you convert your svg to a svg font, then use svg2ttf to convert to a ttf font, which can be installed systemwide, or can be loaded temporarily in app. Then, you can create images from the glyphs. Not really worth it in my opinion...
Another option which looks promising but i have not explored yet:
https://github.com/Kozea/CairoSVG can parse svg to produce a tree object, which then uses
https://github.com/Kozea/cairocffi/ to convert to png. cairocffi might work without modification, or a small few, since it relies on ffi in a similar way that objc_util does, and i think the ios cairo is similar if not identical to the mac version. If not, you might also be able to use that tree to write your own output to ui.Path commands in an ui.ImageContext, and get_image provides the ui.Image.
A final option -- convert svg to vector PDF. I believe ui.Image.from_file can read pdf. I don't know hw they compare size wise.. some programs might add a lot of garbage to a pdf, ImageMagick probably would do it well.