Page 1 of 1

Creating Masks with Responsive Vertices

Posted: April 29th, 2013, 3:19 pm
by VinhSonNguyen
Hello everyone,

I was wondering if it was possible to create mask vertices without actually defining the exact coordinates.

For an example, let's say I wanted to create vertice point exactly 10% from the top and bottom of a layer. I could easily define coordinates like the following:

Code: Select all

definedMaskShape.vertices = [[0,100],[0,620],[1280,620],[1280,100]];
But when changing the size of the layer, obviously 10% from the top/bottom results in different coordinates. Is it possible to create vertices using percentages or something instead of exact coordinate points?

Thanks for your time and help. :)

Re: Creating Masks with Responsive Vertices

Posted: April 30th, 2013, 10:03 am
by Alan Eddie
Something like this: as a 2 element array: ?
[app.project.activeItem.width/10, app.project.activeItem.height/10, ]

Re: Creating Masks with Responsive Vertices

Posted: April 30th, 2013, 2:38 pm
by VinhSonNguyen
Alan Eddie wrote:Something like this: as a 2 element array: ?
[app.project.activeItem.width/10, app.project.activeItem.height/10, ]
Hey Alan,

Excuse my inexperience knowledge, but how would I apply that to mask vertices? I know for sure that would work when creating or modifying a layer, but how would I translate that to drawing mask points?

Thanks for your help!

Re: Creating Masks with Responsive Vertices

Posted: May 1st, 2013, 2:25 am
by Alan Eddie

Code: Select all

var newMask = mySolid.Masks.addProperty("Mask");
				  var myMaskShape = newMask.property("maskShape");
				  var myShape = myMaskShape.value;
				  myShape.vertices = [a,b,c,d];
				  myShape.closed = true;
				  myMaskShape.setValue(myShape);
a,b,c,d are 2 element arrays. So it's just mathematics getting the values.. from the comp or the layer or performing a calculation between the two. The zero coordinates start top left and work counter intuitively to some other software.