Last active
June 24, 2019 17:28
-
-
Save anotherjesse/29310476a5ef6e12fc89a32c7621c304 to your computer and use it in GitHub Desktop.
use with http://sketch.paperjs.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function smoother(path) { | |
| var geometric = false; | |
| for (var factor=0.1; factor < 4.0; factor += 0.1) { | |
| var np = path.clone() | |
| np.smooth({type: geometric ? 'geometric' : 'catmull-rom', factor: factor}) | |
| np.position.y += factor * 10 | |
| } | |
| } | |
| function onMouseDown(event) { | |
| // The mouse was clicked, so let's put a newly created Path into | |
| // myPath, give it the color black and add the location as the | |
| // path's first segment. | |
| project.clear() | |
| myPath = new Path(); | |
| myPath.strokeColor = 'black'; | |
| myPath.add(event.point); | |
| } | |
| function onMouseDrag(event) { | |
| myPath.add(event.point); | |
| } | |
| function onMouseUp(event) { | |
| // The mouse was released, so we add the new location as the end | |
| // segment of the line. | |
| myPath.add(event.point); | |
| myPath.simplify(); | |
| myPath.simplify(); | |
| smoother(myPath) | |
| myPath.remove(); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use this in http://sketch.paperjs.org