Copy link to clipboard
Copied
How to apply corner radius to shape using setEntirePath()
Copy link to clipboard
Copied
Not possible. You can't make smooth points with setEntirePath().
Copy link to clipboard
Copied
Okay.
Is there any other method to do that in script?
Copy link to clipboard
Copied
setEntirePath() takes care of the Anchor points, after that you'll have to set the Handles of each Anchor. It's quite a bit of Math, but it can technically be done
Copy link to clipboard
Copied
check this thread for a similar question
Copy link to clipboard
Copied
Okay thanks.
But "PointType.SMOOTH" not working for me.
Copy link to clipboard
Copied
PointType is ReadOnly, it's used to find out what kind of point we're dealing with, not to change from corner to smooth or viceversa.
Copy link to clipboard
Copied
Thank you. But Is it possible to change pointType into
Copy link to clipboard
Copied
Thank you. But Is it possible to change pointType into
By @Ashu24845488rcnx
I'm not sure what you're asking. Can you elaborate?
If you mean if it's possible to change a corner point to a smooth point by using the PointType property, no, it's not possible.
Copy link to clipboard
Copied
Here's a roundedRectangle() function with the same syntax as rectangle(), but with an added corner radius argument.
// e.g. of function call
roundedRectangle(
-25 /*top*/, 25 /*left*/, 50 /*w*/, 50 /*h*/, 10 /*cornerRadius*/);
/*
* roundedRectangle by Femke Blanco
* Beta 04/08/2022
*/
function roundedRectangle(top, left, w, h, r) {
var paths = app.activeDocument.pathItems;
var path1 = paths.add();
var p;
var c = r * ((4 / 3) * Math.tan(Math.PI / 8)); // handle length
// p2
point(left + r, top, left + r, top, left + r - c, top);
// p3
point(left + w - r, top, left + w - r + c, top, left + w - r, top);
// p4
point(left + w , top - r, left + w , top - r, left + w , top - r + c);
// p5
point(left + w, top - h + r, left + w, top - h + r - c,
left + w, top - h + r);
// p6
point(left + w - r, top - h, left + w - r, top - h,
left + w - r + c, top - h);
// p7
point(left + r, top - h, left + r - c, top - h, left + r, top - h);
// p8
point(left, top - h + r, left, top - h + r, left, top - h + r - c);
// p1
point(left, top - r, left, top - r + c, left, top - r);
path1.closed = true;
function point(x, y, Rx, Ry, Lx, Ly) {
p = path1.pathPoints.add();
p.anchor = [x, y];
p.rightDirection = [Rx, Ry];
p.leftDirection = [Lx, Ly];
}
}