From 84f5e5abe38ce779a9d5ef799f6764277924a846 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 2 Dec 2017 20:21:56 +0100 Subject: [PATCH] Fix path shifting and inability to draw dots on 1.7 (#4525) * fix paths * fixed tests * restored dist * right limit --- src/brushes/pencil_brush.class.js | 11 ++++++++--- test/unit/group.js | 1 - test/unit/object.js | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/brushes/pencil_brush.class.js b/src/brushes/pencil_brush.class.js index 6fa47488..8b7bed15 100644 --- a/src/brushes/pencil_brush.class.js +++ b/src/brushes/pencil_brush.class.js @@ -146,7 +146,7 @@ var path = [], i, width = this.width / 1000, p1 = new fabric.Point(points[0].x, points[0].y), p2 = new fabric.Point(points[1].x, points[1].y), - len = points.length, multSignX, multSignY, manyPoints = len > 2; + len = points.length, multSignX = 1, multSignY = 1, manyPoints = len > 2; if (manyPoints) { multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1; @@ -187,9 +187,14 @@ strokeLineCap: this.strokeLineCap, strokeLineJoin: this.strokeLineJoin, strokeDashArray: this.strokeDashArray, + originX: 'center', + originY: 'center' }); - var position = new fabric.Point(path.left + path.width / 2, path.top + path.height / 2); - position = path.translateToGivenOrigin(position, 'center', 'center', path.originX, path.originY); + var position = new fabric.Point(path.left, path.top); + path.originX = fabric.Object.prototype.originX; + path.originY = fabric.Object.prototype.originY; + position = path.translateToGivenOrigin( + position, 'center', 'center', path.originX, path.originY); path.top = position.y; path.left = position.x; if (this.shadow) { diff --git a/test/unit/group.js b/test/unit/group.js index afb73afc..9fc0ad87 100644 --- a/test/unit/group.js +++ b/test/unit/group.js @@ -417,7 +417,6 @@ var groupObject = group.toObject(); fabric.Group.fromObject(groupObject, function(newGroupFromObject) { - console.log(newGroupFromObject._objects[0]); ok(newGroupFromObject._objects[0].oCoords.tl, 'acoords 0 are restored'); ok(newGroupFromObject._objects[1].oCoords.tl, 'acoords 1 are restored'); diff --git a/test/unit/object.js b/test/unit/object.js index 861dd7ef..5d541853 100644 --- a/test/unit/object.js +++ b/test/unit/object.js @@ -1228,7 +1228,7 @@ }); test('_limitCacheSize limit min to 256', function() { - fabric.perfLimitSizeTotal = 10000; + fabric.perfLimitSizeTotal = 60000; fabric.maxCacheSideLimit = 4096; fabric.minCacheSideLimit = 256; var object = new fabric.Object({ width: 200, height: 200, strokeWidth: 0 }); @@ -1237,8 +1237,8 @@ var zoomY = dims.zoomY; var limitedDims = object._limitCacheSize(dims); equal(dims, limitedDims, 'object is mutated'); - equal(dims.width, 256, 'width gets minimum to the cacheSideLimit'); - equal(dims.height, 256, 'height gets minimum to the cacheSideLimit'); + equal(limitedDims.width, 256, 'width gets minimum to the cacheSideLimit'); + equal(limitedDims.height, 256, 'height gets minimum to the cacheSideLimit'); equal(zoomX, dims.zoomX, 'zoom factor X does not need a change'); equal(zoomY, dims.zoomY, 'zoom factor Y does not need a change'); });