hi all,
is there a way to draw in Sparrow. I know we can draw rectangles, but can I draw a rounded corner rectangle or may be a circle? I mean, which the way to go if I want to draw my own shapes. I could not find a line drawing API inside Sparrow.
thank you
custom drawing
(5 posts) (2 voices)-
Posted 1 year ago #
-
Hi!
Unfortunately, Sparrow does not currently have any drawing methods. So you either have to find a way to emulate what you want to do with textures, or write custom OpenGL code for drawing.
I'm thinking about a way to support Core Graphics contexts as textures, but that will only be available in a future version.
Sorry that I do not have any better news on that topic!
Posted 1 year ago # -
hey Daniel,
thanks for the response. And never be sorry.
You have done a splendid job putting up Sparrow framework. I am a core Flash developer and Sparrow seems to be the place to be, for a flash developer.
Glad that its coming, and if at all i can hep you in that with my limited knowledge, that will be my pleasure.Now can you guide me through the process the SPQuad or SPRect is being drawn. I have looked into the source, but couldnot find, where actually its being drawn. So that I could re-write that method to add my custom rounded corner rectangles or may be drawing lines. Does, override render method will help?
Posted 1 year ago # -
Hi Saumya,
thanks a lot for the compliments! That means really a lot to me =)
The rendering code can be found in the file "SPRendering.m". In there, you will find the render methods of all important classes.
So, one way to create an SPQuad with rounded corners would be to create a subclass of SPQuad and adding a property for the radius of your corners. Then you'd have to write a custom "render"-method that uses OpenGL-calls to draw the rectangle.
If you are not familiar with OpenGL drawing, you'll sure find some tutorials on the web. The tricky thing will be to find out how you can create your object with triangles -- because in OpenGL, you render almost everything with triangles.
Thus, my recommendation is to first try if you can do what you want with textures, and only if that is not possible or extremely difficult, work on a custom render method.
A rounded rectangle could be built, for example, by drawing 4 SPImages that have a texture that contains a quadrant of a circle in the corners, and five SPQuads that fill the inner part of the rectangle. You can combine those objects in one SPSprite easily.
I hope that gets you started!
Posted 1 year ago # -
Hey Daniel,
Thanks a lot.
I think currently i go for full textured buttons rather than drawing it. A lot of work
textures seems to be good alternative.
Posted 1 year ago #
Reply
You must log in to post.