-
Scripting – Centre Mask on Shape Layer
Hey Guys,
I have created this snippet of code that creates a rectangle mask on any layer given it’s dimension. It works fine on all layers except Shape Layers and Text Layers. I can’t quite figure where I’m going wrong. It doesn’t centre when I thought it would. How do I center the mask?
The image show’s how it’s not cantered.
myLayer = app.project.activeItem.selectedLayers[i];
newMask = myLayer.Masks.addProperty(“ADBE Mask Atom”);
myProperty = newMask.property(“ADBE Mask Shape”);
newMask.name = “Rectangle Mask”;
newMask.maskMode = MaskMode.ADD;
myShape = myProperty.value;
myShape.vertices = [[myLayer.width,0],[0,0],[0,myLayer.height],[myLayer.width,myLayer.height]];
myShape.inTangents = [[0,0],[0,0],[0,0],[0,0]];
myShape.outTangents = [[0,0],[0,0],[0,0],[0,0]];
myShape.closed = true;
myProperty.setValue(myShape);
Thanks,
Liam