Custom shape

hello, how can i create custom shapes? like this red rectangle with custom borders?

This is probably done using masks, with the red bit just being a rounded rectangle that is cut-off by the mask so only the bottom left corner is shown.

Unfortunately it’s not as easy in Corona as some other frameworks to use the larger image as a mask for the smaller one. You’ll need a third image which is just black and white - black where you don’t want the image to show and white where you do.

However this does mean you don’t have to create the food images with rounded corners. It might be setup like this:

  1. A normal rectangular image, 512 x 512.

  2. A smaller rounded white rectangle, coloured red in code, placed to be in the top right with most of it outside the large image. Both images placed in same group.

  3. A 512 x 512 mask, with a large white rounded rectangle in the middle and small black border. Mask applied to the group.

https://docs.coronalabs.com/guide/media/imageMask/index.html

So this effect can only be created with images? can’t do it in code?

Technically you could, using Corona’s built in rounded rects to generate and save a mask on the fly and then apply it, but to be honest it will be a lot quicker to just create the mask manually. Also, the built-in round shapes in Corona are very pixelated.

Thanks nick_sherman.