# Copied!

June 2, 2020
After-Effects expression
Inverted Rounded Corners Rectangle

Apply this expression to a path property to create a rectangle with inverted rounded corners (corners round inwards).
At the beginning of the expression, you can set the corner radius and the two main points that form the rectangle (top left & bottom right).
by default, those values are set to 'undefined' which will automatically create a rectangle the size of the current comp, with a relative corner radius.

Good Boy Ninja
All Tools Sale
For a limited time
9
Days
99
Hours
99
Minutes
99
Seconds
Promo ends 30 Aug, 20:00 UTC
Shape Layer
Path
Expression

// USER SETTINGS

cornerRadius = undefined; // leave undefined to use comp size average;

topLeftCorner = undefined; // leave undefined to use comp zero point [0,0];

btmRightCorner = undefined; // leave undefined to use comp size point [compWidth,compHeight];

// EXPRESSION

return [~~circlePntX, ~~circlePntY];

}

switch (iteration) {

//tl

case 0:

newA = [cornerPnt[0], cornerPnt[1] + cornerRadius];

newB = [cornerPnt[0] + cornerRadius, cornerPnt[1]];

return [newA, newB];

break;

case 1:

newA = [cornerPnt[0] - cornerRadius, cornerPnt[1]];

newB = [cornerPnt[0], cornerPnt[1] + cornerRadius];

return [newA, newB];

break;

case 2:

newA = [cornerPnt[0], cornerPnt[1] - cornerRadius];

newB = [cornerPnt[0] - cornerRadius, cornerPnt[1]];

return [newA, newB];

break;

case 3:

newA = [cornerPnt[0] + cornerRadius, cornerPnt[1]];

newB = [cornerPnt[0], cornerPnt[1] - cornerRadius];

return [newA, newB];

break;

}

}

topLeftPnt = (topLeftPnt === undefined) ? [0, 0] : topLeftPnt;

btmRightPnt = (btmRightPnt === undefined) ? [thisComp.width, thisComp.height] : btmRightPnt;

tl = topLeftPnt;

tr = [btmRightPnt[0], topLeftPnt[1]];

br = btmRightPnt;

bl = [topLeftPnt[0], btmRightPnt[1]];

AllCorners = [tl, tr, br, bl];

allPntsArray = [];

allITArray = [];

allOTArray = [];

for (i = 0; i < 4; i++) {

angleFromCornerToCircle = 45 + (90 * i);

angleOfCirlcePntOutTangent = angleFromCornerToCircle - 90;

angleOfCirclePntInTangent = angleFromCornerToCircle + 90;

currentCorner = AllCorners[i];

newCirclePnt = currentCorner + findCircle

newInTan = FindCirclePnt(newCirclePnt, (cornerRadius / 2), angleOfCirclePntInTangent);

newOutTan = FindCirclePnt(newCirclePnt, (cornerRadius / 2), angleOfCirlcePntOutTangent);

allPntsArray.push(newPntAB[0]);

allPntsArray.push(newCirclePnt);

allPntsArray.push(newPntAB[1]);

allITArray.push([0, 0]);

allITArray.push(newInTan);

allITArray.push([0, 0]);

allOTArray.push([0, 0]);

allOTArray.push(newOutTan);

allOTArray.push([0, 0]);

}

return createPath(points = allPntsArray, inTangents = allITArray, outTangents = allOTArray, isClosed = true)

}