Skip to content

Commit

Permalink
updated functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
adi-panda committed Jan 22, 2023
1 parent 4c7fb27 commit d02b97f
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 19 deletions.
19 changes: 10 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "extendscript-debug",
"request": "launch",
"name": "ExtendScript",
"program": "${workspaceFolder}/dist/script.jsx",
"stopOnEntry": false
}
]
"configurations" : [
{
"type": "extendscript-debug",
"request": "launch",
"name": "ExtendScript",
"script" : "${workspaceFolder}/dist/script.jsx",
"hostAppSpecifier": "aftereffects-22.0",
"preLaunchTask": "yarn build",
}
]
}
23 changes: 23 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"group": "build",
"problemMatcher": [],
"label": "npm: build",
"detail": "spack"
},
{
"label": "yarn build",
"type": "shell",
"command": "yarn build",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
82 changes: 72 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,81 @@

(function testScript() {

app.beginUndoGroup("Test Script");

if (app.project.activeItem instanceof CompItem) {
const comp = app.project.activeItem;
const curr = comp.selectedLayers[0];
var newLay = curr.duplicate();
newLay.name = "mangaPanelDuplicate";
newLay.moveAfter(curr);
//set fill of current layer to black
(newLay.property("Contents").property(1).property("Contents").property("Fill 1").property("Opacity") as Property<Number>).setValue(100);
(newLay.property("Contents").property(1).property("Contents").property("Stroke 1").property("Opacity") as Property<Number>).setValue(0);
(newLay as AVLayer).blendingMode = BlendingMode.STENCIL_ALPHA;

if(comp.selectedLayers.length != 2){
alert("Please select a base layer and a shape layer!");
return;
}

if(comp.selectedLayers[0].index > comp.selectedLayers[1].index){
var selectedShapeLayer = comp.selectedLayers[1];
var baseLayer = comp.selectedLayers[0];
} else {
var selectedShapeLayer = comp.selectedLayers[0];
var baseLayer = comp.selectedLayers[1];
}



//Duplicate layer delete all shapes after the first
if (selectedShapeLayer instanceof ShapeLayer) {
var shapes = selectedShapeLayer.property("Contents");
if(shapes instanceof PropertyGroup){
for (var j = 1; j <= shapes.numProperties; j++) {
var newLayer = selectedShapeLayer.duplicate();
var newShape = newLayer.property("Contents");
newLayer.name = newShape.property(j).name;

if(newShape instanceof PropertyGroup){
for (var k = 1; k != newShape.numProperties; k++) {
for (var k = newShape.numProperties; k > 0; k--) {
if (k !== j) {
newShape.property(k).remove();
}
}
}
}

var baseLayerDuplicate = baseLayer.duplicate();
baseLayerDuplicate.moveAfter(newLayer);
if(newLayer instanceof ShapeLayer){
var borderDuplicate = isolateBorder(newLayer);
comp.layers.precompose([newLayer.index, borderDuplicate.index,
baseLayerDuplicate.index], newLayer.name, true);
}
}


selectedShapeLayer.remove();
baseLayer.remove();

}
}
} else{
alert("Please select a composition");
}

app.endUndoGroup();

})();

function isolateBorder(border : ShapeLayer): Layer {
var newLay = border.duplicate();
newLay.name = "borderDuplicate";
var fillOpacity = border.property("Contents").property(1).property("Contents").
property("Fill 1").property("Opacity");
if(fillOpacity instanceof Property){
fillOpacity.setValue(100);
}
var strokeOpacity = border.property("Contents").property(1).property("Contents").
property("Stroke 1").property("Opacity");
if(strokeOpacity instanceof Property){
strokeOpacity.setValue(0);
}
if(border instanceof ShapeLayer){
border.blendingMode = BlendingMode.STENCIL_ALPHA;
}
return newLay;
}

0 comments on commit d02b97f

Please sign in to comment.