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.
- package/dist/cjs/draw_symbols.js +34 -35
- package/dist/cjs/execute.js +1 -1
- package/dist/cjs/globals.js +5 -4
- package/dist/cjs/helpers.js +1 -1
- package/dist/cjs/layout.js +396 -281
- package/dist/cjs/objects/Frame.js +9 -1
- package/dist/cjs/objects/ParamDefinition.js +3 -0
- package/dist/cjs/render.js +45 -37
- package/dist/cjs/utils.js +19 -1
- package/dist/cjs/visitor.js +10 -1
- package/dist/esm/draw_symbols.mjs +34 -35
- package/dist/esm/execute.mjs +1 -1
- package/dist/esm/globals.mjs +5 -4
- package/dist/esm/helpers.mjs +1 -1
- package/dist/esm/layout.mjs +400 -285
- package/dist/esm/objects/Frame.mjs +8 -0
- package/dist/esm/objects/ParamDefinition.mjs +3 -0
- package/dist/esm/render.mjs +46 -38
- package/dist/esm/utils.mjs +16 -0
- package/dist/esm/visitor.mjs +10 -1
- package/dist/types/draw_symbols.d.ts +3 -2
- package/dist/types/globals.d.ts +1 -1
- package/dist/types/layout.d.ts +14 -33
- package/dist/types/objects/ExecutionScope.d.ts +1 -1
- package/dist/types/objects/Frame.d.ts +7 -0
- package/dist/types/objects/ParamDefinition.d.ts +1 -0
- package/dist/types/utils.d.ts +8 -0
- package/libs/lib.cst +10 -5
- package/package.json +1 -1
package/dist/cjs/draw_symbols.js
CHANGED
|
@@ -96,7 +96,7 @@ class SymbolGraphic {
|
|
|
96
96
|
const bbox = this.drawing.getBoundingBox();
|
|
97
97
|
const originSize = (0, helpers_js_1.milsToMM)(10);
|
|
98
98
|
group.circle(originSize.toNumber())
|
|
99
|
-
.translate(originSize.neg().
|
|
99
|
+
.translate(originSize.neg().half().toNumber(), originSize.neg().half().toNumber())
|
|
100
100
|
.fill('red')
|
|
101
101
|
.stroke('none');
|
|
102
102
|
group.rect(bbox.width, bbox.height)
|
|
@@ -622,6 +622,7 @@ var PlaceHolderCommands;
|
|
|
622
622
|
PlaceHolderCommands["arc"] = "arc";
|
|
623
623
|
PlaceHolderCommands["circle"] = "circle";
|
|
624
624
|
PlaceHolderCommands["rect"] = "rect";
|
|
625
|
+
PlaceHolderCommands["crect"] = "crect";
|
|
625
626
|
PlaceHolderCommands["triangle"] = "triangle";
|
|
626
627
|
PlaceHolderCommands["pin"] = "pin";
|
|
627
628
|
PlaceHolderCommands["hpin"] = "hpin";
|
|
@@ -672,7 +673,9 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
672
673
|
const defaultLineColor = globals_js_1.ColorScheme.PinLineColor;
|
|
673
674
|
drawing.addSetLineColor(defaultLineColor);
|
|
674
675
|
drawing.addSetLineWidth((0, ParamDefinition_js_1.numeric)(5));
|
|
675
|
-
|
|
676
|
+
const xBody = bodyWidth.half().neg();
|
|
677
|
+
const yBody = bodyHeight.half().neg();
|
|
678
|
+
drawing.addRectMM(xBody, yBody, bodyWidth, bodyHeight);
|
|
676
679
|
this.generateDrawingPins(drawing, bodyWidth, bodyHeight, {
|
|
677
680
|
left: leftPins, right: rightPins, top: topPins, bottom: bottomPins
|
|
678
681
|
}, defaultLineColor);
|
|
@@ -690,12 +693,12 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
690
693
|
}
|
|
691
694
|
generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, pins, defaultLineColor) {
|
|
692
695
|
const { left: leftPins, right: rightPins, top: topPins, bottom: bottomPins } = pins;
|
|
693
|
-
const leftPinStart = bodyWidthMM.neg().
|
|
694
|
-
const rightPinStart = bodyWidthMM.
|
|
695
|
-
const topPinStart = bodyHeightMM.neg().
|
|
696
|
-
const bottomPinStart = bodyHeightMM.
|
|
697
|
-
const pinStartY = bodyHeightMM.neg().
|
|
698
|
-
const pinStartX = bodyWidthMM.neg().
|
|
696
|
+
const leftPinStart = bodyWidthMM.neg().half();
|
|
697
|
+
const rightPinStart = bodyWidthMM.half();
|
|
698
|
+
const topPinStart = bodyHeightMM.neg().half();
|
|
699
|
+
const bottomPinStart = bodyHeightMM.half();
|
|
700
|
+
const pinStartY = bodyHeightMM.neg().half();
|
|
701
|
+
const pinStartX = bodyWidthMM.neg().half();
|
|
699
702
|
const tmpPinSpacing = this.pinSpacing.toNumber();
|
|
700
703
|
leftPins.forEach(pin => {
|
|
701
704
|
const position = pin.position;
|
|
@@ -770,7 +773,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
770
773
|
});
|
|
771
774
|
});
|
|
772
775
|
const instanceName = drawing.variables.get('refdes');
|
|
773
|
-
instanceName && drawing.addLabel(bodyWidthMM.neg().
|
|
776
|
+
instanceName && drawing.addLabel(bodyWidthMM.neg().half(), bodyHeightMM.neg().half().sub((0, helpers_js_1.milsToMM)(20)), instanceName, {
|
|
774
777
|
fontSize: (0, ParamDefinition_js_1.numeric)(globals_js_1.CustomSymbolRefDesSize),
|
|
775
778
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
776
779
|
});
|
|
@@ -778,7 +781,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
778
781
|
acceptedMPNKeys.some(key => {
|
|
779
782
|
const labelValue = drawing.variables.get(key);
|
|
780
783
|
if (labelValue !== undefined) {
|
|
781
|
-
drawing.addLabel(bodyWidthMM.neg().
|
|
784
|
+
drawing.addLabel(bodyWidthMM.neg().half(), bodyHeightMM.half().add((0, helpers_js_1.milsToMM)(20)), labelValue, {
|
|
782
785
|
fontSize: (0, ParamDefinition_js_1.numeric)(globals_js_1.CustomSymbolParamTextSize),
|
|
783
786
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
784
787
|
vanchor: geometry_js_1.VerticalAlign.Top,
|
|
@@ -825,12 +828,12 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
825
828
|
this.portHeight = (0, helpers_js_1.milsToMM)(50);
|
|
826
829
|
}
|
|
827
830
|
generateDrawingPins(drawing, bodyWidthMM, bodyHeightMM, pins, defaultLineColor) {
|
|
828
|
-
const leftPinStart = bodyWidthMM.neg().
|
|
829
|
-
const rightPinStart = bodyWidthMM.
|
|
830
|
-
const topPinStart = bodyHeightMM.neg().
|
|
831
|
-
const bottomPinStart = bodyHeightMM.
|
|
832
|
-
const pinStartY = bodyHeightMM.neg().
|
|
833
|
-
const pinStartX = bodyWidthMM.neg().
|
|
831
|
+
const leftPinStart = bodyWidthMM.neg().half();
|
|
832
|
+
const rightPinStart = bodyWidthMM.half();
|
|
833
|
+
const topPinStart = bodyHeightMM.neg().half();
|
|
834
|
+
const bottomPinStart = bodyHeightMM.half();
|
|
835
|
+
const pinStartY = bodyHeightMM.neg().half();
|
|
836
|
+
const pinStartX = bodyWidthMM.neg().half();
|
|
834
837
|
const tmpPinSpacing = this.pinSpacing.toNumber();
|
|
835
838
|
const { left: leftPins, right: rightPins, top: topPins, bottom: bottomPins } = pins;
|
|
836
839
|
leftPins.forEach(pin => {
|
|
@@ -963,22 +966,18 @@ class SymbolDrawing {
|
|
|
963
966
|
this.items.push(geometry_js_1.Geometry.segment([startX, startY], [startX.add(value), startY]));
|
|
964
967
|
return this;
|
|
965
968
|
}
|
|
966
|
-
addRect(
|
|
967
|
-
|
|
968
|
-
centerY = (0, helpers_js_1.milsToMM)(centerY);
|
|
969
|
-
width = (0, helpers_js_1.milsToMM)(width);
|
|
970
|
-
height = (0, helpers_js_1.milsToMM)(height);
|
|
971
|
-
return this.addRectMM(centerX, centerY, width, height);
|
|
969
|
+
addRect(x, y, width, height) {
|
|
970
|
+
return this.addRectMM((0, helpers_js_1.milsToMM)(x), (0, helpers_js_1.milsToMM)(y), (0, helpers_js_1.milsToMM)(width), (0, helpers_js_1.milsToMM)(height));
|
|
972
971
|
}
|
|
973
|
-
addRectMM(
|
|
974
|
-
const
|
|
975
|
-
const
|
|
972
|
+
addRectMM(x, y, width, height) {
|
|
973
|
+
const x2 = x.add(width);
|
|
974
|
+
const y2 = y.add(height);
|
|
976
975
|
this.items.push(geometry_js_1.Geometry.polygon([
|
|
977
|
-
[
|
|
978
|
-
[
|
|
979
|
-
[
|
|
980
|
-
[
|
|
981
|
-
[
|
|
976
|
+
[x, y],
|
|
977
|
+
[x2, y],
|
|
978
|
+
[x2, y2],
|
|
979
|
+
[x, y2],
|
|
980
|
+
[x, y]
|
|
982
981
|
]));
|
|
983
982
|
return this;
|
|
984
983
|
}
|
|
@@ -990,10 +989,10 @@ class SymbolDrawing {
|
|
|
990
989
|
width = (0, helpers_js_1.milsToMM)(width);
|
|
991
990
|
const line = geometry_js_1.Geometry.line(startX, startY, endX, endY);
|
|
992
991
|
const normLine = line.norm;
|
|
993
|
-
const dx1 = (0, ParamDefinition_js_1.numeric)(normLine.x).mul(width).
|
|
994
|
-
const dy1 = (0, ParamDefinition_js_1.numeric)(normLine.y).mul(width).
|
|
995
|
-
const dx2 = (0, ParamDefinition_js_1.numeric)(normLine.x).mul(width.neg()).
|
|
996
|
-
const dy2 = (0, ParamDefinition_js_1.numeric)(normLine.y).mul(width.neg()).
|
|
992
|
+
const dx1 = (0, ParamDefinition_js_1.numeric)(normLine.x).mul(width).half();
|
|
993
|
+
const dy1 = (0, ParamDefinition_js_1.numeric)(normLine.y).mul(width).half();
|
|
994
|
+
const dx2 = (0, ParamDefinition_js_1.numeric)(normLine.x).mul(width.neg()).half();
|
|
995
|
+
const dy2 = (0, ParamDefinition_js_1.numeric)(normLine.y).mul(width.neg()).half();
|
|
997
996
|
this.items.push(geometry_js_1.Geometry.polygon([
|
|
998
997
|
[dx1.add(startX), dy1.add(startY)],
|
|
999
998
|
[dx2.add(startX), dy2.add(startY)],
|
|
@@ -1019,7 +1018,7 @@ class SymbolDrawing {
|
|
|
1019
1018
|
return this;
|
|
1020
1019
|
}
|
|
1021
1020
|
addModulePort(x, y, width, height, portType = PinTypes_js_1.PinTypes.Any, scaleX = 1, angle = 0) {
|
|
1022
|
-
const height2 = height.
|
|
1021
|
+
const height2 = height.half();
|
|
1023
1022
|
let path = [];
|
|
1024
1023
|
const arrowSize = (0, helpers_js_1.milsToMM)(30);
|
|
1025
1024
|
if (portType === PinTypes_js_1.PinTypes.Any) {
|
package/dist/cjs/execute.js
CHANGED
|
@@ -54,7 +54,7 @@ class ExecutionContext {
|
|
|
54
54
|
console.log.apply(null, args);
|
|
55
55
|
}
|
|
56
56
|
setupRoot() {
|
|
57
|
-
const componentRoot = ClassComponent_js_1.ClassComponent.simple(globals_js_1.GlobalNames.__root, 1
|
|
57
|
+
const componentRoot = ClassComponent_js_1.ClassComponent.simple(globals_js_1.GlobalNames.__root, 1);
|
|
58
58
|
componentRoot.typeProp = globals_js_1.ComponentTypes.net;
|
|
59
59
|
componentRoot.displayProp = this.getPointSymbol();
|
|
60
60
|
this.scope.instances.set(globals_js_1.GlobalNames.__root, componentRoot);
|
package/dist/cjs/globals.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RenderFlags = exports.GlobalDocumentName = exports.ModuleContainsKeyword = exports.FrameType = exports.BlockTypes = exports.ReferenceTypes = exports.ComponentTypes = exports.ColorScheme = exports.PortPaddingVertical = exports.PortPaddingHorizontal = exports.PortArrowSize = exports.junctionSize = exports.defaultFontSize = exports.defaultFontBold = exports.defaultFont = exports.displayUnits = exports.defaultFrameTitleTextSize = exports.CustomSymbolParamTextSize = exports.CustomSymbolRefDesSize = exports.CustomSymbolPinIdSize = exports.CustomSymbolPinTextSize = exports.defaultPageSpacingMM = exports.defaultPageMarginMM = exports.defaultPinIdTextSize = exports.defaultPinNameTextSize = exports.defaultWireLineWidth = exports.defaultSymbolLineWidth = exports.fontDisplayScale = exports.defaultZoomScale = exports.defaultGridSizeUnits = exports.portHeight = exports.portWidth = exports.PxToMM = exports.MMToPt = exports.MMToPx = exports.MilsToMM = exports.WireAutoDirection = exports.LengthUnit = exports.SymbolPinSide = exports.LayoutDirection = exports.ParamKeys = exports.NoNetText = exports.GlobalNames = void 0;
|
|
4
|
+
const ParamDefinition_1 = require("./objects/ParamDefinition");
|
|
4
5
|
var GlobalNames;
|
|
5
6
|
(function (GlobalNames) {
|
|
6
7
|
GlobalNames["__root"] = "__root";
|
|
@@ -45,11 +46,11 @@ exports.MMToPt = 2.8346456693;
|
|
|
45
46
|
exports.PxToMM = 0.2645833;
|
|
46
47
|
exports.portWidth = 20;
|
|
47
48
|
exports.portHeight = 2;
|
|
48
|
-
exports.defaultGridSizeUnits = exports.MilsToMM
|
|
49
|
+
exports.defaultGridSizeUnits = (0, ParamDefinition_1.numeric)(exports.MilsToMM).mul(100).toNumber();
|
|
49
50
|
exports.defaultZoomScale = 2.5;
|
|
50
51
|
exports.fontDisplayScale = 0.032;
|
|
51
|
-
exports.defaultSymbolLineWidth = exports.MilsToMM
|
|
52
|
-
exports.defaultWireLineWidth = exports.MilsToMM
|
|
52
|
+
exports.defaultSymbolLineWidth = (0, ParamDefinition_1.numeric)(exports.MilsToMM).mul(6).toNumber();
|
|
53
|
+
exports.defaultWireLineWidth = (0, ParamDefinition_1.numeric)(exports.MilsToMM).mul(6).toNumber();
|
|
53
54
|
exports.defaultPinNameTextSize = 40;
|
|
54
55
|
exports.defaultPinIdTextSize = 30;
|
|
55
56
|
exports.defaultPageMarginMM = 10;
|
|
@@ -63,7 +64,7 @@ exports.displayUnits = LengthUnit.mils;
|
|
|
63
64
|
exports.defaultFont = 'Arial';
|
|
64
65
|
exports.defaultFontBold = 'Arial';
|
|
65
66
|
exports.defaultFontSize = 10;
|
|
66
|
-
exports.junctionSize = exports.MilsToMM
|
|
67
|
+
exports.junctionSize = (0, ParamDefinition_1.numeric)(exports.MilsToMM).mul(20);
|
|
67
68
|
exports.PortArrowSize = exports.MilsToMM * 50;
|
|
68
69
|
exports.PortPaddingHorizontal = exports.MilsToMM * 10;
|
|
69
70
|
exports.PortPaddingVertical = exports.MilsToMM * 10;
|
package/dist/cjs/helpers.js
CHANGED
|
@@ -349,7 +349,7 @@ function milsToMM(value) {
|
|
|
349
349
|
if (typeof value === 'number') {
|
|
350
350
|
value = (0, utils_js_1.resolveToNumericValue)(new big_js_1.default(value));
|
|
351
351
|
}
|
|
352
|
-
return (0, utils_js_1.resolveToNumericValue)(value.toBigNumber().mul(new big_js_1.default(globals_js_1.MilsToMM)));
|
|
352
|
+
return (0, utils_js_1.resolveToNumericValue)(value.toBigNumber().mul(new big_js_1.default(globals_js_1.MilsToMM)).round(6));
|
|
353
353
|
}
|
|
354
354
|
exports.milsToMM = milsToMM;
|
|
355
355
|
function pxToMM(value) {
|