circuitscript 0.1.2 → 0.1.3

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FramePlotDirection = exports.FrameParamKeys = exports.Frame = void 0;
3
+ exports.FramePlotDirection = exports.FrameParamKeys = exports.FixedFrameIds = exports.Frame = void 0;
4
4
  const globals_js_1 = require("../globals.js");
5
5
  class Frame {
6
6
  constructor(frameId, frameType = globals_js_1.FrameType.Frame) {
@@ -10,6 +10,11 @@ class Frame {
10
10
  }
11
11
  }
12
12
  exports.Frame = Frame;
13
+ var FixedFrameIds;
14
+ (function (FixedFrameIds) {
15
+ FixedFrameIds[FixedFrameIds["BaseFrame"] = -1] = "BaseFrame";
16
+ FixedFrameIds[FixedFrameIds["FrameIdNotUsed"] = -2] = "FrameIdNotUsed";
17
+ })(FixedFrameIds || (exports.FixedFrameIds = FixedFrameIds = {}));
13
18
  var FrameParamKeys;
14
19
  (function (FrameParamKeys) {
15
20
  FrameParamKeys["Title"] = "title";
@@ -20,6 +25,9 @@ var FrameParamKeys;
20
25
  FrameParamKeys["Height"] = "height";
21
26
  FrameParamKeys["PaperSize"] = "paper_size";
22
27
  FrameParamKeys["SheetType"] = "sheet_type";
28
+ FrameParamKeys["TitleAlign"] = "title_align";
29
+ FrameParamKeys["HorizontalAlign"] = "align";
30
+ FrameParamKeys["VerticalAlign"] = "valign";
23
31
  FrameParamKeys["SheetNumber"] = "sheet_number";
24
32
  FrameParamKeys["SheetTotal"] = "sheet_total";
25
33
  })(FrameParamKeys || (exports.FrameParamKeys = FrameParamKeys = {}));
@@ -54,6 +54,9 @@ class NumericValue {
54
54
  }
55
55
  return (0, utils_1.resolveToNumericValue)(this.toBigNumber().div(value.toBigNumber()));
56
56
  }
57
+ half() {
58
+ return this.div(2);
59
+ }
57
60
  mul(value) {
58
61
  if (typeof value === 'number') {
59
62
  value = numeric(value);
@@ -34,7 +34,7 @@ function renderSheetsToSVG(sheetFrames, logger) {
34
34
  let extendGrid = true;
35
35
  let xOffset = 0;
36
36
  let yOffset = 0;
37
- let sheetYOffset = 0;
37
+ let sheetYOffset = (0, ParamDefinition_js_1.numeric)(0);
38
38
  if (sheet.frame.frame) {
39
39
  logger.add('drawing frame');
40
40
  const frameComponent = sheet.frame.frame.parameters
@@ -44,29 +44,33 @@ function renderSheetsToSVG(sheetFrames, logger) {
44
44
  throw 'Invalid graphic object for sheet frame';
45
45
  }
46
46
  const frameRects = (0, layout_js_1.ExtractDrawingRects)(frameComponent.displayProp) ?? [];
47
- let originalWidthMM = 0;
48
- let originalHeightMM = 0;
49
- let widthMM = 0;
50
- let heightMM = 0;
51
- if (frameRects[0]) {
52
- originalWidthMM = (0, helpers_js_1.milsToMM)(frameRects[0].width).toNumber();
53
- originalHeightMM = (0, helpers_js_1.milsToMM)(frameRects[0].height).toNumber();
54
- logger.add('first frame size: ' + originalWidthMM + ' ' + originalHeightMM);
47
+ let originalWidthMM = (0, ParamDefinition_js_1.numeric)(0);
48
+ let originalHeightMM = (0, ParamDefinition_js_1.numeric)(0);
49
+ let widthMM = (0, ParamDefinition_js_1.numeric)(0);
50
+ let heightMM = (0, ParamDefinition_js_1.numeric)(0);
51
+ const paperRect = frameRects.find(item => item.className === 'paper-area');
52
+ const plotRect = frameRects.find(item => item.className === 'plot-area');
53
+ if (paperRect) {
54
+ originalWidthMM = (0, helpers_js_1.milsToMM)(paperRect.width);
55
+ originalHeightMM = (0, helpers_js_1.milsToMM)(paperRect.height);
56
+ logger.add('first frame size: ' + originalWidthMM.toNumber()
57
+ + ' ' + originalHeightMM.toNumber());
55
58
  }
56
- if (frameRects[1]) {
57
- widthMM = (0, helpers_js_1.milsToMM)(frameRects[1].width).toNumber();
58
- heightMM = (0, helpers_js_1.milsToMM)(frameRects[1].height).toNumber();
59
- logger.add('second frame size: ' + widthMM + ' ' + heightMM);
59
+ if (plotRect) {
60
+ widthMM = (0, helpers_js_1.milsToMM)(plotRect.width);
61
+ heightMM = (0, helpers_js_1.milsToMM)(plotRect.height);
62
+ logger.add('second frame size: ' + widthMM.toNumber()
63
+ + ' ' + heightMM.toNumber());
60
64
  }
61
- xOffset = (originalWidthMM - widthMM) / 2;
62
- yOffset = (originalHeightMM - heightMM) / 2;
65
+ xOffset = (originalWidthMM.sub(widthMM)).half().toNumber();
66
+ yOffset = (originalHeightMM.sub(heightMM)).half().toNumber();
63
67
  logger.add('offset', xOffset, yOffset);
64
- sheetYOffset = index * (originalHeightMM + globals_js_1.defaultPageSpacingMM);
68
+ sheetYOffset = originalHeightMM.add(globals_js_1.defaultPageSpacingMM).mul(index);
65
69
  gridBounds = {
66
70
  xmin: 0,
67
71
  ymin: 0,
68
- xmax: widthMM,
69
- ymax: heightMM
72
+ xmax: widthMM.toNumber(),
73
+ ymax: heightMM.toNumber()
70
74
  };
71
75
  extendGrid = false;
72
76
  }
@@ -76,7 +80,7 @@ function renderSheetsToSVG(sheetFrames, logger) {
76
80
  const sheetElements = sheetGroup.group().addClass('sheet-elements');
77
81
  generateSVGChild(sheetElements, components, wires, junctions, mergedWires, allFrames, textObjects, gridBounds, extendGrid, logger);
78
82
  sheetElements.translate(xOffset, yOffset);
79
- sheetGroup.translate(0, sheetYOffset);
83
+ sheetGroup.translate(0, sheetYOffset.toNumber());
80
84
  });
81
85
  return canvas;
82
86
  }
@@ -186,10 +190,13 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
186
190
  })
187
191
  .fill('none');
188
192
  });
193
+ const halfJunctionSize = globals_js_1.junctionSize.half();
189
194
  intersectPoints.forEach(point => {
190
- const [x, y, count] = point;
191
- mergedWireGroup.circle(globals_js_1.junctionSize)
192
- .translate(x - globals_js_1.junctionSize / 2, y - globals_js_1.junctionSize / 2)
195
+ const [x, y,] = point;
196
+ const translateX = (0, ParamDefinition_js_1.numeric)(x).sub(halfJunctionSize);
197
+ const translateY = (0, ParamDefinition_js_1.numeric)(y).sub(halfJunctionSize);
198
+ mergedWireGroup.circle(globals_js_1.junctionSize.toNumber())
199
+ .translate(translateX.toNumber(), translateY.toNumber())
193
200
  .fill(globals_js_1.ColorScheme.JunctionColor)
194
201
  .stroke('none');
195
202
  });
@@ -204,10 +211,10 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
204
211
  }
205
212
  else {
206
213
  if (borderWidth.toNumber() > 0) {
207
- if (item.type === layout_js_1.RenderFrameType.Container) {
214
+ if (item.renderType === layout_js_1.RenderFrameType.Container) {
208
215
  strokeColor = '#111';
209
216
  }
210
- else if (item.type === layout_js_1.RenderFrameType.Elements) {
217
+ else if (item.renderType === layout_js_1.RenderFrameType.Elements) {
211
218
  strokeColor = '#aaa';
212
219
  if (!globals_js_1.RenderFlags.ShowElementFrames) {
213
220
  return;
@@ -239,33 +246,34 @@ function drawGrid(group, canvasSize, extendGrid, logger) {
239
246
  const gridSize = globals_js_1.defaultGridSizeUnits;
240
247
  const { xmin, ymin, xmax, ymax } = canvasSize;
241
248
  const extraValue = extendGrid ? 1 : 0;
242
- const gridStartX = (Math.floor(xmin / gridSize) - extraValue) * gridSize;
243
- const gridStartY = (Math.floor(ymin / gridSize) - extraValue) * gridSize;
249
+ const gridStartX = ((0, ParamDefinition_js_1.numeric)(Math.floor(xmin / gridSize)).sub(extraValue)).mul(gridSize);
250
+ const gridStartY = ((0, ParamDefinition_js_1.numeric)(Math.floor(ymin / gridSize)).sub(extraValue)).mul(gridSize);
244
251
  const gridEndX = extendGrid
245
- ? (Math.ceil(xmax / gridSize) + extraValue) * gridSize
246
- : (xmax - xmin);
252
+ ? ((0, ParamDefinition_js_1.numeric)(Math.ceil(xmax / gridSize)).add(extraValue)).mul(gridSize)
253
+ : ((0, ParamDefinition_js_1.numeric)(xmax).sub(xmin));
247
254
  const gridEndY = extendGrid
248
- ? (Math.ceil(ymax / gridSize) + extraValue) * gridSize
249
- : (ymax - ymin);
250
- const numCols = Math.floor((gridEndX - gridStartX) / gridSize)
255
+ ? ((0, ParamDefinition_js_1.numeric)(Math.ceil(ymax / gridSize)).add(extraValue)).mul(gridSize)
256
+ : ((0, ParamDefinition_js_1.numeric)(ymax).sub(ymin));
257
+ const numCols = Math.floor(gridEndX.sub(gridStartX).div(gridSize).toNumber())
251
258
  + (extendGrid ? 1 : 0);
252
259
  const originSize = (0, helpers_js_1.milsToMM)(10).toNumber();
253
260
  globals_js_1.RenderFlags.ShowGridOrigin && group.circle(originSize)
254
261
  .translate(-originSize / 2, -originSize / 2)
255
262
  .stroke('none').fill('blue');
256
263
  const lines = [];
257
- const smallOffset = (0, helpers_js_1.milsToMM)(3).toNumber();
258
- const startY = gridStartY - smallOffset / 2;
259
- const endY = gridEndY + smallOffset;
264
+ const smallOffset = (0, helpers_js_1.milsToMM)(3);
265
+ const startY = gridStartY.sub(smallOffset.half());
266
+ const endY = gridEndY.add(smallOffset);
267
+ const numericGridSize = (0, ParamDefinition_js_1.numeric)(gridSize);
260
268
  for (let i = 0; i < numCols; i++) {
261
- const startX = gridStartX + i * gridSize;
262
- lines.push(`M ${startX} ${startY} L ${startX} ${endY}`);
269
+ const startX = gridStartX.add(numericGridSize.mul(i)).toNumber();
270
+ lines.push(`M ${startX} ${startY.toNumber()} L ${startX} ${endY.toNumber()}`);
263
271
  }
264
272
  const strokeSize = (0, helpers_js_1.milsToMM)(3);
265
273
  group.addClass('grid')
266
274
  .path(lines.join(" "))
267
275
  .attr({
268
- 'stroke-dasharray': `${strokeSize.toNumber()},${gridSize - strokeSize.toNumber()}`,
276
+ 'stroke-dasharray': `${strokeSize.toNumber()},${numericGridSize.sub(strokeSize).toNumber()}`,
269
277
  })
270
278
  .stroke({
271
279
  width: strokeSize.toNumber(),
package/dist/cjs/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveToNumericValue = exports.getNumberExponentialText = exports.getNumberExponential = exports.combineMaps = exports.throwWithContext = exports.roundValue = exports.getPortType = exports.getBoundsSize = exports.toNearestGrid = exports.resizeToNearestGrid = exports.printBounds = exports.resizeBounds = exports.SimpleStopwatch = void 0;
3
+ exports.areasOverlap = exports.isPointWithinArea = exports.resolveToNumericValue = exports.getNumberExponentialText = exports.getNumberExponential = exports.combineMaps = exports.throwWithContext = exports.roundValue = exports.getPortType = exports.getBoundsSize = exports.toNearestGrid = exports.resizeToNearestGrid = exports.printBounds = exports.resizeBounds = exports.SimpleStopwatch = void 0;
4
4
  const big_js_1 = require("big.js");
5
5
  const ParamDefinition_1 = require("./objects/ParamDefinition");
6
6
  class SimpleStopwatch {
@@ -166,3 +166,21 @@ function resolveToNumericValue(value) {
166
166
  return new ParamDefinition_1.NumericValue(useValue, prefixPart * 3);
167
167
  }
168
168
  exports.resolveToNumericValue = resolveToNumericValue;
169
+ function isPointWithinArea(point, bounds) {
170
+ const [xPt, yPt] = point;
171
+ const [xmin, ymin, xmax, ymax] = bounds;
172
+ return (xPt > xmin && xPt < xmax && yPt > ymin && yPt < ymax);
173
+ }
174
+ exports.isPointWithinArea = isPointWithinArea;
175
+ function areasOverlap(area1, area2) {
176
+ const [xmin, ymin, xmax, ymax] = area1;
177
+ const pt1 = [xmin, ymin];
178
+ const pt2 = [xmin, ymax];
179
+ const pt3 = [xmax, ymin];
180
+ const pt4 = [xmax, ymax];
181
+ return isPointWithinArea(pt1, area2)
182
+ || isPointWithinArea(pt2, area2)
183
+ || isPointWithinArea(pt3, area2)
184
+ || isPointWithinArea(pt4, area2);
185
+ }
186
+ exports.areasOverlap = areasOverlap;
@@ -194,7 +194,16 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
194
194
  }
195
195
  return accum;
196
196
  }, []);
197
- accum.push([commandName, positionParams, keywordParams, item]);
197
+ let useCommandName = commandName;
198
+ let usePositionParams = positionParams;
199
+ if (commandName === draw_symbols_js_1.PlaceHolderCommands.crect) {
200
+ useCommandName = draw_symbols_js_1.PlaceHolderCommands.rect;
201
+ const [centerX, centerY, width, height] = positionParams;
202
+ const newX = centerX.sub(width.half());
203
+ const newY = centerY.sub(height.half());
204
+ usePositionParams = [newX, newY, width, height];
205
+ }
206
+ accum.push([useCommandName, usePositionParams, keywordParams, item]);
198
207
  }
199
208
  return accum;
200
209
  }, []);
@@ -94,7 +94,7 @@ export class SymbolGraphic {
94
94
  const bbox = this.drawing.getBoundingBox();
95
95
  const originSize = milsToMM(10);
96
96
  group.circle(originSize.toNumber())
97
- .translate(originSize.neg().div(2).toNumber(), originSize.neg().div(2).toNumber())
97
+ .translate(originSize.neg().half().toNumber(), originSize.neg().half().toNumber())
98
98
  .fill('red')
99
99
  .stroke('none');
100
100
  group.rect(bbox.width, bbox.height)
@@ -618,6 +618,7 @@ export var PlaceHolderCommands;
618
618
  PlaceHolderCommands["arc"] = "arc";
619
619
  PlaceHolderCommands["circle"] = "circle";
620
620
  PlaceHolderCommands["rect"] = "rect";
621
+ PlaceHolderCommands["crect"] = "crect";
621
622
  PlaceHolderCommands["triangle"] = "triangle";
622
623
  PlaceHolderCommands["pin"] = "pin";
623
624
  PlaceHolderCommands["hpin"] = "hpin";
@@ -669,7 +670,9 @@ export class SymbolCustom extends SymbolGraphic {
669
670
  const defaultLineColor = ColorScheme.PinLineColor;
670
671
  drawing.addSetLineColor(defaultLineColor);
671
672
  drawing.addSetLineWidth(numeric(5));
672
- drawing.addRectMM(numeric(0), numeric(0), bodyWidth, bodyHeight);
673
+ const xBody = bodyWidth.half().neg();
674
+ const yBody = bodyHeight.half().neg();
675
+ drawing.addRectMM(xBody, yBody, bodyWidth, bodyHeight);
673
676
  this.generateDrawingPins(drawing, bodyWidth, bodyHeight, {
674
677
  left: leftPins, right: rightPins, top: topPins, bottom: bottomPins
675
678
  }, defaultLineColor);
@@ -687,12 +690,12 @@ export class SymbolCustom extends SymbolGraphic {
687
690
  }
688
691
  generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, pins, defaultLineColor) {
689
692
  const { left: leftPins, right: rightPins, top: topPins, bottom: bottomPins } = pins;
690
- const leftPinStart = bodyWidthMM.neg().div(2);
691
- const rightPinStart = bodyWidthMM.div(2);
692
- const topPinStart = bodyHeightMM.neg().div(2);
693
- const bottomPinStart = bodyHeightMM.div(2);
694
- const pinStartY = bodyHeightMM.neg().div(2);
695
- const pinStartX = bodyWidthMM.neg().div(2);
693
+ const leftPinStart = bodyWidthMM.neg().half();
694
+ const rightPinStart = bodyWidthMM.half();
695
+ const topPinStart = bodyHeightMM.neg().half();
696
+ const bottomPinStart = bodyHeightMM.half();
697
+ const pinStartY = bodyHeightMM.neg().half();
698
+ const pinStartX = bodyWidthMM.neg().half();
696
699
  const tmpPinSpacing = this.pinSpacing.toNumber();
697
700
  leftPins.forEach(pin => {
698
701
  const position = pin.position;
@@ -767,7 +770,7 @@ export class SymbolCustom extends SymbolGraphic {
767
770
  });
768
771
  });
769
772
  const instanceName = drawing.variables.get('refdes');
770
- instanceName && drawing.addLabel(bodyWidthMM.neg().div(2), bodyHeightMM.neg().div(2).sub(milsToMM(20)), instanceName, {
773
+ instanceName && drawing.addLabel(bodyWidthMM.neg().half(), bodyHeightMM.neg().half().sub(milsToMM(20)), instanceName, {
771
774
  fontSize: numeric(CustomSymbolRefDesSize),
772
775
  anchor: HorizontalAlign.Left,
773
776
  });
@@ -775,7 +778,7 @@ export class SymbolCustom extends SymbolGraphic {
775
778
  acceptedMPNKeys.some(key => {
776
779
  const labelValue = drawing.variables.get(key);
777
780
  if (labelValue !== undefined) {
778
- drawing.addLabel(bodyWidthMM.neg().div(2), bodyHeightMM.div(2).add(milsToMM(20)), labelValue, {
781
+ drawing.addLabel(bodyWidthMM.neg().half(), bodyHeightMM.half().add(milsToMM(20)), labelValue, {
779
782
  fontSize: numeric(CustomSymbolParamTextSize),
780
783
  anchor: HorizontalAlign.Left,
781
784
  vanchor: VerticalAlign.Top,
@@ -818,12 +821,12 @@ export class SymbolCustomModule extends SymbolCustom {
818
821
  portWidth = milsToMM(100);
819
822
  portHeight = milsToMM(50);
820
823
  generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, pins, defaultLineColor) {
821
- const leftPinStart = bodyWidthMM.neg().div(2);
822
- const rightPinStart = bodyWidthMM.div(2);
823
- const topPinStart = bodyHeightMM.neg().div(2);
824
- const bottomPinStart = bodyHeightMM.div(2);
825
- const pinStartY = bodyHeightMM.neg().div(2);
826
- const pinStartX = bodyWidthMM.neg().div(2);
824
+ const leftPinStart = bodyWidthMM.neg().half();
825
+ const rightPinStart = bodyWidthMM.half();
826
+ const topPinStart = bodyHeightMM.neg().half();
827
+ const bottomPinStart = bodyHeightMM.half();
828
+ const pinStartY = bodyHeightMM.neg().half();
829
+ const pinStartX = bodyWidthMM.neg().half();
827
830
  const tmpPinSpacing = this.pinSpacing.toNumber();
828
831
  const { left: leftPins, right: rightPins, top: topPins, bottom: bottomPins } = pins;
829
832
  leftPins.forEach(pin => {
@@ -953,22 +956,18 @@ export class SymbolDrawing {
953
956
  this.items.push(Geometry.segment([startX, startY], [startX.add(value), startY]));
954
957
  return this;
955
958
  }
956
- addRect(centerX, centerY, width, height) {
957
- centerX = milsToMM(centerX);
958
- centerY = milsToMM(centerY);
959
- width = milsToMM(width);
960
- height = milsToMM(height);
961
- return this.addRectMM(centerX, centerY, width, height);
959
+ addRect(x, y, width, height) {
960
+ return this.addRectMM(milsToMM(x), milsToMM(y), milsToMM(width), milsToMM(height));
962
961
  }
963
- addRectMM(centerX, centerY, width, height) {
964
- const width2 = width.div(2);
965
- const height2 = height.div(2);
962
+ addRectMM(x, y, width, height) {
963
+ const x2 = x.add(width);
964
+ const y2 = y.add(height);
966
965
  this.items.push(Geometry.polygon([
967
- [centerX.sub(width2), centerY.sub(height2)],
968
- [centerX.add(width2), centerY.sub(height2)],
969
- [centerX.add(width2), centerY.add(height2)],
970
- [centerX.sub(width2), centerY.add(height2)],
971
- [centerX.sub(width2), centerY.sub(height2)]
966
+ [x, y],
967
+ [x2, y],
968
+ [x2, y2],
969
+ [x, y2],
970
+ [x, y]
972
971
  ]));
973
972
  return this;
974
973
  }
@@ -980,10 +979,10 @@ export class SymbolDrawing {
980
979
  width = milsToMM(width);
981
980
  const line = Geometry.line(startX, startY, endX, endY);
982
981
  const normLine = line.norm;
983
- const dx1 = numeric(normLine.x).mul(width).div(2);
984
- const dy1 = numeric(normLine.y).mul(width).div(2);
985
- const dx2 = numeric(normLine.x).mul(width.neg()).div(2);
986
- const dy2 = numeric(normLine.y).mul(width.neg()).div(2);
982
+ const dx1 = numeric(normLine.x).mul(width).half();
983
+ const dy1 = numeric(normLine.y).mul(width).half();
984
+ const dx2 = numeric(normLine.x).mul(width.neg()).half();
985
+ const dy2 = numeric(normLine.y).mul(width.neg()).half();
987
986
  this.items.push(Geometry.polygon([
988
987
  [dx1.add(startX), dy1.add(startY)],
989
988
  [dx2.add(startX), dy2.add(startY)],
@@ -1009,7 +1008,7 @@ export class SymbolDrawing {
1009
1008
  return this;
1010
1009
  }
1011
1010
  addModulePort(x, y, width, height, portType = PinTypes.Any, scaleX = 1, angle = 0) {
1012
- const height2 = height.div(2);
1011
+ const height2 = height.half();
1013
1012
  let path = [];
1014
1013
  const arrowSize = milsToMM(30);
1015
1014
  if (portType === PinTypes.Any) {
@@ -58,7 +58,7 @@ export class ExecutionContext {
58
58
  console.log.apply(null, args);
59
59
  }
60
60
  setupRoot() {
61
- const componentRoot = ClassComponent.simple(GlobalNames.__root, 1, '__root');
61
+ const componentRoot = ClassComponent.simple(GlobalNames.__root, 1);
62
62
  componentRoot.typeProp = ComponentTypes.net;
63
63
  componentRoot.displayProp = this.getPointSymbol();
64
64
  this.scope.instances.set(GlobalNames.__root, componentRoot);
@@ -1,3 +1,4 @@
1
+ import { numeric } from "./objects/ParamDefinition";
1
2
  export var GlobalNames;
2
3
  (function (GlobalNames) {
3
4
  GlobalNames["__root"] = "__root";
@@ -42,11 +43,11 @@ export const MMToPt = 2.8346456693;
42
43
  export const PxToMM = 0.2645833;
43
44
  export const portWidth = 20;
44
45
  export const portHeight = 2;
45
- export const defaultGridSizeUnits = MilsToMM * 100;
46
+ export const defaultGridSizeUnits = numeric(MilsToMM).mul(100).toNumber();
46
47
  export const defaultZoomScale = 2.5;
47
48
  export const fontDisplayScale = 0.032;
48
- export const defaultSymbolLineWidth = MilsToMM * 6;
49
- export const defaultWireLineWidth = MilsToMM * 6;
49
+ export const defaultSymbolLineWidth = numeric(MilsToMM).mul(6).toNumber();
50
+ export const defaultWireLineWidth = numeric(MilsToMM).mul(6).toNumber();
50
51
  export const defaultPinNameTextSize = 40;
51
52
  export const defaultPinIdTextSize = 30;
52
53
  export const defaultPageMarginMM = 10;
@@ -60,7 +61,7 @@ export const displayUnits = LengthUnit.mils;
60
61
  export const defaultFont = 'Arial';
61
62
  export const defaultFontBold = 'Arial';
62
63
  export const defaultFontSize = 10;
63
- export const junctionSize = MilsToMM * 20;
64
+ export const junctionSize = numeric(MilsToMM).mul(20);
64
65
  export const PortArrowSize = MilsToMM * 50;
65
66
  export const PortPaddingHorizontal = MilsToMM * 10;
66
67
  export const PortPaddingVertical = MilsToMM * 10;
@@ -333,7 +333,7 @@ export function milsToMM(value) {
333
333
  if (typeof value === 'number') {
334
334
  value = resolveToNumericValue(new Big(value));
335
335
  }
336
- return resolveToNumericValue(value.toBigNumber().mul(new Big(MilsToMM)));
336
+ return resolveToNumericValue(value.toBigNumber().mul(new Big(MilsToMM)).round(6));
337
337
  }
338
338
  export function pxToMM(value) {
339
339
  return value * PxToMM;