@design-core/core 0.0.7 → 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.
Files changed (113) hide show
  1. package/.github/workflows/DesignCoreQA.yml +3 -0
  2. package/core/designCore.js +1 -1
  3. package/core/dimensions/alignedDimension.js +7 -7
  4. package/core/dimensions/angularDimension.js +32 -32
  5. package/core/dimensions/{baseCircularDimension.js → circularDimensionBase.js} +19 -19
  6. package/core/dimensions/diametricDimension.js +10 -10
  7. package/core/dimensions/dimension.js +42 -42
  8. package/core/dimensions/{baseDimension.js → dimensionBase.js} +17 -17
  9. package/core/dimensions/{baseLinearDimension.js → linearDimensionBase.js} +9 -9
  10. package/core/dimensions/radialDimension.js +8 -8
  11. package/core/dimensions/rotatedDimension.js +8 -8
  12. package/core/entities/arc.js +22 -22
  13. package/core/entities/arctext.js +13 -13
  14. package/core/entities/circle.js +7 -7
  15. package/core/entities/hatch.js +28 -28
  16. package/core/entities/insert.js +5 -5
  17. package/core/entities/point.js +19 -19
  18. package/core/entities/polyline.js +3 -3
  19. package/core/entities/{basePolyline.js → polylineBase.js} +18 -18
  20. package/core/entities/text.js +4 -4
  21. package/core/lib/boundingBox.js +11 -11
  22. package/core/lib/canvas.js +6 -4
  23. package/core/lib/clipboard.js +2 -2
  24. package/core/lib/dxf/dxf.js +11 -11
  25. package/core/lib/dxf/dxfIterator.js +2 -2
  26. package/core/lib/entityManager.js +19 -19
  27. package/core/lib/inputManager.js +1 -1
  28. package/core/lib/matrix.js +1 -1
  29. package/core/lib/patterns.js +1 -1
  30. package/core/lib/polylineUtils.js +9 -9
  31. package/core/lib/renderers/cairoRenderer.js +5 -5
  32. package/core/lib/renderers/canvasRenderer.js +4 -4
  33. package/core/lib/renderers/pdfRenderer.js +7 -7
  34. package/core/lib/renderers/rendererBase.js +1 -1
  35. package/core/lib/scene.js +1 -1
  36. package/core/lib/selectionManager.js +18 -18
  37. package/core/lib/utils.js +5 -5
  38. package/core/properties/property.js +1 -1
  39. package/core/properties/propertyManager.js +37 -37
  40. package/core/tables/block.js +48 -46
  41. package/core/tables/dimStyle.js +5 -5
  42. package/core/tables/ltypeManager.js +1 -1
  43. package/core/tables/vport.js +2 -2
  44. package/core/tools/chamfer.js +6 -6
  45. package/core/tools/chamferFilletBase.js +4 -4
  46. package/core/tools/copy.js +8 -8
  47. package/core/tools/copybase.js +3 -3
  48. package/core/tools/copyclip.js +3 -3
  49. package/core/tools/cornerEntity.js +2 -2
  50. package/core/tools/cutclip.js +3 -3
  51. package/core/tools/explode.js +6 -6
  52. package/core/tools/extend.js +13 -13
  53. package/core/tools/fillet.js +6 -6
  54. package/core/tools/matchProp.js +1 -1
  55. package/core/tools/mirror.js +11 -11
  56. package/core/tools/move.js +5 -5
  57. package/core/tools/offset.js +29 -29
  58. package/core/tools/purge.js +10 -10
  59. package/core/tools/rotate.js +16 -16
  60. package/core/tools/scale.js +6 -6
  61. package/core/tools/trim.js +15 -15
  62. package/cspell.json +321 -0
  63. package/package.json +1 -1
  64. package/test/dimensions/alignedDimension.test.js +3 -3
  65. package/test/dimensions/angularDimension.test.js +7 -7
  66. package/test/dimensions/diametricDimension.test.js +9 -9
  67. package/test/dimensions/dimension.test.js +12 -12
  68. package/test/dimensions/{baseDimension.test.js → dimensionBase.test.js} +12 -12
  69. package/test/dimensions/{baseLinearDimension.test.js → linearDimensionBase.test.js} +7 -7
  70. package/test/dimensions/radialDimension.test.js +9 -9
  71. package/test/dimensions/rotatedDimension.test.js +4 -4
  72. package/test/entities/arc.test.js +10 -10
  73. package/test/entities/arctext.test.js +6 -6
  74. package/test/entities/circle.test.js +18 -18
  75. package/test/entities/hatch.test.js +39 -39
  76. package/test/entities/insert.test.js +9 -9
  77. package/test/entities/point.test.js +3 -3
  78. package/test/entities/{basePolyline.test.js → polylineBase.test.js} +131 -62
  79. package/test/entities/text.test.js +19 -19
  80. package/test/integration/exportIntegration.test.js +3 -3
  81. package/test/integration/userInputIntegration.test.js +5 -5
  82. package/test/lib/boundingBox.test.js +3 -3
  83. package/test/lib/canvas.test.js +9 -9
  84. package/test/lib/inputManager.test.js +4 -4
  85. package/test/lib/scene.test.js +9 -9
  86. package/test/lib/selectionManager.test.js +3 -3
  87. package/test/lib/snapping.test.js +1 -1
  88. package/test/properties/propertyManager.test.js +22 -22
  89. package/test/renderers/pdfRenderer.test.js +2 -2
  90. package/test/tables/block.test.js +63 -14
  91. package/test/tables/layerManager.test.js +2 -2
  92. package/test/test-helpers/hatchGridRenderer.js +3 -3
  93. package/test/test-helpers/test-helpers.js +6 -6
  94. package/test/tools/chamfer.test.js +60 -60
  95. package/test/tools/chamferFilletBase.test.js +36 -36
  96. package/test/tools/copy.test.js +6 -6
  97. package/test/tools/copybase.test.js +2 -2
  98. package/test/tools/copyclip.test.js +2 -2
  99. package/test/tools/cornerEntity.test.js +8 -8
  100. package/test/tools/cutclip.test.js +2 -2
  101. package/test/tools/erase.test.js +6 -6
  102. package/test/tools/explode.test.js +2 -2
  103. package/test/tools/extend.test.js +84 -84
  104. package/test/tools/fillet.test.js +62 -62
  105. package/test/tools/matchProp.test.js +6 -6
  106. package/test/tools/mirror.test.js +26 -26
  107. package/test/tools/move.test.js +7 -7
  108. package/test/tools/offset.test.js +65 -65
  109. package/test/tools/purge.test.js +4 -4
  110. package/test/tools/rotate.test.js +10 -10
  111. package/test/tools/scale.test.js +28 -28
  112. package/test/tools/trim.test.js +109 -109
  113. package/test/tools/zoom.test.js +5 -5
@@ -153,13 +153,13 @@ export class Insert extends Entity {
153
153
  /**
154
154
  * Draw the entity
155
155
  * @param {Object} renderer
156
- * @return {Array} block items for the canvas to render recursively
156
+ * @return {Array} block entities for the canvas to render recursively
157
157
  */
158
158
  draw(renderer) {
159
159
  // blocks are associated with an insert point.
160
- // Apply the insert location and rotation so block items draw correctly.
160
+ // Apply the insert location and rotation so block entities draw correctly.
161
161
  renderer.applyTransform({ x: this.points[0].x, y: this.points[0].y, rotation: Utils.degrees2radians(this.getRotation()) });
162
- return this.block.items;
162
+ return this.block.entities;
163
163
  }
164
164
 
165
165
  /**
@@ -204,9 +204,9 @@ export class Insert extends Entity {
204
204
 
205
205
  for (let snap = 0; snap < blockSnaps.length; snap++) {
206
206
  const sp = blockSnaps[snap];
207
- // offset the item snap point by the block insert location
207
+ // offset the entity snap point by the block insert location
208
208
  const rotatedPoint = sp.snapPoint.add(this.points[0]);
209
- // rotate the snap point to match the item positions
209
+ // rotate the snap point to match the entity positions
210
210
  const adjustedPoint = rotatedPoint.rotate(this.points[0], Utils.degrees2radians(this.getRotation()));
211
211
  snaps.push(new SnapPoint(adjustedPoint, sp.type));
212
212
  }
@@ -298,16 +298,16 @@ export class Point {
298
298
  * Find the closest point on a arc between start and end points
299
299
  * @param {Point} startPoint
300
300
  * @param {Point} endPoint
301
- * @param {Point} centerPoint
301
+ * @param {Point} centrePoint
302
302
  * @param {number} direction - CCW if > 0
303
303
  * @return {Point} the closest point on the arc or null
304
304
  */
305
- closestPointOnArc(startPoint, endPoint, centerPoint, direction = 0) {
306
- const length = this.distance(centerPoint);
307
- const radius = centerPoint.distance(startPoint);
305
+ closestPointOnArc(startPoint, endPoint, centrePoint, direction = 0) {
306
+ const length = this.distance(centrePoint);
307
+ const radius = centrePoint.distance(startPoint);
308
308
 
309
- const Cx = centerPoint.x + radius * (this.x - centerPoint.x) / length;
310
- const Cy = centerPoint.y + radius * (this.y - centerPoint.y) / length;
309
+ const Cx = centrePoint.x + radius * (this.x - centrePoint.x) / length;
310
+ const Cy = centrePoint.y + radius * (this.y - centrePoint.y) / length;
311
311
  const closest = new Point(Cx, Cy);
312
312
 
313
313
  // circle
@@ -315,7 +315,7 @@ export class Point {
315
315
  return closest;
316
316
  }
317
317
 
318
- if (closest.isOnArc(startPoint, endPoint, centerPoint, direction)) {
318
+ if (closest.isOnArc(startPoint, endPoint, centrePoint, direction)) {
319
319
  return closest;
320
320
  }
321
321
 
@@ -327,15 +327,15 @@ export class Point {
327
327
  * Determine if point is on arc segment
328
328
  * @param {Point} startPoint
329
329
  * @param {Point} endPoint
330
- * @param {Point} centerPoint
330
+ * @param {Point} centrePoint
331
331
  * @param {number} direction - CCW if > 0
332
332
  * @return {Point} true or false
333
333
  */
334
- isOnArc(startPoint, endPoint, centerPoint, direction = 0) {
334
+ isOnArc(startPoint, endPoint, centrePoint, direction = 0) {
335
335
  // direction: ccw arc > 0, clockwise arc <= 0
336
- const snapAngle = centerPoint.angle(this);
337
- const startAngle = centerPoint.angle(startPoint);
338
- const endAngle = centerPoint.angle(endPoint);
336
+ const snapAngle = centrePoint.angle(this);
337
+ const startAngle = centrePoint.angle(startPoint);
338
+ const endAngle = centrePoint.angle(endPoint);
339
339
 
340
340
  if (direction > 0) {
341
341
  // Counter Clockwise Arc
@@ -438,7 +438,7 @@ export class Point {
438
438
  }
439
439
 
440
440
  /**
441
- * Returns apothem; the distance from arc center to cord midpoint
441
+ * Returns apothem; the distance from arc centre to cord midpoint
442
442
  * @param {Point} nextPoint
443
443
  * @return {number} apothem
444
444
  */
@@ -465,12 +465,12 @@ export class Point {
465
465
 
466
466
  let a = this.apothem(nextPoint);
467
467
 
468
- // check if the center point is inverted. i.e. at 180 it goes inside the arc
468
+ // check if the centre point is inverted. i.e. at 180 it goes inside the arc
469
469
  if (Math.abs(this.bulgeAngle()) > Math.PI) {
470
470
  a = -a;
471
471
  }
472
472
 
473
- // get the direction from the midpoint to the center point
473
+ // get the direction from the midpoint to the centre point
474
474
  const direction = this.angle(nextPoint) + (Math.PI / 2) * Math.sign(this.bulge);
475
475
  // centre point is the apothem distance from the mid point in the given direction
476
476
  const centre = midp.project(direction, a);
@@ -486,12 +486,12 @@ export class Point {
486
486
  * @return {number} - the partial bulge value
487
487
  */
488
488
  partialBulge(nextPoint, splitPoint, afterSplit = false) {
489
- const center = this.bulgeCentrePoint(nextPoint);
489
+ const centre = this.bulgeCentrePoint(nextPoint);
490
490
  const direction = this.bulge > 0 ? 1 : -1;
491
491
 
492
- const startAngle = center.angle(this);
493
- const endAngle = center.angle(nextPoint);
494
- const splitAngle = center.angle(splitPoint);
492
+ const startAngle = centre.angle(this);
493
+ const endAngle = centre.angle(nextPoint);
494
+ const splitAngle = centre.angle(splitPoint);
495
495
 
496
496
  let includedAngle;
497
497
  if (afterSplit) {
@@ -1,12 +1,12 @@
1
1
  import { DXFFile } from '../lib/dxf/dxfFile.js';
2
- import { BasePolyline } from './basePolyline.js';
2
+ import { PolylineBase } from './polylineBase.js';
3
3
  import { Point } from './point.js';
4
4
 
5
5
  /**
6
6
  * Polyline Entity Class
7
- * @extends BasePolyline
7
+ * @extends PolylineBase
8
8
  */
9
- export class Polyline extends BasePolyline {
9
+ export class Polyline extends PolylineBase {
10
10
  static type = 'Polyline';
11
11
 
12
12
  /**
@@ -20,8 +20,8 @@ import { RubberBand } from '../lib/auxiliary/rubberBand.js';
20
20
  * Base Polyline Entity Class
21
21
  * @extends Entity
22
22
  */
23
- export class BasePolyline extends Entity {
24
- static type = 'BasePolyline';
23
+ export class PolylineBase extends Entity {
24
+ static type = 'PolylineBase';
25
25
 
26
26
  /**
27
27
  * Create a Base Polyline
@@ -233,7 +233,7 @@ export class BasePolyline extends Entity {
233
233
  /**
234
234
  * Set entity points from a polyline point representation
235
235
  * @param {Array} points
236
- * @return {BasePolyline}
236
+ * @return {PolylineBase}
237
237
  */
238
238
  fromPolylinePoints(points) {
239
239
  const pts = points.map((p) => new Point(p.x, p.y, p.bulge));
@@ -311,10 +311,10 @@ export class BasePolyline extends Entity {
311
311
  let closestPoint;
312
312
  let candidateSegment;
313
313
  if (A.bulge !== 0) {
314
- const center = A.bulgeCentrePoint(B);
314
+ const centre = A.bulgeCentrePoint(B);
315
315
  const direction = A.bulge > 0 ? 1 : -1;
316
- closestPoint = P.closestPointOnArc(A, B, center, direction);
317
- candidateSegment = new Arc({ points: [center, A, B], direction });
316
+ closestPoint = P.closestPointOnArc(A, B, centre, direction);
317
+ candidateSegment = new Arc({ points: [centre, A, B], direction });
318
318
  } else {
319
319
  closestPoint = P.closestPointOnLine(A, B);
320
320
  candidateSegment = new Line({ points: [A, B] });
@@ -420,9 +420,9 @@ export class BasePolyline extends Entity {
420
420
  */
421
421
  isPointOnSegment(point, A, B) {
422
422
  if (A.bulge !== 0) {
423
- const center = A.bulgeCentrePoint(B);
423
+ const centre = A.bulgeCentrePoint(B);
424
424
  const direction = A.bulge > 0 ? 1 : -1;
425
- return point.isOnArc(A, B, center, direction);
425
+ return point.isOnArc(A, B, centre, direction);
426
426
  }
427
427
  return point.isOnLine(A, B);
428
428
  }
@@ -438,9 +438,9 @@ export class BasePolyline extends Entity {
438
438
  const B = this.points[segmentIndex % this.points.length];
439
439
 
440
440
  if (A.bulge !== 0) {
441
- const center = A.bulgeCentrePoint(B);
441
+ const centre = A.bulgeCentrePoint(B);
442
442
  const direction = A.bulge > 0 ? 1 : -1;
443
- const closest = point.closestPointOnArc(A, B, center, direction);
443
+ const closest = point.closestPointOnArc(A, B, centre, direction);
444
444
 
445
445
  if (closest) {
446
446
  return closest;
@@ -464,10 +464,10 @@ export class BasePolyline extends Entity {
464
464
  const B = this.points[segmentIndex % this.points.length];
465
465
 
466
466
  if (A.bulge !== 0) {
467
- const center = A.bulgeCentrePoint(B);
467
+ const centre = A.bulgeCentrePoint(B);
468
468
  const direction = A.bulge > 0 ? 1 : -1;
469
- const startAngle = center.angle(A);
470
- const pointAngle = center.angle(point);
469
+ const startAngle = centre.angle(A);
470
+ const pointAngle = centre.angle(point);
471
471
  return ((pointAngle - startAngle) * direction + 4 * Math.PI) % (2 * Math.PI);
472
472
  }
473
473
 
@@ -490,8 +490,8 @@ export class BasePolyline extends Entity {
490
490
  let boundingBox = BoundingBox.lineBoundingBox(this.points[i], nextPoint);
491
491
 
492
492
  if (this.points[i].bulge !== 0) {
493
- const centerPoint = this.points[i].bulgeCentrePoint(nextPoint);
494
- boundingBox = BoundingBox.arcBoundingBox(centerPoint, this.points[i], nextPoint, this.points[i].bulge);
493
+ const centrePoint = this.points[i].bulgeCentrePoint(nextPoint);
494
+ boundingBox = BoundingBox.arcBoundingBox(centrePoint, this.points[i], nextPoint, this.points[i].bulge);
495
495
  }
496
496
 
497
497
  xmin = Math.min(xmin, boundingBox.xMin);
@@ -519,9 +519,9 @@ export class BasePolyline extends Entity {
519
519
  // get the angle at the end of the previous segment
520
520
  let lastSegAngle;
521
521
  if (lastSegIsArc) {
522
- const centerPoint = this.points.at(-2).bulgeCentrePoint(this.points.at(-1));
523
- // angle is perpendicular to the center-to-end point ray, in the direction of the bulge
524
- lastSegAngle = centerPoint.angle(this.points.at(-1)) + (Math.PI / 2) * Math.sign(lastSegBulge);
522
+ const centrePoint = this.points.at(-2).bulgeCentrePoint(this.points.at(-1));
523
+ // angle is perpendicular to the centre-to-end point ray, in the direction of the bulge
524
+ lastSegAngle = centrePoint.angle(this.points.at(-1)) + (Math.PI / 2) * Math.sign(lastSegBulge);
525
525
  } else {
526
526
  // line segment angle is the angle from point 0 to point 1
527
527
  lastSegAngle = this.points.at(-2).angle(this.points.at(-1));
@@ -83,7 +83,7 @@ export class Text extends Entity {
83
83
  type: Property.Type.LIST,
84
84
  value: hAlign > 2 ? 1 : hAlign,
85
85
  dxfCode: 72,
86
- options: () => [{ display: 'Left', value: 0 }, { display: 'Center', value: 1 }, { display: 'Right', value: 2 }],
86
+ options: () => [{ display: 'Left', value: 0 }, { display: 'Centre', value: 1 }, { display: 'Right', value: 2 }],
87
87
  });
88
88
  // DXF Groupcode 73 - Vertical Alignment (0=Baseline; 1=Bottom; 2=Middle; 3=Top)
89
89
  this.properties.add(Property.Names.VERTICALALIGNMENT, {
@@ -354,13 +354,13 @@ export class Text extends Entity {
354
354
  case 0:
355
355
  return 'left';
356
356
  case 1:
357
- return 'center';
357
+ return 'centre';
358
358
  case 2:
359
359
  return 'right';
360
360
  case 3:
361
361
  return (this.getProperty(Property.Names.VERTICALALIGNMENT) === 0 ? 'aligned' : 'left');
362
362
  case 4:
363
- return (this.getProperty(Property.Names.VERTICALALIGNMENT) === 0 ? 'center' : 'left');
363
+ return (this.getProperty(Property.Names.VERTICALALIGNMENT) === 0 ? 'centre' : 'left');
364
364
  case 5:
365
365
  return (this.getProperty(Property.Names.VERTICALALIGNMENT) === 0 ? 'fit' : 'left');
366
366
  default:
@@ -539,7 +539,7 @@ export class Text extends Entity {
539
539
  case 0: // left
540
540
  offsetX = 0;
541
541
  break;
542
- case 1: // center
542
+ case 1: // centre
543
543
  offsetX = -rect.width / 2;
544
544
  break;
545
545
  case 2: // right
@@ -55,9 +55,9 @@ export class BoundingBox {
55
55
  }
56
56
 
57
57
  /**
58
- * return bounding box center point
58
+ * return bounding box centre point
59
59
  */
60
- get centerPoint() {
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} centerPoint
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(centerPoint, startPoint, endPoint, direction = 1) {
146
- const startAngle = centerPoint.angle(startPoint);
147
- const endAngle = centerPoint.angle(endPoint);
148
- const radius = centerPoint.distance(startPoint);
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 ? centerPoint.x - radius : Math.min(startPoint.x, endPoint.x);
158
- const xmax = cross0 ? centerPoint.x + radius : Math.max(startPoint.x, endPoint.x);
159
- const ymin = cross270 ? centerPoint.y - radius : Math.min(startPoint.y, endPoint.y);
160
- const ymax = cross90 ? centerPoint.y + radius : Math.max(startPoint.y, endPoint.y);
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);
@@ -189,7 +189,9 @@ export class Canvas {
189
189
  */
190
190
  wheel(delta) {
191
191
  if (DesignCore.Mouse.buttonTwoDown) return;
192
- const scale = Math.pow(1 + Math.abs(delta), delta > 0 ? 1 : -1);
192
+ // Clamp to [-1, 1] so that high-resolution mice and track pads don't produce runaway jumps.
193
+ const clampedDelta = Math.max(-1, Math.min(1, delta));
194
+ const scale = Math.pow(1.2, clampedDelta);
193
195
  if (scale < 1 && this.getScale() > this.minScaleFactor || scale > 1 && this.getScale() < this.maxScaleFactor) {
194
196
  this.zoom(scale);
195
197
  }
@@ -386,8 +388,8 @@ export class Canvas {
386
388
  this.#paintEntities(DesignCore.Scene.previewEntities, renderer);
387
389
 
388
390
  // Paint the selected scene items: single pass — renderer handles glow + entity internally.
389
- const selectedItems = DesignCore.Scene.selectionManager.selectedItems;
390
- this.#paintEntities(selectedItems, renderer, { colour: selectionHaloColour, lineWidthDelta: selectionLineWidthDelta });
391
+ const selectedEntities = DesignCore.Scene.selectionManager.selectedEntities;
392
+ this.#paintEntities(selectedEntities, renderer, { colour: selectionHaloColour, lineWidthDelta: selectionLineWidthDelta });
391
393
 
392
394
  // Paint the auxiliary scene items
393
395
  // auxiliary items include things like the selection window, snap points etc
@@ -403,7 +405,7 @@ export class Canvas {
403
405
 
404
406
  /**
405
407
  * Recursively paint a single entity and any children it returns.
406
- * Container entities (Insert, BaseDimension) return an array of child items from draw().
408
+ * Container entities (Insert, DimensionBase) return an array of child items from draw().
407
409
  * Leaf entities return undefined. Renderer state is saved/restored around each entity.
408
410
  * @param {Object} entity - entity to paint
409
411
  * @param {Object} renderer - renderer instance
@@ -69,7 +69,7 @@ export class Clipboard {
69
69
  return;
70
70
  }
71
71
 
72
- // copy the item to avoid mutation of originals
72
+ // copy the entity to avoid mutation of originals
73
73
  this.#Entities = entities.map((entity) => Utils.cloneObject(entity));
74
74
  // set basepoint to bottom left of selection bounding box
75
75
  const bbox = BoundingBox.fromEntities(entities);
@@ -152,7 +152,7 @@ export class Clipboard {
152
152
  const clipboardData = { basePoint: undefined, Entities: undefined };
153
153
  const jsonEntities = [];
154
154
 
155
- // convert each entity to a simple object - this allows non-enumberable properties (like points) to be copied
155
+ // convert each entity to a simple object - this allows non-enumerable properties (like points) to be copied
156
156
  for (const ent of this.#Entities) {
157
157
  const jsonEntity = this.#simplify(ent);
158
158
  jsonEntities.push(jsonEntity);
@@ -311,14 +311,14 @@ export class DXF {
311
311
  DesignCore.HandleManager.checkHandle(itemHandle);
312
312
  }
313
313
 
314
- if (block.hasOwnProperty('items') === false) {
315
- block.items = [];
314
+ if (block.hasOwnProperty('entities') === false) {
315
+ block.entities = [];
316
316
  }
317
317
 
318
318
  // add the child to the block items
319
319
  // TODO: create a block instance and add the items.
320
320
  // check block is valid before adding to scene
321
- block.items.push(item);
321
+ block.entities.push(item);
322
322
  }
323
323
  });
324
324
  }
@@ -347,7 +347,7 @@ export class DXF {
347
347
  entity.points = this.parsePoints(entity.points);
348
348
  }
349
349
 
350
- this.addItem(entity);
350
+ this.addEntity(entity);
351
351
  });
352
352
 
353
353
  // ensure all layers, ltypes, styles, dimstyles exist
@@ -378,18 +378,18 @@ export class DXF {
378
378
  }
379
379
 
380
380
  /**
381
- * Add Item
382
- * @param {Object} item
381
+ * Add Entity
382
+ * @param {Object} entity
383
383
  */
384
- addItem(item) {
385
- if (item.hasOwnProperty('0') === false) {
384
+ addEntity(entity) {
385
+ if (entity.hasOwnProperty('0') === false) {
386
386
  return;
387
387
  }
388
388
 
389
- const command = item[0];
389
+ const command = entity[0];
390
390
  if (DesignCore.CommandManager.isCommand(command)) {
391
- const entity = DesignCore.CommandManager.createNew(command, item);
392
- DesignCore.Scene.entities.add(entity);
391
+ const newEntity = DesignCore.CommandManager.createNew(command, entity);
392
+ DesignCore.Scene.entities.add(newEntity);
393
393
  } else {
394
394
  Logging.instance.warn(`${Strings.Message.UNKNOWNCOMMAND} ${command}`);
395
395
  this.unsupportedElements = true;
@@ -23,11 +23,11 @@ Example DXF Entity Pairs:
23
23
  value: 100.0 - y position
24
24
  */
25
25
 
26
- /** DXF Interator Class */
26
+ /** DXF Iterator Class */
27
27
  export class DxfIterator {
28
28
  static _instance;
29
29
 
30
- /** Create DXFInterator */
30
+ /** Create DXFIterator */
31
31
  constructor() {
32
32
  this.currentIndex = 0;
33
33
  this.lines = [];
@@ -92,26 +92,26 @@ export class EntityManager {
92
92
  }
93
93
 
94
94
  /**
95
- * Find items in scene
95
+ * Find entities in scene
96
96
  * @param {string} type - entity type or "ANY"
97
97
  * @param {string} prop - object of entity parameters
98
98
  * @param {any} value - value of the property
99
- * @return {number} - index of items
99
+ * @return {number} - index of entities
100
100
  */
101
101
  find(type, prop, value) {
102
- const filteredItems = [];
102
+ const filteredEntities = [];
103
103
 
104
- this.#entities.forEach((item, index) => {
105
- if (type.toUpperCase() === 'ANY' || item.type.toUpperCase() === type.toUpperCase()) {
106
- const inStore = item.properties?.has(prop);
107
- const propValue = inStore ? item.getProperty(prop) : (Object.prototype.hasOwnProperty.call(item, prop) ? item[prop] : undefined);
104
+ this.#entities.forEach((entity, index) => {
105
+ if (type.toUpperCase() === 'ANY' || entity.type.toUpperCase() === type.toUpperCase()) {
106
+ const inStore = entity.properties?.has(prop);
107
+ const propValue = inStore ? entity.getProperty(prop) : (Object.prototype.hasOwnProperty.call(entity, prop) ? entity[prop] : undefined);
108
108
  if (propValue !== undefined && propValue === value) {
109
- filteredItems.push(index);
109
+ filteredEntities.push(index);
110
110
  }
111
111
  }
112
112
  });
113
113
 
114
- return filteredItems;
114
+ return filteredEntities;
115
115
  }
116
116
 
117
117
  /** Get index of entity
@@ -124,16 +124,16 @@ export class EntityManager {
124
124
 
125
125
 
126
126
  /**
127
- * Find closest item to point
127
+ * Find closest entity to point
128
128
  * @param {Point} point
129
- * @return {number} - return index of closest item or undefined
129
+ * @return {number} - return index of closest entity or undefined
130
130
  */
131
131
  findClosest(point) {
132
132
  let delta = 1.65 / DesignCore.Core.canvas.getScale(); // find a more suitable starting value
133
- let closestItemIndex;
133
+ let closestEntityIndex;
134
134
 
135
135
  for (let i = 0; i < this.#entities.length; i++) {
136
- // check the items layer is selectable - i.e. on, thawed, etc...
136
+ // check the entities layer is selectable - i.e. on, thawed, etc...
137
137
  const layer = DesignCore.LayerManager.getItemByName(this.#entities[i].getProperty(Property.Names.LAYER));
138
138
 
139
139
  if (!layer?.isSelectable) {
@@ -144,11 +144,11 @@ export class EntityManager {
144
144
 
145
145
  if (distance < delta) {
146
146
  delta = distance;
147
- closestItemIndex = i;
147
+ closestEntityIndex = i;
148
148
  }
149
149
  }
150
150
 
151
- return closestItemIndex;
151
+ return closestEntityIndex;
152
152
  }
153
153
 
154
154
  /**
@@ -157,14 +157,14 @@ export class EntityManager {
157
157
  * @param {object} data
158
158
  */
159
159
  update(index, data) {
160
- const item = this.get(index);
160
+ const entity = this.get(index);
161
161
 
162
- if (!item) {
163
- throw Error('Item not found in scene');
162
+ if (!entity) {
163
+ throw Error('Entity not found in scene');
164
164
  }
165
165
 
166
166
  for (const property of Object.keys(data)) {
167
- item.setProperty(property, data[property]);
167
+ entity.setProperty(property, data[property]);
168
168
  }
169
169
  }
170
170
 
@@ -392,7 +392,7 @@ export class InputManager {
392
392
  }
393
393
 
394
394
  if (Input.getType(selection) === Input.Type.SINGLESELECTION) {
395
- DesignCore.Scene.selectionManager.addToSelectionSet(selection.selectedItemIndex);
395
+ DesignCore.Scene.selectionManager.addToSelectionSet(selection.selectedEntityIndex);
396
396
  }
397
397
  }
398
398
 
@@ -37,7 +37,7 @@ export class Matrix {
37
37
  };
38
38
 
39
39
  /**
40
- * Apply tranlation to matrix
40
+ * Apply translation to matrix
41
41
  * @param {number} x - translation in x
42
42
  * @param {number} y - translation in y
43
43
  */
@@ -462,7 +462,7 @@ export class Patterns {
462
462
  60, 0, 0, 4.7625, 2.749630645, -6.35, 3.175` },
463
463
 
464
464
  'HOUND': {
465
- description: 'Houndstooth check', pattern:
465
+ description: 'Hounds tooth check', pattern:
466
466
  `0, 0, 0, 6.35, 1.5875, 25.4, -12.7
467
467
  90, 0, 0, 6.35, 1.5875, 25.4, -12.7` },
468
468
 
@@ -16,12 +16,12 @@ export class PolylineUtils {
16
16
  */
17
17
  static isPointOnSegment(point, A, B) {
18
18
  if (A.bulge !== 0 && A.bulge !== undefined) {
19
- const center = A.bulgeCentrePoint(B);
20
- const radius = center.distance(A);
19
+ const centre = A.bulgeCentrePoint(B);
20
+ const radius = centre.distance(A);
21
21
  // Point must lie on the circle before checking the angular range.
22
- if (Utils.round(center.distance(point)) !== Utils.round(radius)) return false;
22
+ if (Utils.round(centre.distance(point)) !== Utils.round(radius)) return false;
23
23
  const direction = A.bulge > 0 ? 1 : -1;
24
- return point.isOnArc(A, B, center, direction);
24
+ return point.isOnArc(A, B, centre, direction);
25
25
  }
26
26
  return point.isOnLine(A, B);
27
27
  }
@@ -38,9 +38,9 @@ export class PolylineUtils {
38
38
  const B = points[segmentIndex % points.length];
39
39
 
40
40
  if (A.bulge !== 0 && A.bulge !== undefined) {
41
- const center = A.bulgeCentrePoint(B);
41
+ const centre = A.bulgeCentrePoint(B);
42
42
  const direction = A.bulge > 0 ? 1 : -1;
43
- const closest = point.closestPointOnArc(A, B, center, direction);
43
+ const closest = point.closestPointOnArc(A, B, centre, direction);
44
44
  if (closest) return closest;
45
45
  // Point not on arc — return the nearer endpoint
46
46
  return point.distance(A) < point.distance(B) ? A : B;
@@ -63,10 +63,10 @@ export class PolylineUtils {
63
63
  const B = points[segmentIndex % points.length];
64
64
 
65
65
  if (A.bulge !== 0 && A.bulge !== undefined) {
66
- const center = A.bulgeCentrePoint(B);
66
+ const centre = A.bulgeCentrePoint(B);
67
67
  const direction = A.bulge > 0 ? 1 : -1;
68
- const startAngle = center.angle(A);
69
- const pointAngle = center.angle(point);
68
+ const startAngle = centre.angle(A);
69
+ const pointAngle = centre.angle(point);
70
70
  return ((pointAngle - startAngle) * direction + 4 * Math.PI) % (2 * Math.PI);
71
71
  }
72
72
 
@@ -159,14 +159,14 @@ export class CairoRenderer extends RendererBase {
159
159
  if (!p.bulge) {
160
160
  this.#cr.lineTo(next.x, next.y);
161
161
  } else {
162
- const center = p.bulgeCentrePoint(next);
162
+ const centre = p.bulgeCentrePoint(next);
163
163
  const radius = p.bulgeRadius(next);
164
- const startAngle = center.angle(p);
165
- const endAngle = center.angle(next);
164
+ const startAngle = centre.angle(p);
165
+ const endAngle = centre.angle(next);
166
166
  if (p.bulge > 0) {
167
- this.#cr.arc(center.x, center.y, radius, startAngle, endAngle);
167
+ this.#cr.arc(centre.x, centre.y, radius, startAngle, endAngle);
168
168
  } else {
169
- this.#cr.arcNegative(center.x, center.y, radius, startAngle, endAngle);
169
+ this.#cr.arcNegative(centre.x, centre.y, radius, startAngle, endAngle);
170
170
  }
171
171
  }
172
172
  }
@@ -141,12 +141,12 @@ export class CanvasRenderer extends RendererBase {
141
141
  if (!p.bulge) {
142
142
  this.#ctx.lineTo(next.x, next.y);
143
143
  } else {
144
- const center = p.bulgeCentrePoint(next);
144
+ const centre = p.bulgeCentrePoint(next);
145
145
  const radius = p.bulgeRadius(next);
146
- const startAngle = center.angle(p);
147
- const endAngle = center.angle(next);
146
+ const startAngle = centre.angle(p);
147
+ const endAngle = centre.angle(next);
148
148
  // Canvas arc: CCW = false (default), CW = true (anticlockwise flag inverted)
149
- this.#ctx.arc(center.x, center.y, radius, startAngle, endAngle, p.bulge < 0);
149
+ this.#ctx.arc(centre.x, centre.y, radius, startAngle, endAngle, p.bulge < 0);
150
150
  }
151
151
  }
152
152
  }