circuit-to-svg 0.0.237 → 0.0.238
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/index.d.ts +2 -0
- package/dist/index.js +35 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ interface PinoutSvgContext {
|
|
|
112
112
|
};
|
|
113
113
|
styleScale: number;
|
|
114
114
|
label_positions: Map<string, LabelPosition>;
|
|
115
|
+
svgWidth: number;
|
|
116
|
+
svgHeight: number;
|
|
115
117
|
}
|
|
116
118
|
declare function convertCircuitJsonToPinoutSvg(soup: AnyCircuitElement[], options?: Options$2): string;
|
|
117
119
|
|
package/dist/index.js
CHANGED
|
@@ -2913,7 +2913,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
2913
2913
|
var package_default = {
|
|
2914
2914
|
name: "circuit-to-svg",
|
|
2915
2915
|
type: "module",
|
|
2916
|
-
version: "0.0.
|
|
2916
|
+
version: "0.0.237",
|
|
2917
2917
|
description: "Convert Circuit JSON to SVG",
|
|
2918
2918
|
main: "dist/index.js",
|
|
2919
2919
|
files: [
|
|
@@ -4339,6 +4339,10 @@ var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
|
4339
4339
|
function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
4340
4340
|
const { transform, soup } = ctx;
|
|
4341
4341
|
const { width, height, center, outline } = pcbBoard;
|
|
4342
|
+
const sourceBoard = soup.find(
|
|
4343
|
+
(elm) => elm.type === "source_board" && elm.title
|
|
4344
|
+
);
|
|
4345
|
+
const title = sourceBoard?.title;
|
|
4342
4346
|
let path;
|
|
4343
4347
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
4344
4348
|
path = outline.map((point, index) => {
|
|
@@ -4387,7 +4391,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4387
4391
|
} else if (cutout.shape === "circle") {
|
|
4388
4392
|
}
|
|
4389
4393
|
}
|
|
4390
|
-
|
|
4394
|
+
const svgObjects = [
|
|
4391
4395
|
{
|
|
4392
4396
|
name: "path",
|
|
4393
4397
|
type: "element",
|
|
@@ -4404,6 +4408,29 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4404
4408
|
}
|
|
4405
4409
|
}
|
|
4406
4410
|
];
|
|
4411
|
+
if (title) {
|
|
4412
|
+
const titleX = ctx.svgWidth / 2;
|
|
4413
|
+
const titleY = 30;
|
|
4414
|
+
svgObjects.push({
|
|
4415
|
+
name: "text",
|
|
4416
|
+
type: "element",
|
|
4417
|
+
value: "",
|
|
4418
|
+
children: [
|
|
4419
|
+
{ name: "", type: "text", value: title, attributes: {}, children: [] }
|
|
4420
|
+
],
|
|
4421
|
+
attributes: {
|
|
4422
|
+
x: titleX.toString(),
|
|
4423
|
+
y: titleY.toString(),
|
|
4424
|
+
"text-anchor": "middle",
|
|
4425
|
+
"font-size": "18px",
|
|
4426
|
+
"font-weight": "bold",
|
|
4427
|
+
"font-family": "Arial, sans-serif",
|
|
4428
|
+
fill: "black",
|
|
4429
|
+
class: "pinout-board-title"
|
|
4430
|
+
}
|
|
4431
|
+
});
|
|
4432
|
+
}
|
|
4433
|
+
return svgObjects;
|
|
4407
4434
|
}
|
|
4408
4435
|
|
|
4409
4436
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
@@ -5398,6 +5425,9 @@ function convertCircuitJsonToPinoutSvg(soup, options) {
|
|
|
5398
5425
|
const paddingMm = 2;
|
|
5399
5426
|
let svgWidth = options?.width ?? 1200;
|
|
5400
5427
|
let svgHeight = options?.height ?? 768;
|
|
5428
|
+
const boardTitle = soup.find(
|
|
5429
|
+
(e) => e.type === "source_board" && !!e.title
|
|
5430
|
+
)?.title;
|
|
5401
5431
|
const board_bounds = { minX, minY, maxX, maxY };
|
|
5402
5432
|
const pinout_ports = soup.filter(
|
|
5403
5433
|
(elm) => elm.type === "pcb_port" && elm.is_board_pinout
|
|
@@ -5519,7 +5549,9 @@ function convertCircuitJsonToPinoutSvg(soup, options) {
|
|
|
5519
5549
|
soup,
|
|
5520
5550
|
board_bounds,
|
|
5521
5551
|
styleScale,
|
|
5522
|
-
label_positions
|
|
5552
|
+
label_positions,
|
|
5553
|
+
svgWidth,
|
|
5554
|
+
svgHeight
|
|
5523
5555
|
};
|
|
5524
5556
|
const svgObjects = soup.sort(
|
|
5525
5557
|
(a, b) => (OBJECT_ORDER2.indexOf(a.type) ?? 9999) - (OBJECT_ORDER2.indexOf(b.type) ?? 9999)
|