Copy link to clipboard
Copied
hi
I'm writing a script to clean up some imported line drawings and would really like emulate the behaviour of clicking the convert anchor point buttons in the UI. I haven't been able to find a way to do it.
My workflow is basically to select the anchorpoints that need smoothing, click the "convert to corner", which contracts all the bezier handles, then click "convert to smooth" which automatically adds nicely balanced handles with smooth curves between anchors. For my use case this actually works much better than trying to apply 'smoothing'
Simply changing the pathPoint type to PointType.CORNER and then to PointType.SMOOTH doesn't do the job.
And I can't find the button functionality as a menu item so I can go that way either.
Any suggestions greatly appreciated...
1 Correct answer
Look at these scripts:
1) Smooth Curve Points by Jim Heck
2) Smoothing by Hiroyuki Sato
Explore related tutorials & articles
Copy link to clipboard
Copied
Look at these scripts:
1) Smooth Curve Points by Jim Heck
2) Smoothing by Hiroyuki Sato
Copy link to clipboard
Copied
These are great @Sergey Osokin. I did a quick test and found the Jim Heck's script matches the UI's behaviour more closely. - Mark
Copy link to clipboard
Copied
Hiroyuki's and Jim's scripts are totally different. The smoothing.jsx script calculates a catmull-rom spline (which is where my mind went, too) and converts to beziers, but the smoothingCurvePoints.jsx script is simply about angles and sizes and scale (25%), with really no bezier maths at all. I'm no expert but I found it quite fascinating!
- Mark
Copy link to clipboard
Copied
I'm weak in the mathematics of Bezier curves. But Jim's solution is interesting. And I have seen the use of the Catmull-Rom spline more than once in the scripts of Japanese authors.
Copy link to clipboard
Copied
Bonjour à tous,
En 2013, j'ai publié un script "arrondi_angle1.js" sur Scriptopedia.org
A l'époque le script GenerateHandles.js de Hiroyuki ne me convenait pas entièrement, c'est pourquoi j'ai étudié le problème et faire à mon idée.
Dont voici le lien. https://www.scriptopedia.org/js-illustrator/162-arrondir-les-angles.html
Je suis juste intervenu pour vérifier si je pouvais encore me connecter, j'ai corriger une faute de grammaire dans le texte, ce qui explique la mise à jour 2023 qui n'en est pas vraiment une.
le script est de l'époque de la CS2, j'ai fait quelques progrès depuis.
Il fonctionne de deux manières:
A un ratio variant de 0 Ã 1.
B En fixant la longueur des lignes directrices en points (toutes le lignes auront la même longueur).
Vous pouvez passer d'un mode à l'autre en modifiant dans la zone init du script la variable fixe = true ou false
René
PS Je peux éventuellement améliorer l'interface avec une boîte de dialogue.
Me le demander par mail.
Exemples:
Tracé d’origine en position centrale (échelle réduite)
composé de 24 points
Option fixe permet de faire en sorte que la longueur des lignes directrices de gauche de droite
soient de même longueur (donnée en pt)
On peut également demander à ne pas traiter les extrémités des tracés ouverts.
Copy link to clipboard
Copied
Beautiful, René.
Thanks for contributing.
Copy link to clipboard
Copied
Wonderful script, @renél80416020! Thanks for sharing.
- Mark
Copy link to clipboard
Copied
wow, Sergey, thanks so much for the link to Jim Heck's script!
I had already looked at Hiroyuki's script, which is awesome but not quite what I needed.
I had started doodling with something along the same lines of Jims approach but got pretty overwhelmed by the maths.
I am constantly amazed by the generosity of these script writers, to share their work and also to annotate thier code so clearly for lowly mortals like myself... when the interent actually does something good, huzzah
Copy link to clipboard
Copied
I support what you say. One of the users of my scripts said to me: "People who give these little useful things away for free are the fading heartbeat of the internet". And those were important words.