Ok, i think i found some code:

John Lehmann

I have been using the following for cocos SVG sprites:
class SVGNode(cocos.cocosnode.CocosNode):
    """ A CocosNode that displays an SVG image, using squirtle library
"""
    def __init__(self, filename):
        super(SVGNode, self).__init__()
        file = pyglet.resource.file(filename)
        self.image = squirtle.SVG(file = file, anchor_x = "center",
anchor_y = "center")
        self.width, self.height = self.image.width, self.image.height
    def draw(self):
        glPushMatrix()
        glEnable(GL_POINT_SMOOTH)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        (x, y), angle, scale = self.position, self.rotation,
self.scale
        self.image.draw(x = x, y = y, angle = angle, scale = scale)
        glPopMatrix()
class SVGSprite(cocos.sprite.Sprite):
    """ A subclass of cocos Sprite that will accept the name of an SVG
image """
    def __init__(self, filename):
        node = SVGNode(filename)
        image = pyglet.image.create(width = int(node.width), height =
int(node.height))
        cocos.sprite.Sprite.__init__(self, image)
        self.add(node)
I don't know whether the way I have used draw() is appropriate, but
it
seems to work ok.
John


Now i'm wondering, when svg loaded to sprite, is it still vector? how
it's treated by transform commands like scale? like vector or raster
graphics? sorry for my ignorance, i'm beginner...

On Feb 28, 9:47 pm, sonomute <[email protected]> wrote:
> If you happen to have example of code using squirtle with cocos, can
> you post it?
>
> THank you!
>
> On Feb 28, 8:08 pm, Lucio Torre <[email protected]> wrote:
>
> > On Sat, Feb 28, 2009 at 3:33 PM, sonomute <[email protected]> wrote:
>
> > > Nice...
> > > What about composite sprites? and getting shapes from svg?
>
> > You can do composite sprites by creating a CocosNode (maybe a sprite?)
> > and adding images to it.
>
> > I dont know what features the svg library offers. Maybe you will have
> > to do the svg part by hand.
>
> > Lucio.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to