can I use a shape(polygon) as a mask?

Is it possible to use a shape as a mask?  

How would I achieve this for example:

Requirement:  Glass of colored liquid where the liquid level rises and falls.

Implementation: (one idea)

  • layer1 - background image (ideally rectangle with pattern fill for liquid)

  • layer2 - polygon mask same as outline as glass (i.e. shape)

  • layer3 - PNG image of glass with background and inside of glass being transparent

  • then layer 1 could move up &  down showing top of liquid, but would only appear within the outline of the glass based on the layer 2 mask

Will leave this as the basic shape as mask question.  Have moved the “how would you do this” question to:  http://forums.coronalabs.com/topic/42020-tipping-glass-of-beer-with-g20-what-would-be-the-best-approach/ , with the title “beer” in it to attract some attension hopefully :slight_smile:

So is it possible to have layer2 as a mask for layer1?  If not what would be the next best approach?

Rob/Brent - I’m assuming this is not possible? 

Rob/Brent - I’m assuming this is not possible? 

Anyone heard anything on this? I just want to use another display object as a mask too.

Hello,

It’s not possible to directly use a vector object (i.e. polygon) as a mask. However, I believe you could create the vector object, save it as a PNG, and then load/use it as a mask. See the following forum thread as an example:

http://forums.coronalabs.com/topic/9269-vector-based-masking-in-corona-here/

Take care,

Brent

We do just that here: http://ragdogstudios.com/2013/12/29/transform-any-polygon-into-a-mask-with-corona-sdk/   (;
Supply a a display object you’d like to mask, and a polygon, rect, circle you’d like to use as a mask.

Anyone heard anything on this? I just want to use another display object as a mask too.

Hello,

It’s not possible to directly use a vector object (i.e. polygon) as a mask. However, I believe you could create the vector object, save it as a PNG, and then load/use it as a mask. See the following forum thread as an example:

http://forums.coronalabs.com/topic/9269-vector-based-masking-in-corona-here/

Take care,

Brent

We do just that here: http://ragdogstudios.com/2013/12/29/transform-any-polygon-into-a-mask-with-corona-sdk/   (;
Supply a a display object you’d like to mask, and a polygon, rect, circle you’d like to use as a mask.