schematic-symbols 0.0.100 → 0.0.101
Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js
CHANGED
@@ -2219,8 +2219,70 @@ var diode_default = {
|
|
2219
2219
|
circles: {}
|
2220
2220
|
};
|
2221
2221
|
|
2222
|
+
// drawing/modify-symbol/modify-symbol.ts
|
2223
|
+
var SymbolModifier = class {
|
2224
|
+
symbol;
|
2225
|
+
constructor(symbol) {
|
2226
|
+
this.symbol = JSON.parse(JSON.stringify(symbol));
|
2227
|
+
}
|
2228
|
+
changeTextAnchor(text, newAnchor) {
|
2229
|
+
this.symbol = {
|
2230
|
+
...this.symbol,
|
2231
|
+
primitives: this.symbol.primitives.map((primitive) => {
|
2232
|
+
if (primitive.type === "text" && primitive.text === text) {
|
2233
|
+
return {
|
2234
|
+
...primitive,
|
2235
|
+
anchor: newAnchor
|
2236
|
+
};
|
2237
|
+
}
|
2238
|
+
return primitive;
|
2239
|
+
})
|
2240
|
+
};
|
2241
|
+
return this;
|
2242
|
+
}
|
2243
|
+
labelPort(currentLabel, newLabels) {
|
2244
|
+
this.symbol = {
|
2245
|
+
...this.symbol,
|
2246
|
+
ports: this.symbol.ports.map((port) => {
|
2247
|
+
return port.labels.includes(currentLabel) ? { ...port, labels: newLabels } : port;
|
2248
|
+
})
|
2249
|
+
};
|
2250
|
+
return this;
|
2251
|
+
}
|
2252
|
+
rotateRightFacingSymbol(newOrientation) {
|
2253
|
+
this.symbol = rotateRightFacingSymbol(this.symbol, {
|
2254
|
+
newOrientation
|
2255
|
+
});
|
2256
|
+
return this;
|
2257
|
+
}
|
2258
|
+
build() {
|
2259
|
+
return this.symbol;
|
2260
|
+
}
|
2261
|
+
};
|
2262
|
+
var modifySymbol = (symbol) => {
|
2263
|
+
return new SymbolModifier({
|
2264
|
+
...symbol,
|
2265
|
+
primitives: symbol.primitives ?? [
|
2266
|
+
...Object.values(symbol.paths ?? {}),
|
2267
|
+
...Object.values(symbol.texts ?? {}),
|
2268
|
+
...Object.values(symbol.circles ?? {}),
|
2269
|
+
...Object.values(symbol.rects ?? {})
|
2270
|
+
],
|
2271
|
+
ports: symbol.ports ?? Object.entries(symbol.refblocks).flatMap(([key, refblock]) => {
|
2272
|
+
return [{ ...refblock, labels: [key] }];
|
2273
|
+
}),
|
2274
|
+
center: symbol.center ?? {
|
2275
|
+
x: symbol.bounds.centerX,
|
2276
|
+
y: symbol.bounds.centerY
|
2277
|
+
},
|
2278
|
+
size: symbol.size ?? {
|
2279
|
+
width: symbol.bounds.width,
|
2280
|
+
height: symbol.bounds.height
|
2281
|
+
}
|
2282
|
+
});
|
2283
|
+
};
|
2284
|
+
|
2222
2285
|
// symbols/diode_right.ts
|
2223
|
-
import { modifySymbol } from "scripts/lib/modify-symbol/modify-symbol";
|
2224
2286
|
var diode_right_default = modifySymbol(diode_default).labelPort("left1", ["1", "pos"]).labelPort("right1", ["2", "neg"]).changeTextAnchor("{REF}", "middle_bottom").changeTextAnchor("{VAL}", "middle_top").build();
|
2225
2287
|
|
2226
2288
|
// symbols/diode_down.ts
|
@@ -2955,8 +3017,7 @@ var horizontalSymbol = defineSymbol({
|
|
2955
3017
|
var ground_horz_default = horizontalSymbol;
|
2956
3018
|
|
2957
3019
|
// symbols/ground_vert.ts
|
2958
|
-
|
2959
|
-
var ground_vert_default = modifySymbol2(ground_horz_default).rotateRightFacingSymbol("down").build();
|
3020
|
+
var ground_vert_default = modifySymbol(ground_horz_default).rotateRightFacingSymbol("down").build();
|
2960
3021
|
|
2961
3022
|
// assets/generated/gunn_diode.json
|
2962
3023
|
var gunn_diode_default = {
|
@@ -10621,8 +10682,7 @@ var schottky_diode_default = {
|
|
10621
10682
|
};
|
10622
10683
|
|
10623
10684
|
// symbols/schottky_diode_horz.ts
|
10624
|
-
|
10625
|
-
var schottky_diode_horz_default = modifySymbol3(schottky_diode_default).labelPort("left1", ["1", "pos"]).labelPort("right1", ["2", "neg"]).changeTextAnchor("{VAL}", "middle_bottom").changeTextAnchor("{REF}", "middle_top").build();
|
10685
|
+
var schottky_diode_horz_default = modifySymbol(schottky_diode_default).labelPort("left1", ["1", "pos"]).labelPort("right1", ["2", "neg"]).changeTextAnchor("{VAL}", "middle_bottom").changeTextAnchor("{REF}", "middle_top").build();
|
10626
10686
|
|
10627
10687
|
// symbols/schottky_diode_vert.ts
|
10628
10688
|
var rotated10 = rotateSymbol(schottky_diode_horz_default);
|