Skip to main content

JSR-226 - Disappointment, or?

2 replies [Last post]
gullet
Offline
Joined: 2003-11-17

Hi,

I've looked at the support for SVG Tiny in JSR-226, but it feels like a step back, when the SVGImage can't be appended to the GameAPI's LayerManager. I'm looking at creating a game based on image backgrounds in SVG and Sprites moving on top of that background, but I can't see that it will work with the current API's.

Ideally, the SVGTiny's SVGImage object would extend from the regular Image, so that both bitmap images and vector based images could use the LayerManager, Sprites and TiledLayers. Alternatively, if there was "SVG equivalents", like SVGLayerManager and SVGSprite, that's fair enough, so that I can at least have a layered approach to rendering of SVGImages and the ScalableGraphics objects.

Or did I miss something?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
suriththekkiam
Offline
Joined: 2006-10-13

SVGImage can be rendered into an Image. TiledLayer's or Sprite's can be created from this Image, thereby using SVG content as the source.

SVG can be rendered into an Image by first obtaining a Graphics object from that Image and then binding an instance of ScalableGraphics to it. Please see the examples in the "Overview" section of the JSR 226 spec for example code. (snippet below.)

//SVGImage svgimage = SVGImage.createImage(...);

Image img = Image.createImage(100, 100);
Graphics g = img.getGraphics();

ScalableGraphics sg = ScalableGraphics.createInstance();

sg.bindTarget(g); //Bind the ScalableGraphics context to MIDP Graphics object.
sg.render(0, 0, svgimage); //Render the SVG Image.
sg.releaseTarget(); //Release the target

applebanana8
Offline
Joined: 2004-06-16

SVG has rendering order:




where and b overlap b is drawn. You can change the order in the document through DOM calls, thereby putting a on top in the drawing.