Dynamically drawing shapes in Lua

Hi all,

In the game I’m developing the beginning includes a badge customisation page. This means the user can choose the shape, colour patterns and actual colours of their badge. For memory and size purposes, we don’t want to create an image for every possibility as we allow many many colours and may want to add more shapes/patterns in the future.

In the Flex version of our app we use a lot of Cubic Beizer curves, but the only thing I can see to use is display.newLine(); which a )wont make a pattern we can fill, and b )won’t make curves easy to draw.

If anyone can help it will solve days of stress and failed efforts!

Many thanks in advance

James

Curves are not a strong suit with Corona SDK.  There are some curve functions in the community code, but at the end of the day they are just connected lines.  Graphics 2.0 when it comes out is supposed to support polygons that can be filled with a color, gradient or image.  I’ve not heard about any curve processing. 

Thanks for your response Rob, that’s frustrating but I guess I can try and look for a way around it. When is Graphics 2.0 scheduled to come out?

We don’t have a date that we can give out yet.

Curves are not a strong suit with Corona SDK.  There are some curve functions in the community code, but at the end of the day they are just connected lines.  Graphics 2.0 when it comes out is supposed to support polygons that can be filled with a color, gradient or image.  I’ve not heard about any curve processing. 

Thanks for your response Rob, that’s frustrating but I guess I can try and look for a way around it. When is Graphics 2.0 scheduled to come out?

We don’t have a date that we can give out yet.

Rob,

Any updates on Graphics 2.0 yet? Any more news on whether or not it will acommodate curves as well?

Thanks

Walter is posting nearly weekly blog posts on it.  I would go to http://feedback.coronalabs.com and put in a request for curve support. 

You can do fills with lines and shapes, based on triangles etc. I can generate a hill of any shape, and fill it in with whatever color I want, and also add physics to it. It doesn’t work with images (yet, or I haven’t figured it out!) but I can fill it in. It’s based on angles, and calculations of the stage etc.

You can see a test game I was making with dynamic hill generation. It generates each screen, and fills in the bottom and top  with color, along with the middle line. This is a very complex example, but I have a very stripped down version of it that just shows one screen and the hills being filled in with color. 

Here is the video : http://www.youtube.com/watch?v=iq9iY04S4rA

If you are good with math, you can figure it out. It just takes some time :slight_smile:

The only thing I can think of is maybe using masks or something and creating a shape outside the image and surrounding the image with the shape, along with scaling the image. However masks are quirky, I don’t even know if that is feasible…hmmm.

Hit me up on twitter @nicholasgolden I can share with you the basic example (non scrolling single screen hill generation). 

Hi Nicholas,

Thanks for your response - this fills me with hope that it is actually possible! The beizer curves are used for badges and facial avatars, so hopefully this will be doable. I’ll talk to you more on Twitter!

Well, since I’m just telling how wide the fill is, I’m sure it could be adapted to another purpose. I saw you on twitter, I followed back.

Get in touch, I can give you the ultra vanilla example that shows the basics (well, it’s not really basic, but compared to what I’m doing in the video it’s CAKE hah). 

-Nick

hey nicholas, that’s good stuff!

Rob,

Any updates on Graphics 2.0 yet? Any more news on whether or not it will acommodate curves as well?

Thanks

Walter is posting nearly weekly blog posts on it.  I would go to http://feedback.coronalabs.com and put in a request for curve support. 

You can do fills with lines and shapes, based on triangles etc. I can generate a hill of any shape, and fill it in with whatever color I want, and also add physics to it. It doesn’t work with images (yet, or I haven’t figured it out!) but I can fill it in. It’s based on angles, and calculations of the stage etc.

You can see a test game I was making with dynamic hill generation. It generates each screen, and fills in the bottom and top  with color, along with the middle line. This is a very complex example, but I have a very stripped down version of it that just shows one screen and the hills being filled in with color. 

Here is the video : http://www.youtube.com/watch?v=iq9iY04S4rA

If you are good with math, you can figure it out. It just takes some time :slight_smile:

The only thing I can think of is maybe using masks or something and creating a shape outside the image and surrounding the image with the shape, along with scaling the image. However masks are quirky, I don’t even know if that is feasible…hmmm.

Hit me up on twitter @nicholasgolden I can share with you the basic example (non scrolling single screen hill generation). 

Hi Nicholas,

Thanks for your response - this fills me with hope that it is actually possible! The beizer curves are used for badges and facial avatars, so hopefully this will be doable. I’ll talk to you more on Twitter!

Well, since I’m just telling how wide the fill is, I’m sure it could be adapted to another purpose. I saw you on twitter, I followed back.

Get in touch, I can give you the ultra vanilla example that shows the basics (well, it’s not really basic, but compared to what I’m doing in the video it’s CAKE hah). 

-Nick

hey nicholas, that’s good stuff!