Skip to content
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

Fix free draw positioning #5718

Merged
merged 8 commits into from
Jun 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changed
  • Loading branch information
asturur committed Jun 1, 2019
commit ac20b06470e29265a46cad506c0fa1a1cee4cfb5
6 changes: 5 additions & 1 deletion src/brushes/pencil_brush.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @type Number
* @default 0.5
*/
decimate: 1,
decimate: 0.4,

/**
* Constructor
Expand Down Expand Up @@ -227,6 +227,9 @@
* Decimate poins array with the decimate value
*/
decimatePoints: function(points, distance) {
if (points.length <= 2) {
return points;
}
var zoom = this.canvas.getZoom(), adjustedDistance = Math.pow(distance / zoom, 2),
i, l = points.length - 1, lastPoint = points[0], newPoints = [lastPoint],
cDistance;
Expand All @@ -251,6 +254,7 @@
if (this.decimate) {
this._points = this.decimatePoints(this._points, this.decimate);
}
console.log(JSON.stringify(this._points.map(p => ({ x: fabric.util.toFixed(p.x,3), y: fabric.util.toFixed(p.y,3) }))));
var pathData = this.convertPointsToSVGPath(this._points).join('');
if (pathData === 'M 0 0 Q 0 0 0 0 L 0 0') {
// do not create 0 width/height paths, as they are
Expand Down