paperjs / paper.js

The Swiss Army Knife of Vector Graphics Scripting – Scriptographer ported to JavaScript and the browser, using HTML5 Canvas. Created by @lehni & @puckey
http://paperjs.org
Other
14.54k stars 1.23k forks source link

How I can create a central line of path? #1701

Open tolyanor opened 5 years ago

tolyanor commented 5 years ago

I have path like letter:

image

I have only black path (contour). Pink in the middle i must generate. Pink path must be a monolinear and not closed, so paperjs-offset is no resolve my problem.

How I can do this? Thanks!

eeropic commented 5 years ago

Look into "Medial Axis Transforms", "Straight Skeletons" for more information, here's a library I've been wanting to try out for the same purposes, yet haven't had time

Might be a bit overkill, more useful for handling noisy polygon boundaries.

https://github.com/FlorisSteenkamp/MAT

eeropic commented 5 years ago

You could also try Lehni's work in progress code, here might be easier to leave out the 2nd offset curve expanding to another direction. https://github.com/paperjs/paper.js/issues/371#issuecomment-487443847