Fit mask size to changing the size of the auto-layout?

Hello everyone, I need to change the size of the mask depending on the size of the auto-layout. There is also a limit to which the mask can expand. Is there any way to implement this?
I mean something like this