Why the 3 pixel border rule for mask?

Corona DOCS state: “The mask image must be bordered by at least 3 pixels of black space on all four sides.” What is the reason for this and what troubles I may encounter if I decide not to follow this rule? Masks seem to work just fine (at least in the simulator) also without the 3px border. I need to achieve two things with a single mask:

  1. Fade small part of the image

  2. Hide/Unhide the mask

For this reason I created a small mask without 3px borders (see the attached image). I shift the mask horizontally to “hide” or “unhide” the effect of mask. If I followed the 3px rule I would need to create a huge mask that covers the whole image. Is it really required?

Hi @polygonblog,

I’m not sure about the deep technical reason behind the border, but if you don’t use it, I believe your masks will definitely break when you try them on different devices (not necessarily all devices, but some). In other words, there’s a very good reason why the documentation specifies that border. :slight_smile:

Brent

Thanks. I believe there is a good reason for this rule. I just wonder whether it’s a rule of thumb or really required in all situations.

I’m going to make a SWAG at it (Scientific While Guess).  If you have an image with a single pixel wide in it and that image scales down, it’s possible that line will be removed when it gets scaled down.  Having 3 pixels pretty much guarantees that when the mask scales down, there will still be at least one black row of pixels.

I could be completely wrong on this, but it sounds plausible :slight_smile:

I always try to make the things I’m masking evenly divisible by 4 and make sure I have 4 pixels of black.  Better safe than sorry.

Rob

Thanks Rob, itmakes sense. But why do we need the border? In some situations we need to create a huge mask just to able to add the border.

I’m sure its some limit to keep the masking from going off into infinity.

Rob

Hi @polygonblog,

I’m not sure about the deep technical reason behind the border, but if you don’t use it, I believe your masks will definitely break when you try them on different devices (not necessarily all devices, but some). In other words, there’s a very good reason why the documentation specifies that border. :slight_smile:

Brent

Thanks. I believe there is a good reason for this rule. I just wonder whether it’s a rule of thumb or really required in all situations.

I’m going to make a SWAG at it (Scientific While Guess).  If you have an image with a single pixel wide in it and that image scales down, it’s possible that line will be removed when it gets scaled down.  Having 3 pixels pretty much guarantees that when the mask scales down, there will still be at least one black row of pixels.

I could be completely wrong on this, but it sounds plausible :slight_smile:

I always try to make the things I’m masking evenly divisible by 4 and make sure I have 4 pixels of black.  Better safe than sorry.

Rob

Thanks Rob, itmakes sense. But why do we need the border? In some situations we need to create a huge mask just to able to add the border.

I’m sure its some limit to keep the masking from going off into infinity.

Rob