-
Notifications
You must be signed in to change notification settings - Fork 24
Home
TPSVG is a library project for Android for displaying SVG images.
The code works in two distinct stages. Firstly, the library is used to parse a raw image SVG file. The result of doing this is that the parsed image is converted into an internal representation, comprising a kind of instruction 'bytecode' together with collections of native graphics objects such as Paint, Path, Matrix, and so on. This first stage is done just once per image and it can be quite a slow process (as you'll see when waiting for the example project(s) to show you an image), so parsing of particularly detailed images might be best done on a separate thread. The flyweight pattern is used so that each SVG file is parsed only once and the resultant internal structures are shared across all Views that use a given SVG image.
The second stage is rendering, where the library is used to draw the image onto Canvas by running through the bytecode sequence and graphic object collections that were built up when initially parsing the image.
The original purpose of creating this library was for an application that displays various kinds of animated controls and indicators which I wanted to have the freedom of designing in Inkscape first. By 'animated' I don't really mean animated as such, but rather the ability to manipulate various aspects of the SVG images as they are rendered at runtime, in code. To give an example, it is possible to author a circular gauge in Inkscape, and assign a special ID string to the gauge pointer and other image features that should be manipulated. Then, an ItpsvgAnim handler that you pass to paintImage() can receive calls to callback methods when those particular bits of graphics are about to be drawn. For instance, a callback method in your ItpsvgAnim implementing class would affect the gauge pointer angle.
I will add more information about the callbacks and stuff soon. I'm also in the process of giving the source code a damn good tidy.