Answered
How do I modify this script to set the Mask mode to SUBTRACT, instead of the default ADD?
I have this script which attempts to create a vignette. However, the Mask mode is set to Add so it is currently a reverse Vignette (ie a soft black ellipse). How to I modify this script to make it Subtract instead? Or if that is not possible, Add Invert?
app.beginUndoGroup("Create Vignette");
var comp = app.project.activeItem;
if (comp && comp instanceof CompItem) {
var layer = comp.selectedLayers[0];
if (!layer) {
// Create a black solid if no layer is selected
layer = comp.layers.addSolid([0, 0, 0], "Black Solid", comp.width, comp.height, comp.pixelAspect);
}
if (layer) {
var mask = layer.Masks.addProperty("Mask");
var maskShape = mask.property("maskShape").value;
var compWidth = comp.width;
var compHeight = comp.height;
maskShape.vertices = [
[compWidth * 0.5, 0],
[compWidth, compHeight * 0.5],
[compWidth * 0.5, compHeight],
[0, compHeight * 0.5]
];
maskShape.inTangents = [
[-compWidth * 0.25, 0],
[0, -compHeight * 0.25],
[compWidth * 0.25, 0],
[0, compHeight * 0.25]
];
maskShape.outTangents = [
[compWidth * 0.25, 0],
[0, compHeight * 0.25],
[-compWidth * 0.25, 0],
[0, -compHeight * 0.25]
];
mask.property("maskShape").setValue(maskShape);
mask.property("maskFeather").setValue([750, 750]);
}
} else {
alert("Please open a composition first.");
}
app.endUndoGroup();
