@design-core/core 0.0.6 → 50.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +4 -0
- package/.github/workflows/DesignCoreQA.yml +3 -0
- package/TODO.md +49 -6
- package/core/core/core.js +0 -3
- package/core/designCore.js +1 -1
- package/core/dimensions/alignedDimension.js +12 -11
- package/core/dimensions/angularDimension.js +38 -37
- package/core/dimensions/{baseCircularDimension.js → circularDimensionBase.js} +22 -21
- package/core/dimensions/diametricDimension.js +14 -13
- package/core/dimensions/dimension.js +62 -55
- package/core/dimensions/{baseDimension.js → dimensionBase.js} +73 -107
- package/core/dimensions/{baseLinearDimension.js → linearDimensionBase.js} +15 -14
- package/core/dimensions/radialDimension.js +12 -11
- package/core/dimensions/rotatedDimension.js +20 -19
- package/core/entities/arc.js +123 -156
- package/core/entities/arctext.js +222 -184
- package/core/entities/circle.js +77 -99
- package/core/entities/entity.js +114 -93
- package/core/entities/hatch.js +346 -273
- package/core/entities/insert.js +68 -83
- package/core/entities/line.js +21 -142
- package/core/entities/lwpolyline.js +16 -11
- package/core/entities/point.js +19 -19
- package/core/entities/polyline.js +7 -7
- package/core/entities/{basePolyline.js → polylineBase.js} +47 -299
- package/core/entities/rectangle.js +3 -1
- package/core/entities/solid.js +6 -15
- package/core/entities/text.js +190 -201
- package/core/lib/auxiliary/rubberBand.js +32 -0
- package/core/lib/auxiliary/selectionWindow.js +63 -0
- package/core/lib/auxiliary/snapPoint.js +113 -0
- package/core/lib/auxiliary/trackingLine.js +76 -0
- package/core/lib/boundingBox.js +11 -11
- package/core/lib/canvas.js +232 -168
- package/core/lib/clipboard.js +9 -3
- package/core/lib/colour.js +16 -0
- package/core/lib/commandLine.js +1 -6
- package/core/lib/commandManager.js +18 -8
- package/core/lib/constants.js +28 -0
- package/core/lib/dxf/dxf.js +15 -14
- package/core/lib/dxf/dxfIterator.js +2 -2
- package/core/lib/entityManager.js +33 -26
- package/core/lib/inputManager.js +36 -12
- package/core/lib/intersect.js +25 -0
- package/core/lib/matrix.js +1 -1
- package/core/lib/patterns.js +9 -2
- package/core/lib/plotOptions.js +67 -0
- package/core/lib/polylineUtils.js +75 -0
- package/core/lib/renderers/cairoRenderer.js +371 -0
- package/core/lib/renderers/canvasRenderer.js +315 -0
- package/core/lib/renderers/pdfRenderer.js +366 -0
- package/core/lib/renderers/rendererBase.js +284 -0
- package/core/lib/renderers/svgRenderer.js +343 -0
- package/core/lib/scene.js +28 -6
- package/core/lib/selectionManager.js +20 -20
- package/core/lib/settings.js +4 -2
- package/core/lib/snapping.js +4 -191
- package/core/lib/stateManager.js +30 -1
- package/core/lib/utils.js +26 -7
- package/core/properties/entityProperties.js +104 -0
- package/core/properties/property.js +106 -2
- package/core/properties/propertyManager.js +60 -44
- package/core/tables/block.js +50 -81
- package/core/tables/dimStyle.js +5 -5
- package/core/tables/endblk.js +1 -1
- package/core/tables/layer.js +8 -0
- package/core/tables/ltypeManager.js +1 -1
- package/core/tables/styleManagerBase.js +3 -2
- package/core/tables/tableManagerBase.js +8 -3
- package/core/tables/vport.js +2 -2
- package/core/tools/chamfer.js +117 -143
- package/core/tools/chamferFilletBase.js +138 -37
- package/core/tools/copy.js +11 -11
- package/core/tools/copybase.js +3 -3
- package/core/tools/copyclip.js +3 -3
- package/core/tools/cornerEntity.js +2 -2
- package/core/tools/cutclip.js +3 -3
- package/core/tools/explode.js +7 -7
- package/core/tools/extend.js +138 -25
- package/core/tools/fillet.js +92 -189
- package/core/tools/matchProp.js +3 -12
- package/core/tools/mirror.js +15 -14
- package/core/tools/move.js +8 -8
- package/core/tools/offset.js +31 -33
- package/core/tools/pasteclip.js +1 -1
- package/core/tools/purge.js +10 -10
- package/core/tools/rotate.js +19 -16
- package/core/tools/scale.js +7 -7
- package/core/tools/trim.js +271 -29
- package/core/tools/zoom.js +1 -1
- package/cspell.json +321 -0
- package/jest.config.js +6 -0
- package/package.json +5 -3
- package/test/dimensions/alignedDimension.test.js +17 -10
- package/test/dimensions/angularDimension.test.js +13 -13
- package/test/dimensions/diametricDimension.test.js +15 -15
- package/test/dimensions/dimension.test.js +12 -12
- package/test/dimensions/{baseDimension.test.js → dimensionBase.test.js} +73 -12
- package/test/dimensions/linearDimensionBase.test.js +62 -0
- package/test/dimensions/radialDimension.test.js +15 -15
- package/test/dimensions/rotatedDimension.test.js +18 -11
- package/test/entities/arc.test.js +83 -86
- package/test/entities/arctext.test.js +184 -57
- package/test/entities/circle.test.js +68 -96
- package/test/entities/entity.test.js +42 -8
- package/test/entities/hatch.test.js +569 -96
- package/test/entities/insert.test.js +99 -4
- package/test/entities/line.test.js +15 -41
- package/test/entities/lwpolyline.test.js +104 -0
- package/test/entities/point.test.js +3 -3
- package/test/entities/polyline.test.js +11 -0
- package/test/entities/{basePolyline.test.js → polylineBase.test.js} +192 -57
- package/test/entities/rectangle.test.js +11 -0
- package/test/entities/solid.test.js +1 -1
- package/test/entities/text.test.js +302 -77
- package/test/integration/exportIntegration.reference.dxf +9 -9
- package/test/integration/exportIntegration.test.js +5 -5
- package/test/integration/intersectionIntegration.test.js +4 -5
- package/test/integration/pdfRendererIntegration.reference.pdf +17709 -0
- package/test/integration/pdfRendererIntegration.test.js +61 -0
- package/test/integration/svgRendererIntegration.reference.svg +3343 -0
- package/test/integration/svgRendererIntegration.test.js +61 -0
- package/test/integration/userInputIntegration.reference.dxf +1165 -105
- package/test/integration/userInputIntegration.test.js +239 -132
- package/test/lib/boundingBox.test.js +3 -3
- package/test/lib/canvas.test.js +744 -125
- package/test/lib/constants.test.js +27 -0
- package/test/lib/entityManager.test.js +4 -4
- package/test/lib/inputManager.test.js +81 -20
- package/test/lib/intersect.test.js +83 -0
- package/test/lib/plotOptions.test.js +179 -0
- package/test/lib/rubberBand.test.js +84 -0
- package/test/lib/scene.test.js +9 -9
- package/test/lib/selectionManager.test.js +3 -3
- package/test/lib/settings.test.js +5 -6
- package/test/lib/snapping.test.js +72 -130
- package/test/lib/stateManager.test.js +7 -7
- package/test/lib/utils.test.js +36 -2
- package/test/properties/entityProperties.test.js +132 -0
- package/test/properties/property.test.js +53 -0
- package/test/properties/propertyManager.test.js +25 -25
- package/test/renderers/canvasRenderer.test.js +317 -0
- package/test/renderers/pdfRenderer.test.js +271 -0
- package/test/renderers/rendererBase.test.js +213 -0
- package/test/renderers/svgRenderer.test.js +326 -0
- package/test/tables/block.test.js +92 -13
- package/test/tables/endblk.test.js +2 -2
- package/test/tables/layer.test.js +30 -0
- package/test/tables/layerManager.test.js +2 -2
- package/test/test-helpers/hatchGridRenderer.js +180 -0
- package/test/test-helpers/test-helpers.js +158 -6
- package/test/tools/chamfer.test.js +273 -51
- package/test/tools/chamferFilletBase.test.js +125 -36
- package/test/tools/copy.test.js +8 -8
- package/test/tools/copybase.test.js +2 -2
- package/test/tools/copyclip.test.js +2 -2
- package/test/tools/cornerEntity.test.js +8 -8
- package/test/tools/cutclip.test.js +2 -2
- package/test/tools/erase.test.js +6 -6
- package/test/tools/explode.test.js +5 -5
- package/test/tools/extend.test.js +373 -42
- package/test/tools/fillet.test.js +230 -49
- package/test/tools/matchProp.test.js +11 -11
- package/test/tools/mirror.test.js +39 -39
- package/test/tools/move.test.js +7 -7
- package/test/tools/offset.test.js +222 -55
- package/test/tools/pasteclip.test.js +5 -5
- package/test/tools/purge.test.js +4 -4
- package/test/tools/rotate.test.js +39 -9
- package/test/tools/scale.test.js +33 -33
- package/test/tools/trim.test.js +579 -53
- package/test/tools/zoom.test.js +12 -12
- package/core/lib/selectionWindow.js +0 -83
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DesignCore } from '../../designCore.js';
|
|
2
|
+
import { Point } from '../../entities/point.js';
|
|
3
|
+
|
|
4
|
+
/** SelectionWindow Class */
|
|
5
|
+
export class SelectionWindow {
|
|
6
|
+
/**
|
|
7
|
+
* Create a SelectionWindow
|
|
8
|
+
* @param {Object} data
|
|
9
|
+
*/
|
|
10
|
+
constructor(data) {
|
|
11
|
+
this.colour = DesignCore.Settings.selectionWindow;
|
|
12
|
+
this.lineWidth = 1;
|
|
13
|
+
this.dashPattern = [];
|
|
14
|
+
|
|
15
|
+
if (data) {
|
|
16
|
+
if (data.hasOwnProperty('points')) {
|
|
17
|
+
if (data.points[1].y > data.points[0].y) {
|
|
18
|
+
this.colour = DesignCore.Settings.selectionWindow;
|
|
19
|
+
this.dashPattern = [5];
|
|
20
|
+
} else {
|
|
21
|
+
this.colour = DesignCore.Settings.crossingWindow;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.points = [];
|
|
25
|
+
const point1 = new Point(data.points[0].x, data.points[0].y);
|
|
26
|
+
const point2 = new Point(data.points[1].x, data.points[1].y);
|
|
27
|
+
|
|
28
|
+
this.points.push(point1);
|
|
29
|
+
this.points.push(point2);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Draw the entity
|
|
36
|
+
* @param {Object} renderer
|
|
37
|
+
* @param {number} scale
|
|
38
|
+
*/
|
|
39
|
+
draw(renderer, scale) {
|
|
40
|
+
const colour = this.colour;
|
|
41
|
+
const scaledPattern = this.dashPattern.map((x) => x / scale);
|
|
42
|
+
|
|
43
|
+
const p0 = this.points[0];
|
|
44
|
+
const p1 = this.points[1];
|
|
45
|
+
const rectPoints = [
|
|
46
|
+
new Point(p0.x, p0.y),
|
|
47
|
+
new Point(p1.x, p0.y),
|
|
48
|
+
new Point(p1.x, p1.y),
|
|
49
|
+
new Point(p0.x, p1.y),
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
renderer.setColour(colour);
|
|
53
|
+
renderer.setLineWidth(this.lineWidth / scale);
|
|
54
|
+
|
|
55
|
+
// Semi-transparent fill
|
|
56
|
+
renderer.setDash([], 0);
|
|
57
|
+
renderer.drawShape(rectPoints, { closed: true, fill: true, stroke: false, alpha: 0.2 });
|
|
58
|
+
|
|
59
|
+
// Dashed outline
|
|
60
|
+
renderer.setDash(scaledPattern, 0);
|
|
61
|
+
renderer.drawShape(rectPoints, { closed: true, fill: false, stroke: true });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { DesignCore } from '../../designCore.js';
|
|
2
|
+
import { Point } from '../../entities/point.js';
|
|
3
|
+
|
|
4
|
+
/** SnapPoint Class */
|
|
5
|
+
export class SnapPoint {
|
|
6
|
+
static Type = Object.freeze({
|
|
7
|
+
NONE: 'none',
|
|
8
|
+
END: 'end',
|
|
9
|
+
MID: 'mid',
|
|
10
|
+
CENTRE: 'centre',
|
|
11
|
+
QUADRANT: 'quadrant',
|
|
12
|
+
NEAREST: 'nearest',
|
|
13
|
+
TANGENT: 'tangent',
|
|
14
|
+
NODE: 'node',
|
|
15
|
+
PERPENDICULAR: 'perpendicular',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create SnapPoint
|
|
20
|
+
* @param {Point} snapPoint
|
|
21
|
+
* @param {string} type - snap type from SnapPoint.Type
|
|
22
|
+
*/
|
|
23
|
+
constructor(snapPoint, type = SnapPoint.Type.END) {
|
|
24
|
+
this.snapPoint = snapPoint;
|
|
25
|
+
this.type = type;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Draw the entity
|
|
30
|
+
* @param {Object} renderer
|
|
31
|
+
* @param {number} scale
|
|
32
|
+
*/
|
|
33
|
+
draw(renderer, scale) {
|
|
34
|
+
const snapColour = DesignCore.Settings.accentcolour;
|
|
35
|
+
const size = 6 / scale;
|
|
36
|
+
const x = this.snapPoint.x;
|
|
37
|
+
const y = this.snapPoint.y;
|
|
38
|
+
const lineWidth = 2.5 / scale;
|
|
39
|
+
|
|
40
|
+
renderer.setColour(snapColour);
|
|
41
|
+
renderer.setLineWidth(lineWidth);
|
|
42
|
+
renderer.setDash([], 0);
|
|
43
|
+
|
|
44
|
+
// Full circle encoded as two bulge semi-arcs (same encoding as Circle entity)
|
|
45
|
+
const circlePoints = (cx, cy, r) => [
|
|
46
|
+
new Point(cx + r, cy, 1),
|
|
47
|
+
new Point(cx - r, cy, 1),
|
|
48
|
+
new Point(cx + r, cy),
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
switch (this.type) {
|
|
52
|
+
case SnapPoint.Type.END: // square
|
|
53
|
+
renderer.drawShape([
|
|
54
|
+
new Point(x - size, y - size),
|
|
55
|
+
new Point(x + size, y - size),
|
|
56
|
+
new Point(x + size, y + size),
|
|
57
|
+
new Point(x - size, y + size),
|
|
58
|
+
], { closed: true });
|
|
59
|
+
break;
|
|
60
|
+
case SnapPoint.Type.MID: // triangle
|
|
61
|
+
renderer.drawShape([
|
|
62
|
+
new Point(x, y + size),
|
|
63
|
+
new Point(x - size, y - size),
|
|
64
|
+
new Point(x + size, y - size),
|
|
65
|
+
], { closed: true });
|
|
66
|
+
break;
|
|
67
|
+
case SnapPoint.Type.QUADRANT: // diamond
|
|
68
|
+
renderer.drawShape([
|
|
69
|
+
new Point(x, y - size),
|
|
70
|
+
new Point(x + size, y),
|
|
71
|
+
new Point(x, y + size),
|
|
72
|
+
new Point(x - size, y),
|
|
73
|
+
], { closed: true });
|
|
74
|
+
break;
|
|
75
|
+
case SnapPoint.Type.NEAREST: // hourglass
|
|
76
|
+
renderer.drawShape([
|
|
77
|
+
new Point(x - size, y - size),
|
|
78
|
+
new Point(x + size, y - size),
|
|
79
|
+
new Point(x - size, y + size),
|
|
80
|
+
new Point(x + size, y + size),
|
|
81
|
+
], { closed: true });
|
|
82
|
+
break;
|
|
83
|
+
case SnapPoint.Type.TANGENT: // circle + horizontal line above
|
|
84
|
+
renderer.drawShape(circlePoints(x, y, size));
|
|
85
|
+
renderer.drawShape([
|
|
86
|
+
new Point(x - size, y + size * 1.5),
|
|
87
|
+
new Point(x + size, y + size * 1.5),
|
|
88
|
+
]);
|
|
89
|
+
break;
|
|
90
|
+
case SnapPoint.Type.NODE: // circle + X inside
|
|
91
|
+
renderer.drawShape(circlePoints(x, y, size));
|
|
92
|
+
renderer.drawShape([
|
|
93
|
+
new Point(x - size * 0.7, y - size * 0.7),
|
|
94
|
+
new Point(x + size * 0.7, y + size * 0.7),
|
|
95
|
+
]);
|
|
96
|
+
renderer.drawShape([
|
|
97
|
+
new Point(x + size * 0.7, y - size * 0.7),
|
|
98
|
+
new Point(x - size * 0.7, y + size * 0.7),
|
|
99
|
+
]);
|
|
100
|
+
break;
|
|
101
|
+
case SnapPoint.Type.PERPENDICULAR: // L-shape corner
|
|
102
|
+
renderer.drawShape([
|
|
103
|
+
new Point(x - size, y + size),
|
|
104
|
+
new Point(x - size, y - size),
|
|
105
|
+
new Point(x + size, y - size),
|
|
106
|
+
]);
|
|
107
|
+
break;
|
|
108
|
+
default: // CENTRE - circle
|
|
109
|
+
renderer.drawShape(circlePoints(x, y, size));
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Point } from '../../entities/point.js';
|
|
2
|
+
|
|
3
|
+
import { DesignCore } from '../../designCore.js';
|
|
4
|
+
|
|
5
|
+
/** TrackingLine Class - dotted tracking line for polar/ortho snap */
|
|
6
|
+
export class TrackingLine {
|
|
7
|
+
/**
|
|
8
|
+
* Create TrackingLine
|
|
9
|
+
* @param {Point} inputPoint - the previous input point (defines direction)
|
|
10
|
+
* @param {Point} snapPoint - the current snapped mouse point (line starts here)
|
|
11
|
+
*/
|
|
12
|
+
constructor(inputPoint, snapPoint) {
|
|
13
|
+
this.inputPoint = inputPoint;
|
|
14
|
+
this.snapPoint = snapPoint;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Draw the tracking line, extended to the visible canvas edges
|
|
19
|
+
* @param {Object} renderer
|
|
20
|
+
* @param {number} scale
|
|
21
|
+
*/
|
|
22
|
+
draw(renderer, scale) {
|
|
23
|
+
const from = this.snapPoint;
|
|
24
|
+
const dir = this.snapPoint.subtract(this.inputPoint);
|
|
25
|
+
const lineWidth = 2 / scale;
|
|
26
|
+
|
|
27
|
+
if (dir.x === 0 && dir.y === 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Compute visible canvas bounds in scene space
|
|
32
|
+
const w = DesignCore.Canvas.width;
|
|
33
|
+
const h = DesignCore.Canvas.height;
|
|
34
|
+
const corner0 = DesignCore.Mouse.transformToScene(new Point(0, 0));
|
|
35
|
+
const corner1 = DesignCore.Mouse.transformToScene(new Point(w, h));
|
|
36
|
+
const boundsMin = corner0.min(corner1);
|
|
37
|
+
const boundsMax = corner0.max(corner1);
|
|
38
|
+
|
|
39
|
+
// Clip the ray (from snapPoint outward, away from inputPoint) to canvas bounds
|
|
40
|
+
let tMin = 0;
|
|
41
|
+
let tMax = Infinity;
|
|
42
|
+
|
|
43
|
+
if (dir.x !== 0) {
|
|
44
|
+
const tx1 = (boundsMin.x - from.x) / dir.x;
|
|
45
|
+
const tx2 = (boundsMax.x - from.x) / dir.x;
|
|
46
|
+
tMin = Math.max(tMin, Math.min(tx1, tx2));
|
|
47
|
+
tMax = Math.min(tMax, Math.max(tx1, tx2));
|
|
48
|
+
} else if (from.x < boundsMin.x || from.x > boundsMax.x) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (dir.y !== 0) {
|
|
53
|
+
const ty1 = (boundsMin.y - from.y) / dir.y;
|
|
54
|
+
const ty2 = (boundsMax.y - from.y) / dir.y;
|
|
55
|
+
tMin = Math.max(tMin, Math.min(ty1, ty2));
|
|
56
|
+
tMax = Math.min(tMax, Math.max(ty1, ty2));
|
|
57
|
+
} else if (from.y < boundsMin.y || from.y > boundsMax.y) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (tMax < tMin) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const start = from.add(dir.scale(tMin));
|
|
66
|
+
const end = from.add(dir.scale(tMax));
|
|
67
|
+
|
|
68
|
+
const lineColour = DesignCore.Settings.accentcolour;
|
|
69
|
+
const dashSize = 4 / scale;
|
|
70
|
+
|
|
71
|
+
renderer.setColour(lineColour);
|
|
72
|
+
renderer.setLineWidth(lineWidth);
|
|
73
|
+
renderer.setDash([dashSize, dashSize], 0);
|
|
74
|
+
renderer.drawShape([start, end]);
|
|
75
|
+
}
|
|
76
|
+
}
|
package/core/lib/boundingBox.js
CHANGED
|
@@ -55,9 +55,9 @@ export class BoundingBox {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* return bounding box
|
|
58
|
+
* return bounding box centre point
|
|
59
59
|
*/
|
|
60
|
-
get
|
|
60
|
+
get centrePoint() {
|
|
61
61
|
return new Point(this.xMin + this.xLength / 2, this.yMin + this.yLength / 2);
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -136,16 +136,16 @@ export class BoundingBox {
|
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* Calculate the boundingbox for an arc
|
|
139
|
-
* @param {Point}
|
|
139
|
+
* @param {Point} centrePoint
|
|
140
140
|
* @param {Point} startPoint
|
|
141
141
|
* @param {Point} endPoint
|
|
142
142
|
* @param {number} direction - ccw > 0, cw < 0
|
|
143
143
|
* @return {BoundingBox}
|
|
144
144
|
*/
|
|
145
|
-
static arcBoundingBox(
|
|
146
|
-
const startAngle =
|
|
147
|
-
const endAngle =
|
|
148
|
-
const radius =
|
|
145
|
+
static arcBoundingBox(centrePoint, startPoint, endPoint, direction = 1) {
|
|
146
|
+
const startAngle = centrePoint.angle(startPoint);
|
|
147
|
+
const endAngle = centrePoint.angle(endPoint);
|
|
148
|
+
const radius = centrePoint.distance(startPoint);
|
|
149
149
|
|
|
150
150
|
const cross0 = this.crossesAxis(startAngle, endAngle, 0, direction);
|
|
151
151
|
const cross90 = this.crossesAxis(startAngle, endAngle, Math.PI * 0.5, direction);
|
|
@@ -154,10 +154,10 @@ export class BoundingBox {
|
|
|
154
154
|
|
|
155
155
|
// if the arc crosses the axis the min or max is where the arc intersects the axis
|
|
156
156
|
// otherwise max/min is the arc endpoint
|
|
157
|
-
const xmin = cross180 ?
|
|
158
|
-
const xmax = cross0 ?
|
|
159
|
-
const ymin = cross270 ?
|
|
160
|
-
const ymax = cross90 ?
|
|
157
|
+
const xmin = cross180 ? centrePoint.x - radius : Math.min(startPoint.x, endPoint.x);
|
|
158
|
+
const xmax = cross0 ? centrePoint.x + radius : Math.max(startPoint.x, endPoint.x);
|
|
159
|
+
const ymin = cross270 ? centrePoint.y - radius : Math.min(startPoint.y, endPoint.y);
|
|
160
|
+
const ymax = cross90 ? centrePoint.y + radius : Math.max(startPoint.y, endPoint.y);
|
|
161
161
|
|
|
162
162
|
const topLeft = new Point(xmin, ymax);
|
|
163
163
|
const bottomRight = new Point(xmax, ymin);
|