Path smooth on the fly, while user is drawing

276 views
Skip to first unread message

Joahim Van der Graff

unread,
Dec 21, 2016, 4:18:42 PM12/21/16
to Paper.js
Hello,

I just discovered the library and went over the documentation and examples. Overall, it looks amazing!
Here is my issue: I'm trying to create smooth lines (curves) while the user is drawing. So far (without paper.js), I'm smoothing them using `canvas.quadraticCurveTo()`. I'm doing that on `mouseUp` event.

Looking on paper.js examples, they follow the same logic - adding the points on `mouseMove` and then smoothing the path using `path.smooth` method on `mouseUp` event.

This is far from what the user would expect, that's why I'm trying to smooth them while the user is drawing. Is it possible with paper.js?

For the record, if you check the 'Bamboo Paper' application for a tablet for example (either for Android tablet or iPad), they create fantastic curves while the user is drawing. How is that possible?

Thanks,

Jürg Lehni

unread,
Dec 24, 2016, 6:32:01 AM12/24/16
to pap...@googlegroups.com
There’s nothing stopping you from calling smooth() after each adding of a new segment.

You can also tell smooth() to not process the full range, see 3rd example here:


J

--
You received this message because you are subscribed to the Google Groups "Paper.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joahim Van der Graff

unread,
Dec 24, 2016, 12:05:04 PM12/24/16
to Paper.js
That was the first thing I tried before to write here. However, it doesn't do it very well. It works fine if you make the path smooth on mouseUp, but not when doing it on each mouse move.
Reply all
Reply to author
Forward
0 new messages