Skip to content
Merged
Show file tree
Hide file tree
Changes from 161 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
c14e307
fix(): test with missing golden running from CI should fail
ShaMan123 Sep 23, 2022
f98ec94
Update visualTestLoop.js
ShaMan123 Sep 23, 2022
0b44c00
Update visualTestLoop.js
ShaMan123 Sep 23, 2022
69c5663
Update visualTestLoop.js
ShaMan123 Sep 23, 2022
d392ced
Update visualTestLoop.js
ShaMan123 Sep 23, 2022
9b13464
Update visualTestLoop.js
ShaMan123 Sep 23, 2022
7e0ed21
Update CHANGELOG.md
ShaMan123 Sep 23, 2022
51b2590
Update visualTestLoop.js
ShaMan123 Sep 23, 2022
3d3922c
test ci
ShaMan123 Sep 23, 2022
6ee4cf1
Update visualTestLoop.js
ShaMan123 Sep 23, 2022
2d451bc
Revert "test ci"
ShaMan123 Sep 23, 2022
ed66b81
WIP
ShaMan123 Oct 12, 2022
0e5305a
Merge branch 'master' into fix-skewing-controls
ShaMan123 Oct 12, 2022
6501cfa
test(stroke projection): separating the goldens from this commit
Oct 16, 2022
58a68d5
goldens
Oct 16, 2022
e269b33
refactor(stroke_projection): fewer test cases, but more focused on bo…
Oct 17, 2022
caf092a
goldens after refactor
Oct 17, 2022
5d8fe2f
reset freedrawing
Oct 17, 2022
0fedc30
es6
ShaMan123 Oct 17, 2022
c4633cb
Merge branch 'master' into fix-skewing-controls
ShaMan123 Oct 17, 2022
8e512f6
fix(): stroke line cap and size of goldens
Oct 18, 2022
b9a5582
goldens
Oct 18, 2022
9959da6
`isOpen`
ShaMan123 Oct 18, 2022
37e6a22
Revert "`isOpen`"
ShaMan123 Oct 18, 2022
e30dd32
fix skewing
ShaMan123 Oct 18, 2022
465149f
Update controls_handlers.js
ShaMan123 Oct 18, 2022
95b8b39
Update CHANGELOG.md
ShaMan123 Oct 18, 2022
06cdb64
fix(): use set
ShaMan123 Oct 18, 2022
793df67
Update object.class.ts
ShaMan123 Oct 18, 2022
c6f000d
Update controls.actions.ts
ShaMan123 Oct 18, 2022
d4996d1
ws
ShaMan123 Oct 18, 2022
606df66
fix(): flip assignment
ShaMan123 Oct 18, 2022
cdc2c5e
goldens
ShaMan123 Oct 18, 2022
c1f21d1
revert(): svg stuff
ShaMan123 Oct 18, 2022
aa48a3b
cleanup
ShaMan123 Oct 18, 2022
4e84453
Update object.class.ts
ShaMan123 Oct 18, 2022
40b8892
getAcuteAngleFactor => StrokeLineJoinProjections.getOrthogonalRotatio…
ShaMan123 Oct 18, 2022
5ee4741
fix(): restore `compensateScaleForSkew`
ShaMan123 Oct 18, 2022
cf395b4
cleanup
ShaMan123 Oct 18, 2022
22abcc6
cleanup compensate
ShaMan123 Oct 18, 2022
3f4720a
rename
ShaMan123 Oct 18, 2022
dc482f5
WIP compensation
ShaMan123 Oct 18, 2022
fc70ee9
progress!
ShaMan123 Oct 18, 2022
6ec0e26
revert
ShaMan123 Oct 18, 2022
14c7713
refactor
ShaMan123 Oct 18, 2022
7f6e7a3
cleanup
ShaMan123 Oct 18, 2022
9c00f88
refactor(): getBisector to class
ShaMan123 Oct 19, 2022
e20b2ec
test(): group
ShaMan123 Oct 19, 2022
601c363
refactor(): axis keys
ShaMan123 Oct 19, 2022
f4f6635
refactor skew handlers
ShaMan123 Oct 19, 2022
040d459
minor fix + rename
ShaMan123 Oct 19, 2022
60ec16e
Merge branch 'master' into ci-safegurad-visual-tests
ShaMan123 Oct 19, 2022
902a7ca
`compensationFactor` only for `skewY`
ShaMan123 Oct 19, 2022
604a6bc
test(): two equal points
Oct 20, 2022
4a28d67
fix(): anchoring origin
ShaMan123 Oct 20, 2022
730394e
fix(): zero unit vector
ShaMan123 Oct 20, 2022
5ead0b3
Update polygon.js
ShaMan123 Oct 20, 2022
7bd43c4
reduce points
ShaMan123 Oct 20, 2022
14269d6
fix(): polygon last points eq first
ShaMan123 Oct 20, 2022
ef3cfef
fix(): 1 point case
ShaMan123 Oct 20, 2022
abb7a2e
fix(): line cap 1 point
ShaMan123 Oct 20, 2022
a0fef4b
fix(): reduce polygon end points eq start
ShaMan123 Oct 20, 2022
18a2ac4
Update stroke_projection.js
ShaMan123 Oct 20, 2022
9fdd188
Update stroke_projection.js
ShaMan123 Oct 20, 2022
fd9d6c9
comment
ShaMan123 Oct 20, 2022
7512123
rename for clarity
ShaMan123 Oct 20, 2022
6912a60
checkout unrelated changes
ShaMan123 Oct 20, 2022
51c63b4
Merge branch 'master' into fix-skewing-controls
ShaMan123 Oct 20, 2022
0d5d805
checkout svg visual tests/assets
ShaMan123 Oct 20, 2022
60dd440
Update controls.actions.ts
ShaMan123 Oct 20, 2022
0abd35f
test(): add more cases
Oct 20, 2022
ceee8f2
fix(projectBevel)
Oct 20, 2022
7a0cd3b
cleanup findRight
ShaMan123 Oct 21, 2022
a03e124
revert(): square projection of zero vector
ShaMan123 Oct 21, 2022
7966b5b
fix(projectBevel)
Oct 21, 2022
98bf652
Merge commit 'refs/pull/8374/head' of github.com:fabricjs/fabric.js i…
Oct 21, 2022
7104cf8
Merge commit 'refs/pull/8380/head' of github.com:fabricjs/fabric.js i…
Oct 21, 2022
59c7ac1
test(): add singlePoint and skewX=0, skewY=0
Oct 21, 2022
0a35197
Revert "revert(): square projection of zero vector"
Oct 22, 2022
93c0b88
fix(): 1 point round
Oct 22, 2022
d0c89f2
comments
Oct 22, 2022
6ff3b84
fix() strokeMiterLimit
Oct 22, 2022
c5bda31
fix() strokeMiterLimit remove Math.round
Oct 22, 2022
076d502
fix() strokeMiterLimit leq
Oct 22, 2022
0bcf04e
Merge branch 'master' into pr/8374
ShaMan123 Oct 23, 2022
27013c5
Update CHANGELOG.md
ShaMan123 Oct 23, 2022
374fcce
feat(): add isBetweenVectors, crossProduct and dotProduct
Oct 24, 2022
415f919
fix(StrokeLineJoinProjections): orthogonal projection
Oct 26, 2022
2b6746f
Merge branch 'master' into pr/8374
ShaMan123 Oct 26, 2022
a266e9f
Merge branch 'test-stroke-bbox' of https://github.com/luizzappa/fabri…
ShaMan123 Oct 26, 2022
52c5611
Update polyline.class.ts
ShaMan123 Oct 26, 2022
74eaaa0
fix(): `_getTransformedDimensions`
ShaMan123 Oct 26, 2022
2743841
refactor(StrokeLineJoinProjections): check alpha equals 0 or 2PI
Oct 26, 2022
3162be7
Merge commit 'refs/pull/8374/head' of github.com:fabricjs/fabric.js i…
Oct 26, 2022
b895215
tests(polygon#_calcDimensions)
Oct 27, 2022
aca5732
test(): stroke projections
Oct 27, 2022
30113ec
es6 syntax
ShaMan123 Oct 27, 2022
0117baf
Merge branch 'master' into pr/8374
ShaMan123 Oct 28, 2022
9079fff
test(polygon): _calcDimensions with custom options
Oct 28, 2022
c7fc7e1
Merge commit 'refs/pull/8374/head' of github.com:fabricjs/fabric.js i…
Oct 28, 2022
b1025c4
Merge branch 'master' into ci-safegurad-visual-tests
ShaMan123 Oct 30, 2022
8054180
refactor visual test results
ShaMan123 Oct 30, 2022
d4c8d6a
Update testem.config.js
ShaMan123 Oct 30, 2022
958dc06
Update testem.config.js
ShaMan123 Oct 30, 2022
c47abf0
better
ShaMan123 Oct 30, 2022
49c7a31
rename
ShaMan123 Oct 30, 2022
c40ca5b
Update CHANGELOG.md
ShaMan123 Oct 30, 2022
e6d780e
fix(polyline): strokeDiff and strokeOffset
Oct 31, 2022
27a2f5e
test(polygon#_calcDimensions): fix strokeDiff and strokeOffset
Oct 31, 2022
5214ea8
fix(polyline#_calcDimensions): remove options mutate
Nov 1, 2022
477f98b
Merge commit 'refs/pull/8311/head' of github.com:fabricjs/fabric.js i…
Nov 1, 2022
6cd0a1e
test(): reduce the number of tests
Nov 2, 2022
f8c012e
test(): remove testing group
Nov 10, 2022
103fabb
Update stroke_projection.js
ShaMan123 Nov 10, 2022
5b2797b
Merge branch 'master' into pr/8374
ShaMan123 Nov 10, 2022
c4af461
no caching
ShaMan123 Nov 10, 2022
71f030a
prettier
ShaMan123 Nov 10, 2022
599444c
fix
ShaMan123 Nov 10, 2022
8264ce9
fix(strokeLineCapProjections): project square and round with 1 point
Nov 11, 2022
af17575
test(): fix blur and setDimensions order
Nov 13, 2022
2d70240
refactor(strokeLineCapProjections): projectRound and projectSquare fo…
Nov 13, 2022
a3b0631
prettier
Nov 13, 2022
6cad304
fix(strokeLineJoinProjections): correct calc for round cases with str…
Nov 14, 2022
42ec9b2
refactor(strokeLineJoinProjections): simplify calculation of which pr…
Nov 14, 2022
9c076c6
refactor(strokeLineJoinProjections): safe guard
Nov 14, 2022
309357b
fix(StrokeLineCapProjections): line-cap square with uniform stroke
Nov 14, 2022
8f23931
Merge branch 'master' into pr/8374
ShaMan123 Nov 14, 2022
3d2e063
refactor(StrokeLineCapProjections): safe guard with Math.max
Nov 14, 2022
e1c5149
test(): remove skew when testing miter-limit
Nov 14, 2022
3a236e1
test(): remove a case that does not exist more
Nov 15, 2022
a3fdbb1
fix(StrokeLineJoinProjections): round with skewX and skewY
Nov 15, 2022
bcef2a5
test(): add round case with skewX and skewY
Nov 15, 2022
ea2d870
goldens
luizzappa Nov 15, 2022
c806db9
typo
ShaMan123 Nov 16, 2022
884d8c0
Merge branch 'test-stroke-bbox' of https://github.com/luizzappa/fabri…
ShaMan123 Nov 16, 2022
3842035
fix merge conflicts
ShaMan123 Nov 16, 2022
a13b9ec
Update polyline.class.ts
ShaMan123 Nov 16, 2022
16e601b
fix(): `_getTransformedDimensions`
ShaMan123 Nov 16, 2022
212f760
Update controls_handlers.js
ShaMan123 Nov 16, 2022
404859d
Update polyline.class.ts
ShaMan123 Nov 16, 2022
8ab4b62
Revert "Merge commit 'refs/pull/8311/head' of github.com:fabricjs/fab…
luizzappa Nov 16, 2022
547a775
test(): disabled node test for stroke projection
luizzappa Nov 16, 2022
0810190
fix(polyline#_set): recalc projections for round stroke
luizzappa Nov 17, 2022
1499258
Merge branch 'master' into pr/8374
ShaMan123 Nov 17, 2022
a17314a
imports
ShaMan123 Nov 18, 2022
85bc2f1
comment
ShaMan123 Nov 18, 2022
3300f31
checkout
ShaMan123 Nov 18, 2022
e08378f
checkout
ShaMan123 Nov 18, 2022
422be8f
fix(): restore `strokeOffset`
ShaMan123 Nov 18, 2022
7efa536
Merge branch 'master' into pr/8374
ShaMan123 Nov 27, 2022
8d5f319
Merge branch 'master' into pr/8374
ShaMan123 Dec 30, 2022
0adbdf2
rm goldens for diff readability
ShaMan123 Dec 30, 2022
494a10e
refactor(polyline#_getTransformedDimensions): remove strokeProjection…
luizzappa Dec 31, 2022
0b0a09a
comments on _getTransformedDimensions()
luizzappa Jan 2, 2023
43558ef
Merge branch 'master' into 8374-view-diff
ShaMan123 Jul 18, 2023
2029471
Merge remote-tracking branch 'origin/master' into 8374-view-diff
ShaMan123 Jul 18, 2023
a452691
fix merge hopefully
ShaMan123 Jul 18, 2023
78d1ae9
Update stroke_projection.js
ShaMan123 Jul 18, 2023
49c3f7e
disable visual test
ShaMan123 Jul 18, 2023
004e4f8
another merge fix
ShaMan123 Jul 19, 2023
2118e49
todo
ShaMan123 Jul 19, 2023
aa92b72
Update CHANGELOG.md
ShaMan123 Jul 19, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- test(): stroke projection [#8374](https://github.com/fabricjs/fabric.js/pull/8374)
- fix(Filters) Removing type from the options passed in the constructor [#9089](https://github.com/fabricjs/fabric.js/pull/9089)
- feat(InteractiveObject): add `getActiveControl()` to expose `__corner` [#9102](https://github.com/fabricjs/fabric.js/pull/9102)
- ci(sandbox): bump next.js [#9100](https://github.com/fabricjs/fabric.js/pull/9100)
Expand Down
113 changes: 79 additions & 34 deletions src/shapes/Polyline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { Point } from '../Point';
import type { Abortable, TClassProperties } from '../typedefs';
import { classRegistry } from '../ClassRegistry';
import { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';
import { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';
import { projectStrokeOnPoints } from '../util/misc/projectStroke';
import type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';
import { degreesToRadians } from '../util/misc/radiansDegreesConversion';
import { toFixed } from '../util/misc/toFixed';
import { FabricObject, cacheProperties } from './Object/FabricObject';
Expand Down Expand Up @@ -85,6 +87,8 @@ export class Polyline<

static cacheProperties = [...cacheProperties, 'points'];

strokeDiff: Point;

/**
* Constructor
* @param {Array} points Array of points (where each point is an object with x and y)
Expand Down Expand Up @@ -117,19 +121,31 @@ export class Polyline<
return true;
}

private _projectStrokeOnPoints() {
return projectStrokeOnPoints(this.points, this, this.isOpen());
private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {
return projectStrokeOnPoints(this.points, options, this.isOpen());
}

/**
* Calculate the polygon bounding box
* @private
*/
_calcDimensions() {
_calcDimensions(options?: Partial<TProjectStrokeOnPointsOptions>) {
options = {
scaleX: this.scaleX,
scaleY: this.scaleY,
skewX: this.skewX,
skewY: this.skewY,
strokeLineCap: this.strokeLineCap,
strokeLineJoin: this.strokeLineJoin,
strokeMiterLimit: this.strokeMiterLimit,
strokeUniform: this.strokeUniform,
strokeWidth: this.strokeWidth,
...(options || {}),
};
const points = this.exactBoundingBox
? this._projectStrokeOnPoints().map(
(projection) => projection.projectedPoint
)
? this._projectStrokeOnPoints(
options as TProjectStrokeOnPointsOptions
).map((projection) => projection.projectedPoint)
: this.points;
if (points.length === 0) {
return {
Expand All @@ -139,22 +155,30 @@ export class Polyline<
height: 0,
pathOffset: new Point(),
strokeOffset: new Point(),
strokeDiff: new Point(),
};
}
const bbox = makeBoundingBoxFromPoints(points);
const bboxNoStroke = makeBoundingBoxFromPoints(this.points);
const offsetX = bbox.left + bbox.width / 2,
offsetY = bbox.top + bbox.height / 2;
const pathOffsetX =
offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));
const pathOffsetY =
offsetY - pathOffsetX * Math.tan(degreesToRadians(this.skewY));
const bbox = makeBoundingBoxFromPoints(points),
// Remove scale effect, since it's applied after
matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),
bboxNoStroke = makeBoundingBoxFromPoints(
this.points.map((p) => transformPoint(p, matrix, true))
),
offsetX = bbox.left + bbox.width / 2,
offsetY = bbox.top + bbox.height / 2,
pathOffsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX)),
pathOffsetY =
offsetY - pathOffsetX * Math.tan(degreesToRadians(this.skewY)),
scale = new Point(this.scaleX, this.scaleY);
return {
...bbox,
pathOffset: new Point(pathOffsetX, pathOffsetY),
strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top).subtract(
new Point(bbox.left, bbox.top)
),
strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)
.subtract(new Point(bbox.left, bbox.top))
.multiply(scale),
strokeDiff: new Point(bbox.width, bbox.height)
.subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))
.multiply(scale),
};
}

Expand All @@ -174,9 +198,9 @@ export class Polyline<
}

setBoundingBox(adjustPosition?: boolean) {
const { left, top, width, height, pathOffset, strokeOffset } =
const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =
this._calcDimensions();
this.set({ width, height, pathOffset, strokeOffset });
this.set({ width, height, pathOffset, strokeOffset, strokeDiff });
adjustPosition &&
this.setPositionByOrigin(
new Point(left + width / 2, top + height / 2),
Expand All @@ -190,27 +214,48 @@ export class Polyline<
*/
_getNonTransformedDimensions() {
return this.exactBoundingBox
? new Point(this.width, this.height)
? // TODO: fix this
new Point(this.width, this.height)
: super._getNonTransformedDimensions();
}

/**
* @override stroke and skewing are taken into account when projecting stroke on points,
* therefore we don't want the default calculation to account for skewing as well
* therefore we don't want the default calculation to account for skewing as well.
* Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.
*
* @private
*/
_getTransformedDimensions(options?: any) {
return this.exactBoundingBox
? super._getTransformedDimensions({
...(options || {}),
// disable stroke bbox calculations
strokeWidth: 0,
// disable skewing bbox calculations
skewX: 0,
skewY: 0,
})
: super._getTransformedDimensions(options);
_getTransformedDimensions(options: any = {}) {
if (this.exactBoundingBox) {
let size: Point;
/* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because
the stroke projections are affected.
When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on
projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/
if (
Object.keys(options).some(
(key) =>
this.strokeUniform ||
(this.constructor as typeof Polyline).layoutProperties.includes(
key as keyof TProjectStrokeOnPointsOptions
)
)
) {
const { width, height } = this._calcDimensions(options);
size = new Point(options.width ?? width, options.height ?? height);
} else {
size = new Point(
options.width ?? this.width,
options.height ?? this.height
);
}
return size.multiply(
new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY)
);
} else {
return super._getTransformedDimensions(options);
}
}

/**
Expand All @@ -221,13 +266,13 @@ export class Polyline<
const changed = this.initialized && this[key as keyof this] !== value;
const output = super._set(key, value);
if (
this.exactBoundingBox &&
changed &&
(((key === 'scaleX' || key === 'scaleY') &&
this.strokeUniform &&
(this.constructor as typeof Polyline).layoutProperties.includes(
'strokeUniform'
) &&
this.strokeLineJoin !== 'round') ||
)) ||
(this.constructor as typeof Polyline).layoutProperties.includes(
key as keyof Polyline
))
Expand Down
7 changes: 6 additions & 1 deletion src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ export {
createVector,
calcAngleBetweenVectors,
getUnitVector,
getBisector,
calcVectorRotation,
crossProduct,
dotProduct,
getOrthonormalVector,
isBetweenVectors,
magnitude,
} from './misc/vectors';
export {
degreesToRadians,
Expand Down
11 changes: 11 additions & 0 deletions src/util/internals/findRight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const findIndexRight = <T>(
array: T[],
predicate: (value: T, index: number, array: T[]) => boolean
) => {
for (let index = array.length - 1; index >= 0; index--) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
};
7 changes: 4 additions & 3 deletions src/util/internals/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { getRandomInt } from './getRandomInt';
export { ifNaN } from './ifNaN';
export { removeFromArray } from './removeFromArray';
export * from './findRight';
export * from './getRandomInt';
export * from './ifNaN';
export * from './removeFromArray';
77 changes: 56 additions & 21 deletions src/util/misc/projectStroke/StrokeLineCapProjections.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { XY } from '../../../Point';
import { Point } from '../../../Point';
import { createVector, getOrthonormalVector, getUnitVector } from '../vectors';
import { getOrthonormalVector, getUnitVector } from '../vectors';
import { StrokeLineJoinProjections } from './StrokeLineJoinProjections';
import { StrokeProjectionsBase } from './StrokeProjectionsBase';
import type { TProjection, TProjectStrokeOnPointsOptions } from './types';
Expand Down Expand Up @@ -62,12 +62,32 @@ export class StrokeLineCapProjections extends StrokeProjectionsBase {
* @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round
*/
projectRound() {
return new StrokeLineJoinProjections(
this.A,
this.T,
this.T,
this.options
).projectRound();
const projections: Point[] = [];

if (!this.isSkewed() && this.A.eq(this.T)) {
/* 1 point case without `skew`
When `strokeUniform` is true, scaling has no effect.
So we divide by scale, to remove its effect.
*/
const projection = new Point(1, 1)
.scalarMultiply(this.strokeProjectionMagnitude)
.multiply(this.strokeUniformScalar);
projections.push(
this.applySkew(this.A.add(projection)),
this.applySkew(this.A.subtract(projection))
);
} else {
projections.push(
...new StrokeLineJoinProjections(
this.A,
this.T,
this.T,
this.options
).projectRound()
);
}

return projections;
}

/**
Expand All @@ -77,20 +97,35 @@ export class StrokeLineCapProjections extends StrokeProjectionsBase {
* @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square
*/
projectSquare() {
const orthogonalProjection = this.calcOrthogonalProjection(
this.A,
this.T,
this.strokeProjectionMagnitude
);
const strokePointingOut = this.scaleUnitVector(
getUnitVector(createVector(this.A, this.T)),
-this.strokeProjectionMagnitude
);
const projectedA = this.A.add(strokePointingOut);
return [
projectedA.add(orthogonalProjection),
projectedA.subtract(orthogonalProjection),
].map((p) => this.applySkew(p));
const projections: Point[] = [];

if (this.A.eq(this.T)) {
/* 1 point case without `skew`
When `strokeUniform` is true, scaling has no effect.
So we divide by scale, to remove its effect.
*/
const projection = new Point(1, 1)
.scalarMultiply(this.strokeProjectionMagnitude)
.multiply(this.strokeUniformScalar);
projections.push(this.A.add(projection), this.A.subtract(projection));
} else {
const orthogonalProjection = this.calcOrthogonalProjection(
this.A,
this.T,
this.strokeProjectionMagnitude
);
const strokePointingOut = this.scaleUnitVector(
getUnitVector(this.createSideVector(this.A, this.T)),
-this.strokeProjectionMagnitude
);
const projectedA = this.A.add(strokePointingOut);
projections.push(
projectedA.add(orthogonalProjection),
projectedA.subtract(orthogonalProjection)
);
}

return projections.map((p) => this.applySkew(p));
}

protected projectPoints() {
Expand Down
Loading