Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I modify this script to set the Mask mode to SUBTRACT, instead of the default ADD?

Contributor ,
Mar 08, 2025 Mar 08, 2025

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();

 

 

 

 

 

TOPICS
Scripting
121
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 08, 2025 Mar 08, 2025

Add this:

mask.maskMode = MaskMode.SUBTRACT;

 

Translate
Community Expert ,
Mar 08, 2025 Mar 08, 2025

Add this:

mask.maskMode = MaskMode.SUBTRACT;

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 08, 2025 Mar 08, 2025
LATEST

Wonderful. Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines