Created
December 21, 2019 22:47
-
-
Save anotherjesse/ac0a1a5b5a51864bb013aec55d68d507 to your computer and use it in GitHub Desktop.
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 < 2.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(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment