Initial Implementation for Pencil Tool (Freehand Drawing)#679
Open
AshishS-1123 wants to merge 9 commits intoakiraux:mainfrom
Open
Initial Implementation for Pencil Tool (Freehand Drawing)#679AshishS-1123 wants to merge 9 commits intoakiraux:mainfrom
AshishS-1123 wants to merge 9 commits intoakiraux:mainfrom
Conversation
mbfraga
requested changes
Dec 18, 2021
Collaborator
mbfraga
left a comment
There was a problem hiding this comment.
I have not yet reviewed the FreehandMode. There seems to be some general bugginess with some specific traces. Other times it works really nicely. Not sure what exactly triggers the bad behavior. See the screenshot below, where the blue represents roughly the trace I did with my mouse--and the black the result.

.
| cr.curve_to (x1, y1, x3, y3, x4, y4); | ||
|
|
||
| point_idx += 4; | ||
| } else if (commands[i] == Lib.Modes.PathEditMode.Type.BEZIER) { |
Collaborator
There was a problem hiding this comment.
I don't understand the difference between CURVE and Bezier--they are both drawing beziers.
| return Geometry.Point (x * val, y * val); | ||
| } | ||
|
|
||
| public double distance (Point pt) { |
Collaborator
There was a problem hiding this comment.
we should probably add a distance_squared for distance comparisons--so we don't have to do sqrt when not necessary.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / How this PR fixes the problem?
The Pencil Tool will allow users to draw freehand shapes and squiggles.
When drawing such a canvas item, all the users pointer events would be captured and stored. When rendering these points, we join them using a polyline. While this makes the task of creating such squiggles easy, storing large amounts of points becomes a problem.
To reduce the number of points, we use Schneider's Algorithm. This algorithm will compress the set of points into a set of bezier curves that are very close to what the user originally drew.
Using this algorithm will do two things-
Reference
Summary of major changes I made
Steps to Test
Por use the Insert menu to start the pencil tool.Screenshots
freehand.mp4
Known Issues / Things To Do