Copy link to clipboard
Copied
Is there any way to find a specific point on a path, that is not necessarily an anchor point?
What I'd like to be able to do is tell Illustrator "Give me the coordinates of the point that's exactly at half of this path's length" or "... exactly 25% ...". And if that's possible, can I somehow add an anchor point to that point, or cut the path at that point?
Thanks!
Copy link to clipboard
Copied
For straight lines only, or optionally for curved lines as well? For a given straight path segment, or any object?
Straight lines is straightforward interpolation:
for every pair of points (A,B) test if your target is between Ax and Bx, and Ay and By. If so, your coordinates are Ax+d*(Bx-Ax) and Ay+d*(By-Ay) (where d is your factor in decimals, 25% is 0.25).
Curved lines are represented by Bézier curves, and there is no straightforward solution. In that case you have to subdivide the curve until you are "close enough". Still fairly easy, but I cannot type *that* from memory. 🙂
Note that there is a difference in the order of points: 25% up the path from A to B is different then from B to A.
Copy link to clipboard
Copied
With Scriptographer it is really easy:
Copy link to clipboard
Copied
Thanks! Yeah, I'm trying to avoid Scriptographer, since there's no version for CS6 in sight.
Copy link to clipboard
Copied
What I think you will need to do is… avoid the pathPoints.add() method this adds a point to the end of the current path then allows you to move it's position… Store all path points to an array, insert your new pathPoint item into that array then use the pathItem.setEntirePath() method… Me and Monsieur Bézier are going to have to have words one day…