-
-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial Implementation for Pencil Tool (Freehand Drawing) #679
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
.
@@ -72,6 +72,23 @@ public class Akira.Drawables.DrawablePath : Drawable { | |||
cr.curve_to (x0, y0, x2, y2, x1, y1); | |||
cr.curve_to (x1, y1, x3, y3, x4, y4); | |||
|
|||
point_idx += 4; | |||
} else if (commands[i] == Lib.Modes.PathEditMode.Type.BEZIER) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably add a distance_squared for distance comparisons--so we don't have to do sqrt when not necessary.
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
P
or use the Insert menu to start the pencil tool.Screenshots
freehand.mp4
Known Issues / Things To Do