From 6cf8e3e751882e4a474e6bee829802137210a9bb Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 30 Apr 2023 00:46:50 +0200 Subject: [PATCH 1/5] removed goofy code --- src/shapes/Line.ts | 105 ++++++---------------------- test/unit/line.js | 166 +++++---------------------------------------- 2 files changed, 37 insertions(+), 234 deletions(-) diff --git a/src/shapes/Line.ts b/src/shapes/Line.ts index ae66fecbc2e..2c6f3d47f2a 100644 --- a/src/shapes/Line.ts +++ b/src/shapes/Line.ts @@ -11,6 +11,7 @@ import type { TProps, } from './Object/types'; import type { ObjectEvents } from '../EventTypeDefs'; +import { makeBoundingBoxFromPoints } from '../util'; // @TODO this code is terrible and Line should be a special case of polyline. @@ -70,24 +71,28 @@ export class Line< * @param {Object} [options] Options object * @return {Line} thisArg */ - constructor(points = [0, 0, 0, 0], options: Props = {} as Props) { - super(options); - this.x1 = points[0]; - this.y1 = points[1]; - this.x2 = points[2]; - this.y2 = points[3]; - this._setWidthHeight(options); + constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Props = {} as Props) { + super({ ...options, x1, y1, x2, y2 }); + this._setWidthHeight(); + const { left, top } = options; + typeof left === 'number' && this.set('left', left); + typeof top === 'number' && this.set('top', top); } /** * @private * @param {Object} [options] Options */ - _setWidthHeight({ left, top }: Partial = {}) { - this.width = Math.abs(this.x2 - this.x1); - this.height = Math.abs(this.y2 - this.y1); - this.left = left ?? this._getLeftToOriginX(); - this.top = top ?? this._getTopToOriginY(); + _setWidthHeight() { + const { x1, y1, x2, y2 } = this; + this.width = Math.abs(x2 - x1); + this.height = Math.abs(y2 - y1); + const { left, top, width, height } = makeBoundingBoxFromPoints([ + { x: x1, y: y1 }, + { x: x2, y: y2 }, + ]); + const position = new Point(left + width / 2, top + height / 2); + this.setPositionByOrigin(position, 'center', 'center'); } /** @@ -98,6 +103,9 @@ export class Line< _set(key: string, value: any) { super._set(key, value); if (coordProps.includes(key as keyof UniqueLineProps)) { + // this doesn't make sense anymore, since setting x1 when top or left + // are already set, is just going to show a strange result since the + // line will move way more than the developer expect this._setWidthHeight(); } return this; @@ -192,77 +200,6 @@ export class Line< }; } - private makeEdgeToOriginGetter( - propertyNames: any, - originValues: any - ): number { - const origin = propertyNames.origin, - axis1 = propertyNames.axis1, - axis2 = propertyNames.axis2, - dimension = propertyNames.dimension, - nearest = originValues.nearest, - center = originValues.center, - farthest = originValues.farthest; - - switch (this.get(origin)) { - case nearest: - return Math.min(this.get(axis1), this.get(axis2)); - case center: - return ( - Math.min(this.get(axis1), this.get(axis2)) + 0.5 * this.get(dimension) - ); - case farthest: - return Math.max(this.get(axis1), this.get(axis2)); - // this should never occurr, since origin is always either one of the 3 above - default: - return 0; - } - } - - /** - * @private - * @return {Number} leftToOriginX Distance from left edge of canvas to originX of Line. - */ - _getLeftToOriginX(): number { - return this.makeEdgeToOriginGetter( - { - // property names - origin: 'originX', - axis1: 'x1', - axis2: 'x2', - dimension: 'width', - }, - { - // possible values of origin - nearest: 'left', - center: 'center', - farthest: 'right', - } - ); - } - - /** - * @private - * @return {Number} leftToOriginX Distance from left edge of canvas to originX of Line. - */ - _getTopToOriginY(): number { - return this.makeEdgeToOriginGetter( - { - // property names - origin: 'originY', - axis1: 'y1', - axis2: 'y2', - dimension: 'height', - }, - { - // possible values of origin - nearest: 'top', - center: 'center', - farthest: 'bottom', - } - ); - } - /** * Returns svg representation of an instance * @return {Array} an array of strings with the specific svg representation @@ -305,7 +242,7 @@ export class Line< */ static fromElement(element: SVGElement, callback: (line: Line) => any) { const parsedAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES), - points = [ + points: [number, number, number, number] = [ parsedAttributes.x1 || 0, parsedAttributes.y1 || 0, parsedAttributes.x2 || 0, diff --git a/test/unit/line.js b/test/unit/line.js index f44fb5da373..3d368eaf298 100644 --- a/test/unit/line.js +++ b/test/unit/line.js @@ -180,12 +180,24 @@ var lineCoordsCases = [ { description: 'default to 0 left and 0 top', - givenLineArgs: {}, + givenLineArgs: { + options: { + strokeWidth: 0, + } + }, expectedCoords: { left: 0, top: 0, } }, + { description: 'default to 0 left and 0 top and default strokeWidth of 1', + givenLineArgs: { + }, + expectedCoords: { + left: -0.5, + top: -0.5, + } + }, { description: 'origin defaults to left-top', givenLineArgs: { points: [0, 0, 11, 22], @@ -210,7 +222,7 @@ }, { description: 'include offsets for left-top origin', givenLineArgs: { - points: [0 + 33, 0 + 44, 11 + 33, 22 + 44], + points: [33, 44, 44, 66], options: { originX: 'left', originY: 'top', @@ -253,6 +265,7 @@ options: { originX: 'right', originY: 'bottom', + strokeWidth: 0, }, }, expectedCoords: { @@ -264,6 +277,7 @@ givenLineArgs: { points: [0 - 3.14, 0 - 1.41, 55 - 3.14, 18 - 1.41], options: { + strokeWidth: 0, originX: 'right', originY: 'bottom', }, @@ -456,152 +470,4 @@ }); }); - var getLeftToOriginXCases = [ - { description: 'is x1 for left origin and x1 lesser than x2', - givenOrigin: 'left', - givenPoints: [0, 0, 1, 0], - expectedLeft: 0, - }, - { description: 'is x2 for left origin and x1 greater than x2', - givenOrigin: 'left', - givenPoints: [1, 0, 0, 0], - expectedLeft: 0, - }, - { description: 'includes positive offset for left origin', - givenOrigin: 'left', - givenPoints: [0 + 20, 0, 1 + 20, 0], - expectedLeft: 0 + 20, - }, - { description: 'includes negative offset for left origin', - givenOrigin: 'left', - givenPoints: [0 - 11, 0, 1 - 11, 0], - expectedLeft: 0 - 11, - }, - { description: 'is half of x1 for center origin and x1 > x2', - givenOrigin: 'center', - givenPoints: [4, 0, 0, 0], - expectedLeft: 0.5 * 4, - }, - { description: 'is half of x2 for center origin and x1 < x2', - givenOrigin: 'center', - givenPoints: [0, 0, 7, 0], - expectedLeft: 0.5 * 7, - }, - { description: 'includes positive offset for center origin', - givenOrigin: 'center', - givenPoints: [0 + 39, 0, 7 + 39, 0], - expectedLeft: (0.5 * 7) + 39, - }, - { description: 'includes negative offset for center origin', - givenOrigin: 'center', - givenPoints: [4 - 13, 0, 0 - 13, 0], - expectedLeft: (0.5 * 4) - 13, - }, - { description: 'is x1 for right origin and x1 > x2', - givenOrigin: 'right', - givenPoints: [9, 0, 0, 0], - expectedLeft: 9, - }, - { description: 'is x2 for right origin and x1 < x2', - givenOrigin: 'right', - givenPoints: [0, 0, 6, 0], - expectedLeft: 6, - }, - { description: 'includes positive offset for right origin', - givenOrigin: 'right', - givenPoints: [0 + 47, 0, 6 + 47, 0], - expectedLeft: 6 + 47, - }, - { description: 'includes negative offset for right origin', - givenOrigin: 'right', - givenPoints: [9 - 17, 0, 0 - 17, 0], - expectedLeft: 9 - 17, - }, - ]; - - getLeftToOriginXCases.forEach(function (c_) { - QUnit.test('Line.getLeftToOriginX() ' + c_.description, function (assert) { - var line = new fabric.Line( - c_.givenPoints, - { originX: c_.givenOrigin } - ); - - assert.equal(line._getLeftToOriginX(), c_.expectedLeft); - }); - }); - - var getTopToOriginYCases = [ - { description: 'is y1 for top origin and y1 lesser than y2', - givenOrigin: 'top', - givenPoints: [0, 0, 0, 1], - expectedTop: 0, - }, - { description: 'is y2 for top origin and y1 greater than y2', - givenOrigin: 'top', - givenPoints: [0, 1, 0, 0], - expectedTop: 0, - }, - { description: 'includes positive offset for top origin', - givenOrigin: 'top', - givenPoints: [0, 0 + 20, 0, 1 + 20], - expectedTop: 0 + 20, - }, - { description: 'includes negative offset for top origin', - givenOrigin: 'top', - givenPoints: [0, 0 - 11, 0, 1 - 11], - expectedTop: 0 - 11, - }, - { description: 'is half of y1 for center origin and y1 > y2', - givenOrigin: 'center', - givenPoints: [0, 4, 0, 0], - expectedTop: 0.5 * 4, - }, - { description: 'is half of y2 for center origin and y1 < y2', - givenOrigin: 'center', - givenPoints: [0, 0, 0, 7], - expectedTop: 0.5 * 7, - }, - { description: 'includes positive offset for center origin', - givenOrigin: 'center', - givenPoints: [0, 0 + 39, 0, 7 + 39], - expectedTop: (0.5 * 7) + 39, - }, - { description: 'includes negative offset for center origin', - givenOrigin: 'center', - givenPoints: [0, 4 - 13, 0, 0 - 13], - expectedTop: (0.5 * 4) - 13, - }, - { description: 'is y1 for bottom origin and y1 > y2', - givenOrigin: 'bottom', - givenPoints: [0, 9, 0, 0], - expectedTop: 9, - }, - { description: 'is y2 for bottom origin and y1 < y2', - givenOrigin: 'bottom', - givenPoints: [0, 0, 0, 6], - expectedTop: 6, - }, - { description: 'includes positive offset for bottom origin', - givenOrigin: 'bottom', - givenPoints: [0, 0 + 47, 0, 6 + 47], - expectedTop: 6 + 47, - }, - { description: 'includes negative offset for bottom origin', - givenOrigin: 'bottom', - givenPoints: [0, 9 - 17, 0, 0 - 17], - expectedTop: 9 - 17, - }, - ]; - - getTopToOriginYCases.forEach(function (c_) { - QUnit.test('Line._getTopToOriginY() ' + c_.description, function (assert) { - var line = new fabric.Line( - c_.givenPoints, - { originY: c_.givenOrigin } - ); - - assert.equal(line._getTopToOriginY(), c_.expectedTop); - }); - }); - })(); From ab39bc1245f073d6b1ea4dac7723b09652060167 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Mon, 1 May 2023 12:10:50 +0200 Subject: [PATCH 2/5] more es6 --- src/shapes/Line.ts | 54 +++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/src/shapes/Line.ts b/src/shapes/Line.ts index 2c6f3d47f2a..eaca58a3771 100644 --- a/src/shapes/Line.ts +++ b/src/shapes/Line.ts @@ -103,7 +103,7 @@ export class Line< _set(key: string, value: any) { super._set(key, value); if (coordProps.includes(key as keyof UniqueLineProps)) { - // this doesn't make sense anymore, since setting x1 when top or left + // this doesn't make sense very much, since setting x1 when top or left // are already set, is just going to show a strange result since the // line will move way more than the developer expect this._setWidthHeight(); @@ -185,45 +185,38 @@ export class Line< * @private */ calcLinePoints(): UniqueLineProps { - const xMult = this.x1 <= this.x2 ? -1 : 1, - yMult = this.y1 <= this.y2 ? -1 : 1, - x1 = xMult * this.width * 0.5, - y1 = yMult * this.height * 0.5, - x2 = xMult * this.width * -0.5, - y2 = yMult * this.height * -0.5; + const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this; + const xMult = _x1 <= _x2 ? -1 : 1, + yMult = _y1 <= _y2 ? -1 : 1, + x1 = (xMult * width) / 2, + y1 = (yMult * height) / 2, + x2 = (xMult * -width) / 2, + y2 = (yMult * -height) / 2; return { - x1: x1, - x2: x2, - y1: y1, - y2: y2, + x1, + x2, + y1, + y2, }; } + /* _FROM_SVG_START_ */ + /** * Returns svg representation of an instance * @return {Array} an array of strings with the specific svg representation * of the instance */ _toSVG() { - const p = this.calcLinePoints(); + const { x1, x2, y1, y2 } = this.calcLinePoints(); return [ '\n', + `x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" />\n`, ]; } - /* _FROM_SVG_START_ */ - /** * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement}) * @static @@ -241,13 +234,14 @@ export class Line< * @param {Function} [callback] callback function invoked after parsing */ static fromElement(element: SVGElement, callback: (line: Line) => any) { - const parsedAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES), - points: [number, number, number, number] = [ - parsedAttributes.x1 || 0, - parsedAttributes.y1 || 0, - parsedAttributes.x2 || 0, - parsedAttributes.y2 || 0, - ]; + const { + x1 = 0, + y1 = 0, + x2 = 0, + y2 = 0, + ...parsedAttributes + } = parseAttributes(element, this.ATTRIBUTE_NAMES), + points: [number, number, number, number] = [x1, y1, x2, y2]; callback(new this(points, parsedAttributes)); } From 8c69ee1d12dca4aada747ea324832cfc597afbd1 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Mon, 1 May 2023 14:53:03 +0200 Subject: [PATCH 3/5] new line tests --- test/unit/line.js | 321 +++------------------------------------------- 1 file changed, 20 insertions(+), 301 deletions(-) diff --git a/test/unit/line.js b/test/unit/line.js index 3d368eaf298..e355ab115ce 100644 --- a/test/unit/line.js +++ b/test/unit/line.js @@ -5,8 +5,8 @@ type: 'Line', originX: 'left', originY: 'top', - left: 11, - top: 12, + left: 10.5, + top: 11.5, width: 2, height: 2, fill: 'rgb(0,0,0)', @@ -69,7 +69,7 @@ QUnit.test('toSVG', function(assert) { var line = new fabric.Line([11, 12, 13, 14]); - var EXPECTED_SVG = '\n\n\n'; + var EXPECTED_SVG = '\n\n\n'; assert.equal(line.toSVG(), EXPECTED_SVG); }); @@ -169,304 +169,23 @@ }); }); - // this isn't implemented yet, so disabling for now - - // QUnit.test('x1,y1 less than x2,y2 should work', function(assert) { - // var line = new fabric.Line([ 400, 200, 300, 400]); - - // assert.equal(100, line.width); - // assert.equal(200, line.height); - // }); - - var lineCoordsCases = [ - { description: 'default to 0 left and 0 top', - givenLineArgs: { - options: { - strokeWidth: 0, - } - }, - expectedCoords: { - left: 0, - top: 0, - } - }, - { description: 'default to 0 left and 0 top and default strokeWidth of 1', - givenLineArgs: { - }, - expectedCoords: { - left: -0.5, - top: -0.5, - } - }, - { description: 'origin defaults to left-top', - givenLineArgs: { - points: [0, 0, 11, 22], - }, - expectedCoords: { - left: 0, - top: 0, - } - }, - { description: 'equal smallest points when origin is left-top and line not offset', - givenLineArgs: { - points: [0, 0, 12.3, 34.5], - options: { - originX: 'left', - originY: 'top', - }, - }, - expectedCoords: { - left: 0, - top: 0, - } - }, - { description: 'include offsets for left-top origin', - givenLineArgs: { - points: [33, 44, 44, 66], - options: { - originX: 'left', - originY: 'top', - }, - }, - expectedCoords: { - left: 33, - top: 44, - } - }, - { description: 'equal half-dimensions when origin is center and line not offset', - givenLineArgs: { - points: [0, 0, 12.3, 34.5], - options: { - originX: 'center', - originY: 'center', - }, - }, - expectedCoords: { - left: 0.5 * 12.3, - top: 0.5 * 34.5, - } - }, - { description: 'include offsets for center-center origin', - givenLineArgs: { - points: [0 + 9.87, 0 - 4.32, 12.3 + 9.87, 34.5 - 4.32], - options: { - originX: 'center', - originY: 'center', - }, - }, - expectedCoords: { - left: (0.5 * 12.3) + 9.87, - top: (0.5 * 34.5) - 4.32, - } - }, - { description: 'equal full dimensions when origin is right-bottom and line not offset', - givenLineArgs: { - points: [0, 0, 55, 18], - options: { - originX: 'right', - originY: 'bottom', - strokeWidth: 0, - }, - }, - expectedCoords: { - left: 55, - top: 18, - } - }, - { description: 'include offsets for right-bottom origin', - givenLineArgs: { - points: [0 - 3.14, 0 - 1.41, 55 - 3.14, 18 - 1.41], - options: { - strokeWidth: 0, - originX: 'right', - originY: 'bottom', - }, - }, - expectedCoords: { - left: 55 - 3.14, - top: 18 - 1.41, - } - }, - { description: 'arent changed by rotation for left-top origin', - givenLineArgs: { - points: [1, 2, 30, 40], - options: { - originX: 'left', - originY: 'top', - angle: 67, - } - }, - expectedCoords: { - left: 1, - top: 2, - } - }, - { description: 'arent changed by rotation for right-bottom origin', - givenLineArgs: { - points: [1, 2, 30, 40], - options: { - originX: 'right', - originY: 'bottom', - angle: 67, - } - }, - expectedCoords: { - left: 30, - top: 40, - } - }, - { description: 'arent changed by scaling for left-top origin', - givenLineArgs: { - points: [1, 2, 30, 40], - options: { - originX: 'left', - originY: 'top', - scale: 2.1, - } - }, - expectedCoords: { - left: 1, - top: 2, - } - }, - { description: 'arent changed by scaling for right-bottom origin', - givenLineArgs: { - points: [1, 2, 30, 40], - options: { - originX: 'right', - originY: 'bottom', - scale: 1.2, - } - }, - expectedCoords: { - left: 30, - top: 40, - } - }, - { description: 'arent changed by strokeWidth for left-top origin', - givenLineArgs: { - points: [31, 41, 59, 26], - options: { - originX: 'left', - originY: 'top', - stroke: 'black', - strokeWidth: '53' - } - }, - expectedCoords: { - left: 31, - top: 26, - } - }, - { description: 'arent changed by strokeWidth for center-center origin', - givenLineArgs: { - points: [0 + 31, 15 + 26, 28 + 31, 0 + 26], - options: { - originX: 'center', - originY: 'center', - stroke: 'black', - strokeWidth: '53' - } - }, - expectedCoords: { - left: (0.5 * 28) + 31, - top: (0.5 * 15) + 26, - } - }, - { description: 'arent changed by strokeWidth for right-bottom origin', - givenLineArgs: { - points: [1, 2, 30, 40], - options: { - originX: 'right', - originY: 'bottom', - stroke: 'black', - strokeWidth: '53' - } - }, - expectedCoords: { - left: 30, - top: 40, - } - }, - { description: 'left and top options override points', - givenLineArgs: { - points: [12, 34, 56, 78], - options: { - left: 98, - top: 76, - } - }, - expectedCoords: { - left: 98, - top: 76, - } - }, - { description: '0 left and 0 top options override points', - givenLineArgs: { - points: [12, 34, 56, 78], - options: { - left: 0, - top: 0, - } - }, - expectedCoords: { - left: 0, - top: 0, - } - }, - { description: 'equal x2 and y2 for left-top origin when x1 and y1 are largest and line not offset', - givenLineArgs: { - points: [100, 200, 30, 40], - options: { - originX: 'left', - originY: 'top', - } - }, - expectedCoords: { - left: 30, - top: 40, - } - }, - { description: 'equal half-dimensions for center-center origin when x1 and y1 are largest and line not offset', - givenLineArgs: { - points: [100, 200, 0, 0], - options: { - originX: 'center', - originY: 'center', - } - }, - expectedCoords: { - left: 0.5 * 100, - top: 0.5 * 200, - } - }, - { description: 'equal x1 and y1 for right-bottom origin when x1 and y1 are largest and line not offset', - givenLineArgs: { - points: [100, 200, 0, 0], - options: { - originX: 'right', - originY: 'bottom', - } - }, - expectedCoords: { - left: 100, - top: 200, - } - }, - ]; - - lineCoordsCases.forEach(function (c_) { - QUnit.test('stroke-less line coords ' + c_.description, function(assert) { - var points = c_.givenLineArgs.points; - var options = c_.givenLineArgs.options; - - var givenLine = new fabric.Line( - points, - options - ); - - assert.equal(givenLine.left, c_.expectedCoords.left); - assert.equal(givenLine.top, c_.expectedCoords.top); + ['left', 'center', 'right'].forEach((originX) => { + ['top', 'center', 'bottom'].forEach((originY) => { + [0, 7].forEach((strokeWidth) => { + [0, 33, 90].forEach((angle) => { + QUnit.test(`Regardless of strokeWidth or origin, a line is always positioned on its center when left/top are not specified (${originX}/${originY} stroke:${strokeWidth} angle:${angle})`, function(assert) { + const line = new fabric.Line([1, 1, 15, 7], { + strokeWidth, + originX, + originY, + angle, + }); + const center = line.getCenterPoint(); + assert.equal(Math.round(center.x), 8); + assert.equal(Math.round(center.y), 4); + }); + }); + }); }); }); From c9d8096f86de63036de13888752e9f2529c63822 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Mon, 1 May 2023 15:29:58 +0200 Subject: [PATCH 4/5] more test --- src/shapes/Line.ts | 8 +++++++- test/unit/line.js | 21 ++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/shapes/Line.ts b/src/shapes/Line.ts index eaca58a3771..1e6cd320e38 100644 --- a/src/shapes/Line.ts +++ b/src/shapes/Line.ts @@ -105,7 +105,10 @@ export class Line< if (coordProps.includes(key as keyof UniqueLineProps)) { // this doesn't make sense very much, since setting x1 when top or left // are already set, is just going to show a strange result since the - // line will move way more than the developer expect + // line will move way more than the developer expect. + // in fabric5 it worked only when the line didn't have extra transformations, + // in fabric6 too. With extra transform they behave bad in different ways. + // This needs probably a good rework or a tutorial if you have to create a dynamic line this._setWidthHeight(); } return this; @@ -182,6 +185,9 @@ export class Line< /** * Recalculates line points given width and height + * Those points are simply placed around the center, + * This is not useful outside internal render functions and svg output + * Is not meant to be for the developer. * @private */ calcLinePoints(): UniqueLineProps { diff --git a/test/unit/line.js b/test/unit/line.js index e355ab115ce..3465688ef10 100644 --- a/test/unit/line.js +++ b/test/unit/line.js @@ -173,16 +173,19 @@ ['top', 'center', 'bottom'].forEach((originY) => { [0, 7].forEach((strokeWidth) => { [0, 33, 90].forEach((angle) => { - QUnit.test(`Regardless of strokeWidth or origin, a line is always positioned on its center when left/top are not specified (${originX}/${originY} stroke:${strokeWidth} angle:${angle})`, function(assert) { - const line = new fabric.Line([1, 1, 15, 7], { - strokeWidth, - originX, - originY, - angle, + ['butt', 'round', 'square'].forEach((strokeLineCap) => { + QUnit.test(`Regardless of strokeWidth or origin, a line is always positioned on its center when left/top are not specified (${originX}/${originY} stroke:${strokeWidth} angle:${angle} cap:${strokeLineCap})`, function(assert) { + const line = new fabric.Line([1, 1, 15, 7], { + strokeWidth, + originX, + originY, + angle, + strokeLineCap, + }); + const center = line.getCenterPoint(); + assert.equal(Math.round(center.x), 8); + assert.equal(Math.round(center.y), 4); }); - const center = line.getCenterPoint(); - assert.equal(Math.round(center.x), 8); - assert.equal(Math.round(center.y), 4); }); }); }); From 2784d1746d21b639461c29e51e9941d12b1c0467 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 7 May 2023 00:57:05 +0200 Subject: [PATCH 5/5] master and changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f5bb3c73a..5d44f1b8ab8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## [6.0.0-beta5] +- refactor(fabric.Line): Line position is calculated from the center between the 2 points now [#8877](https://github.com/fabricjs/fabric.js/pull/8877) - bundle(): export `setEnv` for JEST interoperability [#8888](https://github.com/fabricjs/fabric.js/pull/8888) ## [6.0.0-beta4]