codelastnight / to-path-figma

object and text to path, a figma plugin
https://www.figma.com/community/plugin/751576264585242935/To-Path
GNU General Public License v3.0
49 stars 6 forks source link
curve figma plugin tangent

In Progress: V 2.0

To-Path: A Figma Plugin

version badge

logo and info image

โœจ ๐™‹๐™ช๐™ฉ ๐™–๐™ฃ๐™ฎ ๐™ค๐™—๐™Ÿ๐™š๐™˜๐™ฉ๐™จ ๐™ค๐™ง ๐™ฉ๐™š๐™ญ๐™ฉ ๐™ค๐™ฃ ๐™– ๐™ฅ๐™–๐™ฉ๐™!โœจ

  1. select a curve
  2. select an object, group, or text
  3. hit "link" and watch the magic* happen

*Its janky code and its not actually magic

โ•ญโ”ˆโ”€โ”€โ”€โ”€โ”€โ”€โ”€ เณ„เพ€เฟ หŠหŽ-

โ•ฐโ”ˆโžค ๐™„๐™ˆ๐™‹๐™Š๐™๐™๐˜ผ๐™‰๐™

Version 1.5.0 and higher's revamped live updates WILL NOT work on previous linked paths made by this plugin! You must create a new linked path group!

โ˜† ใ‚œใƒปใ€‚ใ€‚ใƒปใ‚œใ‚œใƒปใ€‚ใ€‚ใƒปใ‚œ โ˜…

๐ŸŒ™ ๐™„๐™จ๐™จ๐™ช๐™š๐™จ ๐™ค๐™ง ๐™๐™š๐™–๐™ฉ๐™ช๐™ง๐™š ๐™๐™š๐™ฆ๐™ช๐™š๐™จ๐™ฉ๐™จ๐ŸŒ™

Open an issue on the github:

https://github.com/codelastnight/to-path-figma

โ˜† ใ‚œใƒปใ€‚ใ€‚ใƒปใ‚œใ‚œใƒปใ€‚ใ€‚ใƒปใ‚œ โ˜…

โค๏ธ ๐™‡๐™ž๐™ ๐™š ๐™ฌ๐™๐™–๐™ฉ ๐™„ ๐™™๐™ค? โค๏ธ

consider buying me a coffee :)

https://ko-fi.com/lastnight

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โœงโโœงโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

หš ใ€€ใ€€ใ€€ใ€€ใ€€ ใ€€ โŠน ใ€€ ใ€€ ใ€€ใ€€ใ€€ ใ€€ ยทใ€€ ใ€€ใ€€ โœง ใ€€ใ€€ใ€€ โ‹† ใ€€ใ€€ ยท . ยท . ใ€€ ใ€€ ยท ยทใ€€ ใ€€ใ€€ใ€€ใ€€ใ€€.. ใ€€ . . ใ€€ ใ€€ใ€€ใ€€ ยท + ใ€€ใ€€ใ€€ ใ€€ ยทใ€€ โœซ ใ€€ใ€€ โŠน หš ใ€€ใ€€ใ€€ ใ€€. . ใ€€ใ€€ใ€€ ใ€€ใ€€ยท ใ€€ โ‹† ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ ใ€€ใ€€ ใ€€ ใ€€ . ใ€€ใ€€ ใ€€ใ€€ ใ€€ใ€€ . ใ€€ ใ€€ . ยทใ€€ . ใ€€ ยท ใ€€ใ€€ใ€€ . ใ€€ ใ€€ ใ€€ ใ€€ ใ€€ ใ€€ ยท ใ€€ใ€€ใ€€ ใ€€ . ยท ใ€€ ยท + ใ€€. ใ€€ ใ€€ใ€€ใ€€ใ€€ ยท * หš ใ€€ใ€€ใ€€ ใ€€. . + ใ€€ใ€€ใ€€ ใ€€ใ€€ยท ใ€€ โ‹† ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ ใ€€ใ€€ ใ€€ ใ€€ . ใ€€ใ€€ ใ€€ใ€€ ใ€€ใ€€ . ใ€€ ใ€€ . ยทใ€€ . ใ€€ ยท ใ€€ใ€€ใ€€ . ใ€€ ใ€€ ใ€€ ใ€€ ใ€€

How it Works

  1. the plugin generates an array of points (420 between each point but you can also change this in the "about" menu) using castejau's algorithm that follows the curve, also finding the angle of the tangent of each point. the length from the start of the curve to each point is also generated and stored (find out more here: https://javascript.info/bezier-curve)

  2. the nth's object's x position + object width + spacing is calculated

  3. the plugin compares the x position of the object with the array of points. 2 points with closest length is picked

  4. then the plugin finds the point between those two points and finds the exact point to place the object. the angle used is just the tangent of the nearest point.

  5. the object is placed and the plugin moves onto the next object.

development setup

  1. install packages: npm i

  2. compile : npm run prod

mfw someone else already put out something similar to my plugin but i spent too much time on this to stop now.