circuitscript 0.0.27 → 0.0.29
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 +61 -24
- package/dist/cjs/globals.js +8 -4
- package/dist/cjs/regenerate-tests.js +24 -15
- package/dist/cjs/render.js +4 -3
- package/dist/esm/draw_symbols.mjs +63 -26
- package/dist/esm/globals.mjs +7 -3
- package/dist/esm/regenerate-tests.mjs +25 -16
- package/dist/esm/render.mjs +5 -4
- package/dist/types/draw_symbols.d.ts +9 -4
- package/dist/types/geometry.d.ts +1 -0
- package/dist/types/globals.d.ts +7 -3
- package/libs/lib.cst +24 -20
- package/package.json +1 -1
package/dist/cjs/draw_symbols.js
CHANGED
|
@@ -106,17 +106,20 @@ class SymbolGraphic {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
drawPins(group) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
const pinPaths = this.drawing.getPinsPath();
|
|
110
|
+
pinPaths.forEach(({ path, lineColor }) => {
|
|
111
|
+
group.path(path)
|
|
112
|
+
.stroke({
|
|
113
|
+
width: defaultSymbolLineWidth,
|
|
114
|
+
color: lineColor
|
|
115
|
+
});
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
118
|
drawLabels(group) {
|
|
116
119
|
const labels = this.drawing.getLabels();
|
|
117
120
|
labels.forEach(label => {
|
|
118
121
|
const tmpLabel = label;
|
|
119
|
-
const { fontSize = 10, anchor = geometry_js_1.HorizontalAlign.Left, vanchor = geometry_js_1.VerticalAlign.Bottom, fontWeight = 'regular', angle: labelAngle = 0, } = tmpLabel.style ?? {};
|
|
122
|
+
const { fontSize = 10, anchor = geometry_js_1.HorizontalAlign.Left, vanchor = geometry_js_1.VerticalAlign.Bottom, fontWeight = 'regular', angle: labelAngle = 0, textColor = "#333", } = tmpLabel.style ?? {};
|
|
120
123
|
let anchorStyle = 'start';
|
|
121
124
|
let dominantBaseline = 'auto';
|
|
122
125
|
let useAnchor = anchor;
|
|
@@ -158,7 +161,7 @@ class SymbolGraphic {
|
|
|
158
161
|
const useFont = globals_js_1.defaultFont;
|
|
159
162
|
const textContainer = group.group();
|
|
160
163
|
const text = textContainer.text(tmpLabel.text)
|
|
161
|
-
.fill(
|
|
164
|
+
.fill(textColor)
|
|
162
165
|
.font({
|
|
163
166
|
family: useFont,
|
|
164
167
|
size: fontSize,
|
|
@@ -273,8 +276,14 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
273
276
|
drawing.angle = this._angle;
|
|
274
277
|
drawing.flipX = this._flipX;
|
|
275
278
|
drawing.flipY = this._flipY;
|
|
276
|
-
const commands =
|
|
279
|
+
const commands = [
|
|
280
|
+
[PlaceHolderCommands.lineColor, [globals_js_1.ColorScheme.PinLineColor], {}],
|
|
281
|
+
[PlaceHolderCommands.textColor, [globals_js_1.ColorScheme.PinNameColor], {}],
|
|
282
|
+
...drawing.getCommands()
|
|
283
|
+
];
|
|
277
284
|
drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
|
|
285
|
+
let lineColor = "#333";
|
|
286
|
+
let textColor = "#333";
|
|
278
287
|
commands.forEach(([commandName, positionParams, keywordParams]) => {
|
|
279
288
|
switch (commandName) {
|
|
280
289
|
case PlaceHolderCommands.rect:
|
|
@@ -304,6 +313,11 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
304
313
|
break;
|
|
305
314
|
case PlaceHolderCommands.lineColor:
|
|
306
315
|
drawing.addSetLineColor(...positionParams);
|
|
316
|
+
lineColor = positionParams[0];
|
|
317
|
+
break;
|
|
318
|
+
case PlaceHolderCommands.textColor:
|
|
319
|
+
drawing.addSetTextColor(...positionParams);
|
|
320
|
+
textColor = positionParams[0];
|
|
307
321
|
break;
|
|
308
322
|
case PlaceHolderCommands.arc:
|
|
309
323
|
drawing.addArc(...positionParams);
|
|
@@ -318,11 +332,14 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
318
332
|
case PlaceHolderCommands.hpin:
|
|
319
333
|
case PlaceHolderCommands.vpin:
|
|
320
334
|
{
|
|
321
|
-
this.drawPinParams(drawing, commandName, keywordParams, positionParams);
|
|
335
|
+
this.drawPinParams(drawing, commandName, keywordParams, positionParams, lineColor, textColor);
|
|
322
336
|
break;
|
|
323
337
|
}
|
|
324
338
|
case PlaceHolderCommands.label: {
|
|
325
339
|
const style = this.parseLabelStyle(keywordParams);
|
|
340
|
+
if (style['textColor'] === undefined) {
|
|
341
|
+
style['textColor'] = textColor;
|
|
342
|
+
}
|
|
326
343
|
positionParams = [...positionParams];
|
|
327
344
|
positionParams.push(style);
|
|
328
345
|
const labelId = positionParams[0];
|
|
@@ -353,7 +370,7 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
353
370
|
drawing.log("=== end generate drawing ===");
|
|
354
371
|
}
|
|
355
372
|
parseLabelStyle(keywordParams) {
|
|
356
|
-
const keywords = ['fontSize', 'anchor', 'vanchor', 'angle'];
|
|
373
|
+
const keywords = ['fontSize', 'anchor', 'vanchor', 'angle', 'textColor'];
|
|
357
374
|
const style = {};
|
|
358
375
|
keywords.forEach(item => {
|
|
359
376
|
if (keywordParams.has(item)) {
|
|
@@ -362,13 +379,15 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
362
379
|
});
|
|
363
380
|
return style;
|
|
364
381
|
}
|
|
365
|
-
drawPinParams(drawing, commandName, keywordParams, positionParams) {
|
|
382
|
+
drawPinParams(drawing, commandName, keywordParams, positionParams, lineColor, pinNameColor) {
|
|
366
383
|
drawing.log('add pin', ...positionParams);
|
|
367
384
|
const keywordDisplayPinId = 'display_pin_id';
|
|
368
385
|
let displayPinId = true;
|
|
369
|
-
if (keywordParams.has(keywordDisplayPinId)
|
|
370
|
-
|
|
371
|
-
|
|
386
|
+
if (keywordParams.has(keywordDisplayPinId)) {
|
|
387
|
+
const value = keywordParams.get(keywordDisplayPinId);
|
|
388
|
+
if (value === 0 || value === false) {
|
|
389
|
+
displayPinId = false;
|
|
390
|
+
}
|
|
372
391
|
}
|
|
373
392
|
let pinNameParam = null;
|
|
374
393
|
let pinType = PinTypes_js_1.PinTypes.Any;
|
|
@@ -402,7 +421,7 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
402
421
|
startY
|
|
403
422
|
];
|
|
404
423
|
}
|
|
405
|
-
drawing.addPin(...positionParams);
|
|
424
|
+
drawing.addPin(...positionParams, lineColor);
|
|
406
425
|
const lastAddedPin = this.drawing.pins[this.drawing.pins.length - 1];
|
|
407
426
|
const [pinId, , angle] = lastAddedPin;
|
|
408
427
|
const [, , , endX, endY] = positionParams;
|
|
@@ -441,11 +460,13 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
441
460
|
fontSize: 10,
|
|
442
461
|
anchor: pinNameAlignment,
|
|
443
462
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
463
|
+
textColor: pinNameColor,
|
|
444
464
|
});
|
|
445
465
|
displayPinId && drawing.addLabel(endX + pinIdOffsetX, endY + pinIdOffsetY, pinId.toString(), {
|
|
446
466
|
fontSize: 8,
|
|
447
467
|
anchor: pinIdAlignment,
|
|
448
468
|
vanchor: pinIdVAlignment,
|
|
469
|
+
textColor: lineColor
|
|
449
470
|
});
|
|
450
471
|
}
|
|
451
472
|
}
|
|
@@ -472,6 +493,7 @@ var PlaceHolderCommands;
|
|
|
472
493
|
PlaceHolderCommands["lineWidth"] = "lineWidth";
|
|
473
494
|
PlaceHolderCommands["fill"] = "fill";
|
|
474
495
|
PlaceHolderCommands["lineColor"] = "lineColor";
|
|
496
|
+
PlaceHolderCommands["textColor"] = "textColor";
|
|
475
497
|
PlaceHolderCommands["text"] = "text";
|
|
476
498
|
})(PlaceHolderCommands || (exports.PlaceHolderCommands = PlaceHolderCommands = {}));
|
|
477
499
|
class SymbolCustom extends SymbolGraphic {
|
|
@@ -502,6 +524,8 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
502
524
|
drawing.flipY = this._flipY;
|
|
503
525
|
const bodyWidth = this.bodyWidth;
|
|
504
526
|
const bodyHeight = (1 + Math.max(maxLeftPins, maxRightPins)) * this.pinSpacing;
|
|
527
|
+
const defaultLineColor = globals_js_1.ColorScheme.PinLineColor;
|
|
528
|
+
drawing.addSetLineColor(defaultLineColor);
|
|
505
529
|
drawing.addRect(0, 0, bodyWidth, bodyHeight);
|
|
506
530
|
const leftPinStart = -bodyWidth / 2;
|
|
507
531
|
const rightPinStart = bodyWidth / 2;
|
|
@@ -509,31 +533,35 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
509
533
|
leftPins.forEach(pin => {
|
|
510
534
|
const position = pin.position;
|
|
511
535
|
const pinY = pinStartY + (position + 1) * this.pinSpacing;
|
|
512
|
-
drawing.addPin(pin.pinId, leftPinStart - this.pinLength, pinY, leftPinStart, pinY);
|
|
536
|
+
drawing.addPin(pin.pinId, leftPinStart - this.pinLength, pinY, leftPinStart, pinY, defaultLineColor);
|
|
513
537
|
drawing.addLabel(leftPinStart + 4, pinY, pin.text, {
|
|
514
538
|
fontSize: 10,
|
|
515
539
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
516
540
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
541
|
+
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
517
542
|
});
|
|
518
543
|
drawing.addLabel(leftPinStart - 2, pinY - 2, pin.pinId.toString(), {
|
|
519
544
|
fontSize: 8,
|
|
520
545
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
521
546
|
vanchor: geometry_js_1.VerticalAlign.Bottom,
|
|
547
|
+
textColor: defaultLineColor
|
|
522
548
|
});
|
|
523
549
|
});
|
|
524
550
|
rightPins.forEach(pin => {
|
|
525
551
|
const position = pin.position;
|
|
526
552
|
const pinY = pinStartY + (position + 1) * this.pinSpacing;
|
|
527
|
-
drawing.addPin(pin.pinId, rightPinStart + this.pinLength, pinY, rightPinStart, pinY);
|
|
553
|
+
drawing.addPin(pin.pinId, rightPinStart + this.pinLength, pinY, rightPinStart, pinY, defaultLineColor);
|
|
528
554
|
drawing.addLabel(rightPinStart - 4, pinY, pin.text, {
|
|
529
555
|
fontSize: 10,
|
|
530
556
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
531
557
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
558
|
+
textColor: globals_js_1.ColorScheme.PinNameColor,
|
|
532
559
|
});
|
|
533
560
|
drawing.addLabel(rightPinStart + 2, pinY - 2, pin.pinId.toString(), {
|
|
534
561
|
fontSize: 8,
|
|
535
562
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
536
563
|
vanchor: geometry_js_1.VerticalAlign.Bottom,
|
|
564
|
+
textColor: defaultLineColor
|
|
537
565
|
});
|
|
538
566
|
});
|
|
539
567
|
const instanceName = this.getLabelValue("refdes");
|
|
@@ -583,7 +611,7 @@ class SymbolDrawing {
|
|
|
583
611
|
this.items.push(geometry_js_1.Geometry.segment([startX, startY], [endX, endY]));
|
|
584
612
|
return this;
|
|
585
613
|
}
|
|
586
|
-
addPin(pinId, startX, startY, endX, endY) {
|
|
614
|
+
addPin(pinId, startX, startY, endX, endY, lineColor) {
|
|
587
615
|
let angle = 0;
|
|
588
616
|
if (startX === endX) {
|
|
589
617
|
if (startY > endY) {
|
|
@@ -604,7 +632,8 @@ class SymbolDrawing {
|
|
|
604
632
|
this.pins.push([
|
|
605
633
|
pinId,
|
|
606
634
|
geometry_js_1.Geometry.segment([startX, startY], [endX, endY]),
|
|
607
|
-
angle
|
|
635
|
+
angle,
|
|
636
|
+
lineColor
|
|
608
637
|
]);
|
|
609
638
|
return this;
|
|
610
639
|
}
|
|
@@ -723,6 +752,10 @@ class SymbolDrawing {
|
|
|
723
752
|
this.items.push(new geometry_js_1.GeometryProp('lineColor', value));
|
|
724
753
|
return this;
|
|
725
754
|
}
|
|
755
|
+
addSetTextColor(value) {
|
|
756
|
+
this.items.push(new geometry_js_1.GeometryProp('textColor', value));
|
|
757
|
+
return this;
|
|
758
|
+
}
|
|
726
759
|
addSetFillColor(value) {
|
|
727
760
|
this.items.push(new geometry_js_1.GeometryProp('fillColor', value));
|
|
728
761
|
return this;
|
|
@@ -767,11 +800,15 @@ class SymbolDrawing {
|
|
|
767
800
|
return pathItems;
|
|
768
801
|
}
|
|
769
802
|
getPinsPath() {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
803
|
+
return this.pins.map(item => {
|
|
804
|
+
let features = geometry_js_1.Geometry.groupFlip([item[1]], this.flipX, this.flipY);
|
|
805
|
+
features = geometry_js_1.Geometry.groupRotate(features, this.angle, this.mainOrigin);
|
|
806
|
+
const { path } = this.featuresToPath(features, this.flipX, this.flipY);
|
|
807
|
+
return {
|
|
808
|
+
path,
|
|
809
|
+
lineColor: item[3],
|
|
810
|
+
};
|
|
811
|
+
});
|
|
775
812
|
}
|
|
776
813
|
getLabels() {
|
|
777
814
|
return this.items.filter(item => item instanceof geometry_js_1.Textbox);
|
|
@@ -784,7 +821,7 @@ class SymbolDrawing {
|
|
|
784
821
|
return pin[1];
|
|
785
822
|
});
|
|
786
823
|
const drawingFeatures = this.items.reduce((accum, item) => {
|
|
787
|
-
if (!excludeLabels || (excludeLabels && !(item instanceof geometry_js_1.
|
|
824
|
+
if (!excludeLabels || (excludeLabels && !(item instanceof geometry_js_1.Textbox && item.label))) {
|
|
788
825
|
if (!(item instanceof geometry_js_1.GeometryProp)) {
|
|
789
826
|
accum.push(item);
|
|
790
827
|
}
|
package/dist/cjs/globals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlockTypes = exports.ReferenceTypes = exports.ComponentTypes = exports.
|
|
3
|
+
exports.BlockTypes = exports.ReferenceTypes = exports.ComponentTypes = exports.ColorScheme = exports.junctionSize = exports.defaultFontSize = exports.defaultFontBold = exports.defaultFont = exports.portHeight = exports.portWidth = exports.SymbolPinSide = exports.LayoutDirection = exports.ParamKeys = exports.NoNetText = exports.GlobalNames = void 0;
|
|
4
4
|
var GlobalNames;
|
|
5
5
|
(function (GlobalNames) {
|
|
6
6
|
GlobalNames["__root"] = "__root";
|
|
@@ -31,10 +31,14 @@ exports.portHeight = 2;
|
|
|
31
31
|
exports.defaultFont = 'Open Sans-Regular, Arial';
|
|
32
32
|
exports.defaultFontBold = 'Open Sans-Bold, Arial-Bold, Arial';
|
|
33
33
|
exports.defaultFontSize = 10;
|
|
34
|
-
exports.bodyColor = '#FFFEAF';
|
|
35
34
|
exports.junctionSize = 5;
|
|
36
|
-
exports.
|
|
37
|
-
|
|
35
|
+
exports.ColorScheme = {
|
|
36
|
+
BodyColor: 'rgb(255, 255, 194)',
|
|
37
|
+
JunctionColor: 'rgba(0, 132, 0)',
|
|
38
|
+
WireColor: 'rgb(0, 132, 0)',
|
|
39
|
+
PinLineColor: 'rgb(132, 0, 0)',
|
|
40
|
+
PinNameColor: 'rgb(0, 132, 132)',
|
|
41
|
+
};
|
|
38
42
|
var ComponentTypes;
|
|
39
43
|
(function (ComponentTypes) {
|
|
40
44
|
ComponentTypes["gnd"] = "gnd";
|
|
@@ -5,19 +5,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const helpers_js_1 = require("./helpers.js");
|
|
8
|
+
const sizing_js_1 = require("./sizing.js");
|
|
8
9
|
const mainDir = './__tests__/renderData/';
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
cstFiles.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
const fontsPath = (0, helpers_js_1.getFontsPath)();
|
|
11
|
+
const defaultLibsPath = (0, helpers_js_1.getDefaultLibsPath)();
|
|
12
|
+
async function regenerateTests() {
|
|
13
|
+
await (0, sizing_js_1.prepareSVGEnvironment)(fontsPath);
|
|
14
|
+
const cstFiles = [];
|
|
15
|
+
const files = fs_1.default.readdirSync(mainDir);
|
|
16
|
+
files.forEach(file => {
|
|
17
|
+
if (file.endsWith('.cst')) {
|
|
18
|
+
cstFiles.push(file);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
cstFiles.forEach(file => {
|
|
22
|
+
const inputPath = mainDir + file;
|
|
23
|
+
const scriptData = fs_1.default.readFileSync(inputPath, { encoding: 'utf-8' });
|
|
24
|
+
const outputPath = inputPath + '.svg';
|
|
25
|
+
(0, helpers_js_1.renderScript)(scriptData, outputPath, {
|
|
26
|
+
currentDirectory: mainDir,
|
|
27
|
+
defaultLibsPath,
|
|
28
|
+
});
|
|
29
|
+
console.log('generated ', outputPath);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
regenerateTests();
|
package/dist/cjs/render.js
CHANGED
|
@@ -61,7 +61,7 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
symbolGroup.rect(width, height)
|
|
64
|
-
.fill(globals_js_1.
|
|
64
|
+
.fill(globals_js_1.ColorScheme.BodyColor)
|
|
65
65
|
.stroke({ width: 1, color: '#333' });
|
|
66
66
|
}
|
|
67
67
|
});
|
|
@@ -83,14 +83,15 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
83
83
|
const pt1 = segment[0];
|
|
84
84
|
const pt2 = segment[1];
|
|
85
85
|
mergedWireGroup.line([pt1, pt2])
|
|
86
|
-
.stroke({ width: 1, color: globals_js_1.
|
|
86
|
+
.stroke({ width: 1, color: globals_js_1.ColorScheme.WireColor,
|
|
87
|
+
linecap: 'square' })
|
|
87
88
|
.fill('none');
|
|
88
89
|
});
|
|
89
90
|
intersectPoints.forEach(point => {
|
|
90
91
|
const [x, y, count] = point;
|
|
91
92
|
mergedWireGroup.circle(globals_js_1.junctionSize)
|
|
92
93
|
.translate(x - globals_js_1.junctionSize / 2, y - globals_js_1.junctionSize / 2)
|
|
93
|
-
.fill(globals_js_1.
|
|
94
|
+
.fill(globals_js_1.ColorScheme.JunctionColor)
|
|
94
95
|
.stroke('none');
|
|
95
96
|
});
|
|
96
97
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReferenceTypes, SymbolPinSide, defaultFont } from "./globals.mjs";
|
|
2
|
-
import { Geometry, GeometryProp, HorizontalAlign,
|
|
1
|
+
import { ColorScheme, ReferenceTypes, SymbolPinSide, defaultFont } from "./globals.mjs";
|
|
2
|
+
import { Geometry, GeometryProp, HorizontalAlign, Textbox, VerticalAlign } from "./geometry.mjs";
|
|
3
3
|
import { PinTypes } from "./objects/PinTypes.mjs";
|
|
4
4
|
const defaultSymbolLineWidth = 2;
|
|
5
5
|
export class SymbolGraphic {
|
|
@@ -104,17 +104,20 @@ export class SymbolGraphic {
|
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
drawPins(group) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
const pinPaths = this.drawing.getPinsPath();
|
|
108
|
+
pinPaths.forEach(({ path, lineColor }) => {
|
|
109
|
+
group.path(path)
|
|
110
|
+
.stroke({
|
|
111
|
+
width: defaultSymbolLineWidth,
|
|
112
|
+
color: lineColor
|
|
113
|
+
});
|
|
111
114
|
});
|
|
112
115
|
}
|
|
113
116
|
drawLabels(group) {
|
|
114
117
|
const labels = this.drawing.getLabels();
|
|
115
118
|
labels.forEach(label => {
|
|
116
119
|
const tmpLabel = label;
|
|
117
|
-
const { fontSize = 10, anchor = HorizontalAlign.Left, vanchor = VerticalAlign.Bottom, fontWeight = 'regular', angle: labelAngle = 0, } = tmpLabel.style ?? {};
|
|
120
|
+
const { fontSize = 10, anchor = HorizontalAlign.Left, vanchor = VerticalAlign.Bottom, fontWeight = 'regular', angle: labelAngle = 0, textColor = "#333", } = tmpLabel.style ?? {};
|
|
118
121
|
let anchorStyle = 'start';
|
|
119
122
|
let dominantBaseline = 'auto';
|
|
120
123
|
let useAnchor = anchor;
|
|
@@ -156,7 +159,7 @@ export class SymbolGraphic {
|
|
|
156
159
|
const useFont = defaultFont;
|
|
157
160
|
const textContainer = group.group();
|
|
158
161
|
const text = textContainer.text(tmpLabel.text)
|
|
159
|
-
.fill(
|
|
162
|
+
.fill(textColor)
|
|
160
163
|
.font({
|
|
161
164
|
family: useFont,
|
|
162
165
|
size: fontSize,
|
|
@@ -268,8 +271,14 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
268
271
|
drawing.angle = this._angle;
|
|
269
272
|
drawing.flipX = this._flipX;
|
|
270
273
|
drawing.flipY = this._flipY;
|
|
271
|
-
const commands =
|
|
274
|
+
const commands = [
|
|
275
|
+
[PlaceHolderCommands.lineColor, [ColorScheme.PinLineColor], {}],
|
|
276
|
+
[PlaceHolderCommands.textColor, [ColorScheme.PinNameColor], {}],
|
|
277
|
+
...drawing.getCommands()
|
|
278
|
+
];
|
|
272
279
|
drawing.log('id: ', drawing.id, 'angle: ', this._angle, "commands:", commands.length);
|
|
280
|
+
let lineColor = "#333";
|
|
281
|
+
let textColor = "#333";
|
|
273
282
|
commands.forEach(([commandName, positionParams, keywordParams]) => {
|
|
274
283
|
switch (commandName) {
|
|
275
284
|
case PlaceHolderCommands.rect:
|
|
@@ -299,6 +308,11 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
299
308
|
break;
|
|
300
309
|
case PlaceHolderCommands.lineColor:
|
|
301
310
|
drawing.addSetLineColor(...positionParams);
|
|
311
|
+
lineColor = positionParams[0];
|
|
312
|
+
break;
|
|
313
|
+
case PlaceHolderCommands.textColor:
|
|
314
|
+
drawing.addSetTextColor(...positionParams);
|
|
315
|
+
textColor = positionParams[0];
|
|
302
316
|
break;
|
|
303
317
|
case PlaceHolderCommands.arc:
|
|
304
318
|
drawing.addArc(...positionParams);
|
|
@@ -313,11 +327,14 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
313
327
|
case PlaceHolderCommands.hpin:
|
|
314
328
|
case PlaceHolderCommands.vpin:
|
|
315
329
|
{
|
|
316
|
-
this.drawPinParams(drawing, commandName, keywordParams, positionParams);
|
|
330
|
+
this.drawPinParams(drawing, commandName, keywordParams, positionParams, lineColor, textColor);
|
|
317
331
|
break;
|
|
318
332
|
}
|
|
319
333
|
case PlaceHolderCommands.label: {
|
|
320
334
|
const style = this.parseLabelStyle(keywordParams);
|
|
335
|
+
if (style['textColor'] === undefined) {
|
|
336
|
+
style['textColor'] = textColor;
|
|
337
|
+
}
|
|
321
338
|
positionParams = [...positionParams];
|
|
322
339
|
positionParams.push(style);
|
|
323
340
|
const labelId = positionParams[0];
|
|
@@ -348,7 +365,7 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
348
365
|
drawing.log("=== end generate drawing ===");
|
|
349
366
|
}
|
|
350
367
|
parseLabelStyle(keywordParams) {
|
|
351
|
-
const keywords = ['fontSize', 'anchor', 'vanchor', 'angle'];
|
|
368
|
+
const keywords = ['fontSize', 'anchor', 'vanchor', 'angle', 'textColor'];
|
|
352
369
|
const style = {};
|
|
353
370
|
keywords.forEach(item => {
|
|
354
371
|
if (keywordParams.has(item)) {
|
|
@@ -357,13 +374,15 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
357
374
|
});
|
|
358
375
|
return style;
|
|
359
376
|
}
|
|
360
|
-
drawPinParams(drawing, commandName, keywordParams, positionParams) {
|
|
377
|
+
drawPinParams(drawing, commandName, keywordParams, positionParams, lineColor, pinNameColor) {
|
|
361
378
|
drawing.log('add pin', ...positionParams);
|
|
362
379
|
const keywordDisplayPinId = 'display_pin_id';
|
|
363
380
|
let displayPinId = true;
|
|
364
|
-
if (keywordParams.has(keywordDisplayPinId)
|
|
365
|
-
|
|
366
|
-
|
|
381
|
+
if (keywordParams.has(keywordDisplayPinId)) {
|
|
382
|
+
const value = keywordParams.get(keywordDisplayPinId);
|
|
383
|
+
if (value === 0 || value === false) {
|
|
384
|
+
displayPinId = false;
|
|
385
|
+
}
|
|
367
386
|
}
|
|
368
387
|
let pinNameParam = null;
|
|
369
388
|
let pinType = PinTypes.Any;
|
|
@@ -397,7 +416,7 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
397
416
|
startY
|
|
398
417
|
];
|
|
399
418
|
}
|
|
400
|
-
drawing.addPin(...positionParams);
|
|
419
|
+
drawing.addPin(...positionParams, lineColor);
|
|
401
420
|
const lastAddedPin = this.drawing.pins[this.drawing.pins.length - 1];
|
|
402
421
|
const [pinId, , angle] = lastAddedPin;
|
|
403
422
|
const [, , , endX, endY] = positionParams;
|
|
@@ -436,11 +455,13 @@ export class SymbolPlaceholder extends SymbolGraphic {
|
|
|
436
455
|
fontSize: 10,
|
|
437
456
|
anchor: pinNameAlignment,
|
|
438
457
|
vanchor: VerticalAlign.Middle,
|
|
458
|
+
textColor: pinNameColor,
|
|
439
459
|
});
|
|
440
460
|
displayPinId && drawing.addLabel(endX + pinIdOffsetX, endY + pinIdOffsetY, pinId.toString(), {
|
|
441
461
|
fontSize: 8,
|
|
442
462
|
anchor: pinIdAlignment,
|
|
443
463
|
vanchor: pinIdVAlignment,
|
|
464
|
+
textColor: lineColor
|
|
444
465
|
});
|
|
445
466
|
}
|
|
446
467
|
}
|
|
@@ -466,6 +487,7 @@ export var PlaceHolderCommands;
|
|
|
466
487
|
PlaceHolderCommands["lineWidth"] = "lineWidth";
|
|
467
488
|
PlaceHolderCommands["fill"] = "fill";
|
|
468
489
|
PlaceHolderCommands["lineColor"] = "lineColor";
|
|
490
|
+
PlaceHolderCommands["textColor"] = "textColor";
|
|
469
491
|
PlaceHolderCommands["text"] = "text";
|
|
470
492
|
})(PlaceHolderCommands || (PlaceHolderCommands = {}));
|
|
471
493
|
export class SymbolCustom extends SymbolGraphic {
|
|
@@ -498,6 +520,8 @@ export class SymbolCustom extends SymbolGraphic {
|
|
|
498
520
|
drawing.flipY = this._flipY;
|
|
499
521
|
const bodyWidth = this.bodyWidth;
|
|
500
522
|
const bodyHeight = (1 + Math.max(maxLeftPins, maxRightPins)) * this.pinSpacing;
|
|
523
|
+
const defaultLineColor = ColorScheme.PinLineColor;
|
|
524
|
+
drawing.addSetLineColor(defaultLineColor);
|
|
501
525
|
drawing.addRect(0, 0, bodyWidth, bodyHeight);
|
|
502
526
|
const leftPinStart = -bodyWidth / 2;
|
|
503
527
|
const rightPinStart = bodyWidth / 2;
|
|
@@ -505,31 +529,35 @@ export class SymbolCustom extends SymbolGraphic {
|
|
|
505
529
|
leftPins.forEach(pin => {
|
|
506
530
|
const position = pin.position;
|
|
507
531
|
const pinY = pinStartY + (position + 1) * this.pinSpacing;
|
|
508
|
-
drawing.addPin(pin.pinId, leftPinStart - this.pinLength, pinY, leftPinStart, pinY);
|
|
532
|
+
drawing.addPin(pin.pinId, leftPinStart - this.pinLength, pinY, leftPinStart, pinY, defaultLineColor);
|
|
509
533
|
drawing.addLabel(leftPinStart + 4, pinY, pin.text, {
|
|
510
534
|
fontSize: 10,
|
|
511
535
|
anchor: HorizontalAlign.Left,
|
|
512
536
|
vanchor: VerticalAlign.Middle,
|
|
537
|
+
textColor: ColorScheme.PinNameColor,
|
|
513
538
|
});
|
|
514
539
|
drawing.addLabel(leftPinStart - 2, pinY - 2, pin.pinId.toString(), {
|
|
515
540
|
fontSize: 8,
|
|
516
541
|
anchor: HorizontalAlign.Right,
|
|
517
542
|
vanchor: VerticalAlign.Bottom,
|
|
543
|
+
textColor: defaultLineColor
|
|
518
544
|
});
|
|
519
545
|
});
|
|
520
546
|
rightPins.forEach(pin => {
|
|
521
547
|
const position = pin.position;
|
|
522
548
|
const pinY = pinStartY + (position + 1) * this.pinSpacing;
|
|
523
|
-
drawing.addPin(pin.pinId, rightPinStart + this.pinLength, pinY, rightPinStart, pinY);
|
|
549
|
+
drawing.addPin(pin.pinId, rightPinStart + this.pinLength, pinY, rightPinStart, pinY, defaultLineColor);
|
|
524
550
|
drawing.addLabel(rightPinStart - 4, pinY, pin.text, {
|
|
525
551
|
fontSize: 10,
|
|
526
552
|
anchor: HorizontalAlign.Right,
|
|
527
553
|
vanchor: VerticalAlign.Middle,
|
|
554
|
+
textColor: ColorScheme.PinNameColor,
|
|
528
555
|
});
|
|
529
556
|
drawing.addLabel(rightPinStart + 2, pinY - 2, pin.pinId.toString(), {
|
|
530
557
|
fontSize: 8,
|
|
531
558
|
anchor: HorizontalAlign.Left,
|
|
532
559
|
vanchor: VerticalAlign.Bottom,
|
|
560
|
+
textColor: defaultLineColor
|
|
533
561
|
});
|
|
534
562
|
});
|
|
535
563
|
const instanceName = this.getLabelValue("refdes");
|
|
@@ -576,7 +604,7 @@ export class SymbolDrawing {
|
|
|
576
604
|
this.items.push(Geometry.segment([startX, startY], [endX, endY]));
|
|
577
605
|
return this;
|
|
578
606
|
}
|
|
579
|
-
addPin(pinId, startX, startY, endX, endY) {
|
|
607
|
+
addPin(pinId, startX, startY, endX, endY, lineColor) {
|
|
580
608
|
let angle = 0;
|
|
581
609
|
if (startX === endX) {
|
|
582
610
|
if (startY > endY) {
|
|
@@ -597,7 +625,8 @@ export class SymbolDrawing {
|
|
|
597
625
|
this.pins.push([
|
|
598
626
|
pinId,
|
|
599
627
|
Geometry.segment([startX, startY], [endX, endY]),
|
|
600
|
-
angle
|
|
628
|
+
angle,
|
|
629
|
+
lineColor
|
|
601
630
|
]);
|
|
602
631
|
return this;
|
|
603
632
|
}
|
|
@@ -716,6 +745,10 @@ export class SymbolDrawing {
|
|
|
716
745
|
this.items.push(new GeometryProp('lineColor', value));
|
|
717
746
|
return this;
|
|
718
747
|
}
|
|
748
|
+
addSetTextColor(value) {
|
|
749
|
+
this.items.push(new GeometryProp('textColor', value));
|
|
750
|
+
return this;
|
|
751
|
+
}
|
|
719
752
|
addSetFillColor(value) {
|
|
720
753
|
this.items.push(new GeometryProp('fillColor', value));
|
|
721
754
|
return this;
|
|
@@ -760,11 +793,15 @@ export class SymbolDrawing {
|
|
|
760
793
|
return pathItems;
|
|
761
794
|
}
|
|
762
795
|
getPinsPath() {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
796
|
+
return this.pins.map(item => {
|
|
797
|
+
let features = Geometry.groupFlip([item[1]], this.flipX, this.flipY);
|
|
798
|
+
features = Geometry.groupRotate(features, this.angle, this.mainOrigin);
|
|
799
|
+
const { path } = this.featuresToPath(features, this.flipX, this.flipY);
|
|
800
|
+
return {
|
|
801
|
+
path,
|
|
802
|
+
lineColor: item[3],
|
|
803
|
+
};
|
|
804
|
+
});
|
|
768
805
|
}
|
|
769
806
|
getLabels() {
|
|
770
807
|
return this.items.filter(item => item instanceof Textbox);
|
|
@@ -777,7 +814,7 @@ export class SymbolDrawing {
|
|
|
777
814
|
return pin[1];
|
|
778
815
|
});
|
|
779
816
|
const drawingFeatures = this.items.reduce((accum, item) => {
|
|
780
|
-
if (!excludeLabels || (excludeLabels && !(item instanceof
|
|
817
|
+
if (!excludeLabels || (excludeLabels && !(item instanceof Textbox && item.label))) {
|
|
781
818
|
if (!(item instanceof GeometryProp)) {
|
|
782
819
|
accum.push(item);
|
|
783
820
|
}
|
package/dist/esm/globals.mjs
CHANGED
|
@@ -28,10 +28,14 @@ export const portHeight = 2;
|
|
|
28
28
|
export const defaultFont = 'Open Sans-Regular, Arial';
|
|
29
29
|
export const defaultFontBold = 'Open Sans-Bold, Arial-Bold, Arial';
|
|
30
30
|
export const defaultFontSize = 10;
|
|
31
|
-
export const bodyColor = '#FFFEAF';
|
|
32
31
|
export const junctionSize = 5;
|
|
33
|
-
export const
|
|
34
|
-
|
|
32
|
+
export const ColorScheme = {
|
|
33
|
+
BodyColor: 'rgb(255, 255, 194)',
|
|
34
|
+
JunctionColor: 'rgba(0, 132, 0)',
|
|
35
|
+
WireColor: 'rgb(0, 132, 0)',
|
|
36
|
+
PinLineColor: 'rgb(132, 0, 0)',
|
|
37
|
+
PinNameColor: 'rgb(0, 132, 132)',
|
|
38
|
+
};
|
|
35
39
|
export var ComponentTypes;
|
|
36
40
|
(function (ComponentTypes) {
|
|
37
41
|
ComponentTypes["gnd"] = "gnd";
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { renderScript } from './helpers.mjs';
|
|
2
|
+
import { getDefaultLibsPath, getFontsPath, renderScript } from './helpers.mjs';
|
|
3
|
+
import { prepareSVGEnvironment } from './sizing.mjs';
|
|
3
4
|
const mainDir = './__tests__/renderData/';
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
cstFiles.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const fontsPath = getFontsPath();
|
|
6
|
+
const defaultLibsPath = getDefaultLibsPath();
|
|
7
|
+
async function regenerateTests() {
|
|
8
|
+
await prepareSVGEnvironment(fontsPath);
|
|
9
|
+
const cstFiles = [];
|
|
10
|
+
const files = fs.readdirSync(mainDir);
|
|
11
|
+
files.forEach(file => {
|
|
12
|
+
if (file.endsWith('.cst')) {
|
|
13
|
+
cstFiles.push(file);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
cstFiles.forEach(file => {
|
|
17
|
+
const inputPath = mainDir + file;
|
|
18
|
+
const scriptData = fs.readFileSync(inputPath, { encoding: 'utf-8' });
|
|
19
|
+
const outputPath = inputPath + '.svg';
|
|
20
|
+
renderScript(scriptData, outputPath, {
|
|
21
|
+
currentDirectory: mainDir,
|
|
22
|
+
defaultLibsPath,
|
|
23
|
+
});
|
|
24
|
+
console.log('generated ', outputPath);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
regenerateTests();
|
package/dist/esm/render.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SVG, registerWindow } from '@svgdotjs/svg.js';
|
|
2
2
|
import { RenderFrameType, getBounds } from "./layout.mjs";
|
|
3
3
|
import { applyFontsToSVG, getCreateSVGWindow } from './sizing.mjs';
|
|
4
|
-
import { ComponentTypes, ParamKeys,
|
|
4
|
+
import { ColorScheme, ComponentTypes, ParamKeys, junctionSize } from './globals.mjs';
|
|
5
5
|
import { NumericValue } from './objects/ParamDefinition.mjs';
|
|
6
6
|
import { getBoundsSize } from './utils.mjs';
|
|
7
7
|
export function generateSVG2(graph) {
|
|
@@ -57,7 +57,7 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
symbolGroup.rect(width, height)
|
|
60
|
-
.fill(
|
|
60
|
+
.fill(ColorScheme.BodyColor)
|
|
61
61
|
.stroke({ width: 1, color: '#333' });
|
|
62
62
|
}
|
|
63
63
|
});
|
|
@@ -79,14 +79,15 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
79
79
|
const pt1 = segment[0];
|
|
80
80
|
const pt2 = segment[1];
|
|
81
81
|
mergedWireGroup.line([pt1, pt2])
|
|
82
|
-
.stroke({ width: 1, color:
|
|
82
|
+
.stroke({ width: 1, color: ColorScheme.WireColor,
|
|
83
|
+
linecap: 'square' })
|
|
83
84
|
.fill('none');
|
|
84
85
|
});
|
|
85
86
|
intersectPoints.forEach(point => {
|
|
86
87
|
const [x, y, count] = point;
|
|
87
88
|
mergedWireGroup.circle(junctionSize)
|
|
88
89
|
.translate(x - junctionSize / 2, y - junctionSize / 2)
|
|
89
|
-
.fill(
|
|
90
|
+
.fill(ColorScheme.JunctionColor)
|
|
90
91
|
.stroke('none');
|
|
91
92
|
});
|
|
92
93
|
});
|
|
@@ -59,7 +59,7 @@ export declare class SymbolPlaceholder extends SymbolGraphic {
|
|
|
59
59
|
parseLabelStyle(keywordParams: Map<string, any>): {
|
|
60
60
|
[key: string]: any;
|
|
61
61
|
};
|
|
62
|
-
drawPinParams(drawing: SymbolDrawingCommands, commandName: string, keywordParams: Map<string, any>, positionParams: any[]): void;
|
|
62
|
+
drawPinParams(drawing: SymbolDrawingCommands, commandName: string, keywordParams: Map<string, any>, positionParams: any[], lineColor: string, pinNameColor: string): void;
|
|
63
63
|
constructor(drawing: SymbolDrawing);
|
|
64
64
|
}
|
|
65
65
|
export declare enum PlaceHolderCommands {
|
|
@@ -78,6 +78,7 @@ export declare enum PlaceHolderCommands {
|
|
|
78
78
|
lineWidth = "lineWidth",
|
|
79
79
|
fill = "fill",
|
|
80
80
|
lineColor = "lineColor",
|
|
81
|
+
textColor = "textColor",
|
|
81
82
|
text = "text"
|
|
82
83
|
}
|
|
83
84
|
export declare class SymbolCustom extends SymbolGraphic {
|
|
@@ -97,7 +98,7 @@ export declare class SymbolCustom extends SymbolGraphic {
|
|
|
97
98
|
}
|
|
98
99
|
export declare class SymbolDrawing {
|
|
99
100
|
items: (Feature | GeometryProp)[];
|
|
100
|
-
pins: [number, Feature, number][];
|
|
101
|
+
pins: [number, Feature, number, lineColor: string][];
|
|
101
102
|
angle: number;
|
|
102
103
|
flipX: number;
|
|
103
104
|
flipY: number;
|
|
@@ -106,7 +107,7 @@ export declare class SymbolDrawing {
|
|
|
106
107
|
clear(): void;
|
|
107
108
|
log(...params: any[]): void;
|
|
108
109
|
addLine(startX: number, startY: number, endX: number, endY: number): SymbolDrawing;
|
|
109
|
-
addPin(pinId: number, startX: number, startY: number, endX: number, endY: number): SymbolDrawing;
|
|
110
|
+
addPin(pinId: number, startX: number, startY: number, endX: number, endY: number, lineColor: string): SymbolDrawing;
|
|
110
111
|
addVLine(startX: number, startY: number, value: number): SymbolDrawing;
|
|
111
112
|
addHLine(startX: number, startY: number, value: number): SymbolDrawing;
|
|
112
113
|
addRect(centerX: number, centerY: number, width: number, height: number): SymbolDrawing;
|
|
@@ -118,6 +119,7 @@ export declare class SymbolDrawing {
|
|
|
118
119
|
addPath(...pathParts: any): SymbolDrawing;
|
|
119
120
|
addSetLineWidth(value: number): SymbolDrawing;
|
|
120
121
|
addSetLineColor(value: string): SymbolDrawing;
|
|
122
|
+
addSetTextColor(value: string): SymbolDrawing;
|
|
121
123
|
addSetFillColor(value: string): SymbolDrawing;
|
|
122
124
|
addArc(x: number, y: number, radius: number, startAngle: number, endAngle: number): SymbolDrawing;
|
|
123
125
|
getPaths(): {
|
|
@@ -126,7 +128,10 @@ export declare class SymbolDrawing {
|
|
|
126
128
|
lineColor: string;
|
|
127
129
|
lineWidth: number;
|
|
128
130
|
}[];
|
|
129
|
-
getPinsPath():
|
|
131
|
+
getPinsPath(): {
|
|
132
|
+
path: string;
|
|
133
|
+
lineColor: string;
|
|
134
|
+
}[];
|
|
130
135
|
getLabels(): Textbox[];
|
|
131
136
|
private featuresToPath;
|
|
132
137
|
getBoundingBox(excludeLabels?: boolean): {
|
package/dist/types/geometry.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type LabelStyle = {
|
|
|
13
13
|
angle?: number;
|
|
14
14
|
anchor?: HorizontalAlign.Left | HorizontalAlign.Middle | HorizontalAlign.Right;
|
|
15
15
|
vanchor?: VerticalAlign.Top | VerticalAlign.Middle | VerticalAlign.Bottom;
|
|
16
|
+
textColor?: string;
|
|
16
17
|
};
|
|
17
18
|
export declare class Textbox extends Flatten.Polygon {
|
|
18
19
|
id: string;
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -24,10 +24,14 @@ export declare const portHeight = 2;
|
|
|
24
24
|
export declare const defaultFont = "Open Sans-Regular, Arial";
|
|
25
25
|
export declare const defaultFontBold = "Open Sans-Bold, Arial-Bold, Arial";
|
|
26
26
|
export declare const defaultFontSize = 10;
|
|
27
|
-
export declare const bodyColor = "#FFFEAF";
|
|
28
27
|
export declare const junctionSize = 5;
|
|
29
|
-
export declare const
|
|
30
|
-
|
|
28
|
+
export declare const ColorScheme: {
|
|
29
|
+
BodyColor: string;
|
|
30
|
+
JunctionColor: string;
|
|
31
|
+
WireColor: string;
|
|
32
|
+
PinLineColor: string;
|
|
33
|
+
PinNameColor: string;
|
|
34
|
+
};
|
|
31
35
|
export declare enum ComponentTypes {
|
|
32
36
|
gnd = "gnd",
|
|
33
37
|
net = "net",
|
package/libs/lib.cst
CHANGED
|
@@ -7,7 +7,7 @@ def net(net_name):
|
|
|
7
7
|
angle: -90
|
|
8
8
|
display: create graphic:
|
|
9
9
|
hline: -15, 0, 30
|
|
10
|
-
vpin: 1, 0, 10, -10, display_pin_id=
|
|
10
|
+
vpin: 1, 0, 10, -10, display_pin_id=false
|
|
11
11
|
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
12
12
|
type: "net"
|
|
13
13
|
params:
|
|
@@ -21,7 +21,7 @@ def supply(net_name):
|
|
|
21
21
|
angle: -90
|
|
22
22
|
display: create graphic:
|
|
23
23
|
hline: -15, 0, 30
|
|
24
|
-
vpin: 1, 0, 10, -10, display_pin_id=
|
|
24
|
+
vpin: 1, 0, 10, -10, display_pin_id=false
|
|
25
25
|
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
26
26
|
type: "net"
|
|
27
27
|
params:
|
|
@@ -34,8 +34,9 @@ def label(value, anchor="left"):
|
|
|
34
34
|
copy: true
|
|
35
35
|
followWireOrientation: false
|
|
36
36
|
display: create graphic:
|
|
37
|
+
textColor: "#222"
|
|
37
38
|
label: "value", 0, -2, "?", fontSize=10, anchor=anchor
|
|
38
|
-
pin: 1, 0, 0, 0, 0, display_pin_id=
|
|
39
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
39
40
|
type: "label"
|
|
40
41
|
params:
|
|
41
42
|
net_name: value
|
|
@@ -148,7 +149,7 @@ def cgnd():
|
|
|
148
149
|
hline: -15, 0, 30
|
|
149
150
|
hline: -10, 5, 20
|
|
150
151
|
hline: -5, 10, 10
|
|
151
|
-
vpin: 1, 0, -10, 10, display_pin_id=
|
|
152
|
+
vpin: 1, 0, -10, 10, display_pin_id=false
|
|
152
153
|
label: "net_name", 0, 22, net_name, fontSize=10, anchor="middle"
|
|
153
154
|
type: "net"
|
|
154
155
|
params:
|
|
@@ -165,37 +166,40 @@ def dgnd(net_name="GND"):
|
|
|
165
166
|
angle: 90
|
|
166
167
|
display: create graphic:
|
|
167
168
|
triangle: 0, 0, 0, height, width
|
|
168
|
-
vpin: 1, 0, -10, 10, display_pin_id=
|
|
169
|
+
vpin: 1, 0, -10, 10, display_pin_id=false
|
|
169
170
|
label: "net_name", 0, height + 10, net_name, fontSize=10, anchor="middle"
|
|
170
171
|
type: "net"
|
|
171
172
|
params:
|
|
172
173
|
net_name: net_name
|
|
173
174
|
priority: 100
|
|
174
175
|
|
|
175
|
-
def
|
|
176
|
+
def text(value, offsetX = 0, offsetY = 0, fontSize = 12):
|
|
176
177
|
return create component:
|
|
177
178
|
pins: 1
|
|
179
|
+
followWireOrientation: false
|
|
178
180
|
display: create graphic:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
182
|
+
text:
|
|
183
|
+
content: value
|
|
184
|
+
offset: offsetX, offsetY
|
|
185
|
+
fontSize: fontSize
|
|
183
186
|
|
|
184
|
-
|
|
187
|
+
# Drawing markers
|
|
188
|
+
|
|
189
|
+
def marker_point():
|
|
185
190
|
return create component:
|
|
186
191
|
pins: 1
|
|
187
192
|
display: create graphic:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
hline: -5, 0, 10
|
|
194
|
+
vline: 0, -5, 10
|
|
195
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
191
196
|
|
|
192
|
-
def
|
|
197
|
+
def arrow_point():
|
|
193
198
|
return create component:
|
|
194
199
|
pins: 1
|
|
195
200
|
followWireOrientation: false
|
|
196
201
|
display: create graphic:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
fontSize: fontSize
|
|
202
|
+
lineWidth: 2
|
|
203
|
+
path: ("M", -10, -5, "L", -5, 0, "L", -10, 5)
|
|
204
|
+
path: ("M", -5, 0, "L", -20, 0)
|
|
205
|
+
hpin: 1, 0, 0, 0, display_pin_id=false
|