Answered
This topic has been closed for replies.
Try this (I did it in a hurry, so there may still be bugs and it's probably not as efficient as it could be):
s = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").size;
r = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").roundness;
w = s[0]/2;
h = s[1]/2;
maxR = Math.min(w,h);
r = Math.min(maxR,r);
t = r*0.5525;
if (r == 0){ // 4 points
p = [[-w,-h],[w,-h],[w,h],[-w,h]];
iT = [];
oT = [];
}else if (r >= maxR){
if (w == h){ // 4 points
p = [[0,-h],[w,0],[0,h],[-w,0]];
iT = [[-t,0],[0,-t],[t,0],[0,t]];
oT = [[t,0],[0,t],[-t,0],[0,-t]];
}else{ // 6 points
if (w > h){
p = [[-w+r,-h],[w-r,-h],[w,0],[w-r,h],[-w+r,h],[-w,0]];
iT = [[-t,0],[-t,0],[0,-t],[t,0],[t,0],[0,t]];
oT = [[t,0],[t,0],[0,t],[-t,0],[-t,0],[0,-t]];
}else{
p = [[-w,-h+r],[0,-h],[w,-h+r],[w,h-r],[0,h],[-w,h-r]];
iT = [[0,t],[-t,0],[0,-t],[0,-t],[t,0],[0,t]];
oT = [[0,-t],[t,0],[0,t],[0,t],[-t,0],[0,-t]];
}
}
}else{ // 8 points
p = [[-w,-h+r],[-w+r,-h],[w-r,-h],[w,-h+r],[w,h-r],[w-r,h],[-w+r,h],[-w,h-r]];
iT = [[0,t],[-t,0],[-t,0],[0,-t],[0,-t],[t,0],[t,0],[0,t]];
oT = [[0,-t],[t,0],[t,0],[0,t],[0,t],[-t,0],[-t,0],[0,-t]];
}
createPath(p,iT,oT,true)
Sign up
Already have an account? Login
To post, reply, or follow discussions, please sign in with your Adobe ID.
Sign inSign in to Adobe Community
To post, reply, or follow discussions, please sign in with your Adobe ID.
Sign inEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.