@tscircuit/pcb-viewer 1.0.0 → 1.0.2
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/PCBViewer.d.ts +5 -0
- package/dist/PCBViewer.js +662 -0
- package/dist/PCBViewer.js.map +1 -0
- package/dist/assets/alphabet.d.ts +47 -0
- package/{src/assets/alphabet.ts → dist/assets/alphabet.js} +41 -24
- package/dist/assets/alphabet.js.map +1 -0
- package/dist/assets/attiny-eagle.d.ts +133 -0
- package/{src/assets/attiny-eagle.ts → dist/assets/attiny-eagle.js} +156 -130
- package/dist/assets/attiny-eagle.js.map +1 -0
- package/dist/components/CanvasElementsRenderer.d.ts +14 -0
- package/dist/components/CanvasElementsRenderer.js +647 -0
- package/dist/components/CanvasElementsRenderer.js.map +1 -0
- package/dist/components/CanvasPrimitiveRenderer.d.ts +14 -0
- package/dist/components/CanvasPrimitiveRenderer.js +588 -0
- package/dist/components/CanvasPrimitiveRenderer.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +666 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/Drawer.d.ts +146 -0
- package/dist/lib/Drawer.js +396 -0
- package/dist/lib/Drawer.js.map +1 -0
- package/dist/lib/colors.d.ts +154 -0
- package/{src/lib/colors.ts → dist/lib/colors.js} +37 -13
- package/dist/lib/colors.js.map +1 -0
- package/dist/lib/convert-element-to-primitive.d.ts +6 -0
- package/dist/lib/convert-element-to-primitive.js +72 -0
- package/dist/lib/convert-element-to-primitive.js.map +1 -0
- package/dist/lib/convert-text-to-lines.d.ts +5 -0
- package/dist/lib/convert-text-to-lines.js +114 -0
- package/dist/lib/convert-text-to-lines.js.map +1 -0
- package/dist/lib/draw-eagle.d.ts +7 -0
- package/dist/lib/draw-eagle.js +63 -0
- package/dist/lib/draw-eagle.js.map +1 -0
- package/dist/lib/draw-grid.d.ts +18 -0
- package/dist/lib/draw-grid.js +79 -0
- package/dist/lib/draw-grid.js.map +1 -0
- package/dist/lib/draw-primitives.d.ts +12 -0
- package/dist/lib/draw-primitives.js +181 -0
- package/dist/lib/draw-primitives.js.map +1 -0
- package/dist/lib/types.d.ts +52 -0
- package/dist/lib/types.js +18 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/util/scale-only.d.ts +5 -0
- package/dist/lib/util/scale-only.js +34 -0
- package/dist/lib/util/scale-only.js.map +1 -0
- package/dist/pages/eagle.d.ts +3 -0
- package/dist/pages/eagle.js +1265 -0
- package/dist/pages/eagle.js.map +1 -0
- package/dist/pages/index.d.ts +3 -0
- package/dist/pages/index.js +390 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/primitives.d.ts +3 -0
- package/dist/pages/primitives.js +619 -0
- package/dist/pages/primitives.js.map +1 -0
- package/dist/pages/viewer.d.ts +14 -0
- package/dist/pages/viewer.js +676 -0
- package/dist/pages/viewer.js.map +1 -0
- package/package.json +14 -4
- package/.github/workflows/npm-semantic-release.yml +0 -29
- package/next-env.d.ts +0 -5
- package/release.config.js +0 -16
- package/src/PCBViewer.tsx +0 -24
- package/src/components/CanvasElementsRenderer.tsx +0 -15
- package/src/components/CanvasPrimitiveRenderer.tsx +0 -25
- package/src/index.tsx +0 -2
- package/src/lib/Drawer.ts +0 -168
- package/src/lib/convert-element-to-primitive.ts +0 -31
- package/src/lib/convert-text-to-lines.ts +0 -31
- package/src/lib/draw-eagle.ts +0 -45
- package/src/lib/draw-primitives.ts +0 -69
- package/src/lib/types.ts +0 -54
- package/src/lib/util/scale-only.ts +0 -7
- package/src/pages/eagle.tsx +0 -20
- package/src/pages/index.tsx +0 -23
- package/src/pages/primitives.tsx +0 -64
- package/src/pages/viewer.tsx +0 -43
- package/tsconfig.json +0 -21
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/lib/draw-eagle.ts
|
|
20
|
+
var draw_eagle_exports = {};
|
|
21
|
+
__export(draw_eagle_exports, {
|
|
22
|
+
drawEagle: () => drawEagle
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(draw_eagle_exports);
|
|
25
|
+
var import_transformation_matrix = require("transformation-matrix");
|
|
26
|
+
var drawEagle = (drawer, eagle) => {
|
|
27
|
+
const pkg = eagle.library.packages[0];
|
|
28
|
+
if (eagle.grid.unit === "inch") {
|
|
29
|
+
drawer.transform = (0, import_transformation_matrix.compose)(
|
|
30
|
+
(0, import_transformation_matrix.fromDefinition)(
|
|
31
|
+
(0, import_transformation_matrix.fromTransformAttribute)("translate(200, 200) scale(30,-30)")
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const layerMap = {};
|
|
36
|
+
for (const layer of eagle.layers) {
|
|
37
|
+
layerMap[layer.number] = layer;
|
|
38
|
+
}
|
|
39
|
+
for (const smd of pkg.smd || []) {
|
|
40
|
+
drawer.equip({
|
|
41
|
+
color: layerMap[smd.layer].name
|
|
42
|
+
});
|
|
43
|
+
drawer.rect(smd.x - smd.dx / 2, smd.y - smd.dy / 2, smd.dx, smd.dy);
|
|
44
|
+
}
|
|
45
|
+
for (const wire of pkg.wire || []) {
|
|
46
|
+
drawer.equip({
|
|
47
|
+
size: wire.width,
|
|
48
|
+
shape: "circle",
|
|
49
|
+
color: layerMap[wire.layer].name
|
|
50
|
+
});
|
|
51
|
+
drawer.moveTo(wire.x1, wire.y1);
|
|
52
|
+
drawer.lineTo(wire.x2, wire.y2);
|
|
53
|
+
}
|
|
54
|
+
for (const circle of pkg.circle || []) {
|
|
55
|
+
drawer.equip({ color: layerMap[circle.layer].name });
|
|
56
|
+
drawer.circle(circle.x, circle.y, circle.radius);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
drawEagle
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=draw-eagle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/draw-eagle.ts"],"sourcesContent":["import { EagleJSON, Layer } from \"@tscircuit/eagle-xml-converter\"\nimport {\n compose,\n fromDefinition,\n fromTransformAttribute,\n} from \"transformation-matrix\"\nimport { Drawer } from \"./Drawer\"\n\nexport const drawEagle = (drawer: Drawer, eagle: EagleJSON) => {\n const pkg = eagle.library.packages[0]\n\n if (eagle.grid.unit === \"inch\") {\n drawer.transform = compose(\n fromDefinition(\n fromTransformAttribute(\"translate(200, 200) scale(30,-30)\")\n )\n )\n }\n\n const layerMap: Record<number, Layer> = {}\n for (const layer of eagle.layers) {\n layerMap[layer.number] = layer\n }\n\n for (const smd of pkg.smd || []) {\n drawer.equip({\n color: layerMap[smd.layer].name,\n })\n drawer.rect(smd.x - smd.dx / 2, smd.y - smd.dy / 2, smd.dx, smd.dy)\n }\n for (const wire of pkg.wire || []) {\n drawer.equip({\n size: wire.width,\n shape: \"circle\",\n color: layerMap[wire.layer].name,\n })\n drawer.moveTo(wire.x1, wire.y1)\n drawer.lineTo(wire.x2, wire.y2)\n }\n\n for (const circle of pkg.circle || []) {\n drawer.equip({ color: layerMap[circle.layer].name })\n drawer.circle(circle.x, circle.y, circle.radius)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mCAIO;AAGA,IAAM,YAAY,CAAC,QAAgB,UAAqB;AAC7D,QAAM,MAAM,MAAM,QAAQ,SAAS;AAEnC,MAAI,MAAM,KAAK,SAAS,QAAQ;AAC9B,WAAO,gBAAY;AAAA,UACjB;AAAA,YACE,qDAAuB,mCAAmC;AAAA,MAC5D;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAkC,CAAC;AACzC,aAAW,SAAS,MAAM,QAAQ;AAChC,aAAS,MAAM,UAAU;AAAA,EAC3B;AAEA,aAAW,OAAO,IAAI,OAAO,CAAC,GAAG;AAC/B,WAAO,MAAM;AAAA,MACX,OAAO,SAAS,IAAI,OAAO;AAAA,IAC7B,CAAC;AACD,WAAO,KAAK,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,IAAI,EAAE;AAAA,EACpE;AACA,aAAW,QAAQ,IAAI,QAAQ,CAAC,GAAG;AACjC,WAAO,MAAM;AAAA,MACX,MAAM,KAAK;AAAA,MACX,OAAO;AAAA,MACP,OAAO,SAAS,KAAK,OAAO;AAAA,IAC9B,CAAC;AACD,WAAO,OAAO,KAAK,IAAI,KAAK,EAAE;AAC9B,WAAO,OAAO,KAAK,IAAI,KAAK,EAAE;AAAA,EAChC;AAEA,aAAW,UAAU,IAAI,UAAU,CAAC,GAAG;AACrC,WAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,KAAK,CAAC;AACnD,WAAO,OAAO,OAAO,GAAG,OAAO,GAAG,OAAO,MAAM;AAAA,EACjD;AACF;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Matrix } from 'transformation-matrix';
|
|
2
|
+
import { Drawer } from './Drawer.js';
|
|
3
|
+
import { GridConfig } from './types.js';
|
|
4
|
+
|
|
5
|
+
declare const transformBounds: (transform: Matrix, bounds: {
|
|
6
|
+
left: number;
|
|
7
|
+
right: number;
|
|
8
|
+
top: number;
|
|
9
|
+
bottom: number;
|
|
10
|
+
}) => {
|
|
11
|
+
left: number;
|
|
12
|
+
right: number;
|
|
13
|
+
top: number;
|
|
14
|
+
bottom: number;
|
|
15
|
+
};
|
|
16
|
+
declare const drawGrid: (drawer: Drawer, grid_config: GridConfig) => void;
|
|
17
|
+
|
|
18
|
+
export { drawGrid, transformBounds };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/lib/draw-grid.ts
|
|
20
|
+
var draw_grid_exports = {};
|
|
21
|
+
__export(draw_grid_exports, {
|
|
22
|
+
drawGrid: () => drawGrid,
|
|
23
|
+
transformBounds: () => transformBounds
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(draw_grid_exports);
|
|
26
|
+
var import_transformation_matrix = require("transformation-matrix");
|
|
27
|
+
|
|
28
|
+
// src/lib/util/scale-only.ts
|
|
29
|
+
var scaleOnly = (mat, value = 1) => {
|
|
30
|
+
if (Math.abs(mat.a) !== Math.abs(mat.d))
|
|
31
|
+
throw new Error("Cannot scale non-uniformly");
|
|
32
|
+
return value * Math.abs(mat.a);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/lib/draw-grid.ts
|
|
36
|
+
var transformBounds = (transform, bounds) => {
|
|
37
|
+
const { left, right, top, bottom } = bounds;
|
|
38
|
+
const [left$, top$] = (0, import_transformation_matrix.applyToPoint)(transform, [left, top]);
|
|
39
|
+
const [right$, bottom$] = (0, import_transformation_matrix.applyToPoint)(transform, [right, bottom]);
|
|
40
|
+
return {
|
|
41
|
+
left: Math.min(left$, right$),
|
|
42
|
+
right: Math.max(left$, right$),
|
|
43
|
+
top: Math.max(bottom$, top$),
|
|
44
|
+
bottom: Math.min(bottom$, top$)
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
var drawGrid = (drawer, grid_config) => {
|
|
48
|
+
const { spacing, view_window } = grid_config;
|
|
49
|
+
const transformed_window = transformBounds(drawer.transform, view_window);
|
|
50
|
+
const { left, right, top, bottom } = transformed_window;
|
|
51
|
+
const startx = Math.floor(left / spacing) * spacing;
|
|
52
|
+
const starty = Math.floor(bottom / spacing) * spacing;
|
|
53
|
+
const px = scaleOnly((0, import_transformation_matrix.inverse)(drawer.transform));
|
|
54
|
+
drawer.equip({
|
|
55
|
+
color: "green",
|
|
56
|
+
mode: "add",
|
|
57
|
+
shape: "circle",
|
|
58
|
+
size: px
|
|
59
|
+
});
|
|
60
|
+
for (let x = startx; x < right; x += spacing) {
|
|
61
|
+
drawer.moveTo(x, bottom);
|
|
62
|
+
drawer.lineTo(x, top);
|
|
63
|
+
}
|
|
64
|
+
for (let y = starty; y < top; y += spacing) {
|
|
65
|
+
drawer.moveTo(left, y);
|
|
66
|
+
drawer.lineTo(right, y);
|
|
67
|
+
}
|
|
68
|
+
for (let x = startx; x < right; x += spacing) {
|
|
69
|
+
for (let y = starty; y < top; y += spacing) {
|
|
70
|
+
drawer.debugText(`${x}, ${y}`, x + px * 3, y + px * 3);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
drawGrid,
|
|
77
|
+
transformBounds
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=draw-grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/draw-grid.ts","../../src/lib/util/scale-only.ts"],"sourcesContent":["import { applyToPoint, Matrix, inverse } from \"transformation-matrix\"\nimport { Drawer } from \"./Drawer\"\nimport { GridConfig } from \"./types\"\nimport { scaleOnly } from \"./util/scale-only\"\n\nexport const transformBounds = (\n transform: Matrix,\n bounds: { left: number; right: number; top: number; bottom: number }\n) => {\n const { left, right, top, bottom } = bounds\n const [left$, top$] = applyToPoint(transform, [left, top])\n const [right$, bottom$] = applyToPoint(transform, [right, bottom])\n return {\n left: Math.min(left$, right$),\n right: Math.max(left$, right$),\n top: Math.max(bottom$, top$),\n bottom: Math.min(bottom$, top$),\n }\n}\n\nexport const drawGrid = (drawer: Drawer, grid_config: GridConfig) => {\n const { spacing, view_window } = grid_config\n\n const transformed_window = transformBounds(drawer.transform, view_window)\n\n const { left, right, top, bottom } = transformed_window\n\n const startx = Math.floor(left / spacing) * spacing\n const starty = Math.floor(bottom / spacing) * spacing\n\n const px = scaleOnly(inverse(drawer.transform))\n\n drawer.equip({\n color: \"green\",\n mode: \"add\",\n shape: \"circle\",\n size: px,\n })\n\n for (let x = startx; x < right; x += spacing) {\n drawer.moveTo(x, bottom)\n drawer.lineTo(x, top)\n }\n\n for (let y = starty; y < top; y += spacing) {\n drawer.moveTo(left, y)\n drawer.lineTo(right, y)\n }\n\n for (let x = startx; x < right; x += spacing) {\n for (let y = starty; y < top; y += spacing) {\n drawer.debugText(`${x}, ${y}`, x + px * 3, y + px * 3)\n }\n }\n}\n","import { Matrix } from \"transformation-matrix\"\n\nexport const scaleOnly = (mat: Matrix, value: number = 1) => {\n if (Math.abs(mat.a) !== Math.abs(mat.d))\n throw new Error(\"Cannot scale non-uniformly\")\n return value * Math.abs(mat.a)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAA8C;;;ACEvC,IAAM,YAAY,CAAC,KAAa,QAAgB,MAAM;AAC3D,MAAI,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,CAAC;AACpC,UAAM,IAAI,MAAM,4BAA4B;AAC9C,SAAO,QAAQ,KAAK,IAAI,IAAI,CAAC;AAC/B;;;ADDO,IAAM,kBAAkB,CAC7B,WACA,WACG;AACH,QAAM,EAAE,MAAM,OAAO,KAAK,OAAO,IAAI;AACrC,QAAM,CAAC,OAAO,IAAI,QAAI,2CAAa,WAAW,CAAC,MAAM,GAAG,CAAC;AACzD,QAAM,CAAC,QAAQ,OAAO,QAAI,2CAAa,WAAW,CAAC,OAAO,MAAM,CAAC;AACjE,SAAO;AAAA,IACL,MAAM,KAAK,IAAI,OAAO,MAAM;AAAA,IAC5B,OAAO,KAAK,IAAI,OAAO,MAAM;AAAA,IAC7B,KAAK,KAAK,IAAI,SAAS,IAAI;AAAA,IAC3B,QAAQ,KAAK,IAAI,SAAS,IAAI;AAAA,EAChC;AACF;AAEO,IAAM,WAAW,CAAC,QAAgB,gBAA4B;AACnE,QAAM,EAAE,SAAS,YAAY,IAAI;AAEjC,QAAM,qBAAqB,gBAAgB,OAAO,WAAW,WAAW;AAExE,QAAM,EAAE,MAAM,OAAO,KAAK,OAAO,IAAI;AAErC,QAAM,SAAS,KAAK,MAAM,OAAO,OAAO,IAAI;AAC5C,QAAM,SAAS,KAAK,MAAM,SAAS,OAAO,IAAI;AAE9C,QAAM,KAAK,cAAU,sCAAQ,OAAO,SAAS,CAAC;AAE9C,SAAO,MAAM;AAAA,IACX,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,EACR,CAAC;AAED,WAAS,IAAI,QAAQ,IAAI,OAAO,KAAK,SAAS;AAC5C,WAAO,OAAO,GAAG,MAAM;AACvB,WAAO,OAAO,GAAG,GAAG;AAAA,EACtB;AAEA,WAAS,IAAI,QAAQ,IAAI,KAAK,KAAK,SAAS;AAC1C,WAAO,OAAO,MAAM,CAAC;AACrB,WAAO,OAAO,OAAO,CAAC;AAAA,EACxB;AAEA,WAAS,IAAI,QAAQ,IAAI,OAAO,KAAK,SAAS;AAC5C,aAAS,IAAI,QAAQ,IAAI,KAAK,KAAK,SAAS;AAC1C,aAAO,UAAU,GAAG,MAAM,KAAK,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC;AAAA,IACvD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Line, Text, Rect, Circle, Primitive } from './types.js';
|
|
2
|
+
import { Drawer } from './Drawer.js';
|
|
3
|
+
import 'transformation-matrix';
|
|
4
|
+
|
|
5
|
+
declare const drawLine: (drawer: Drawer, line: Line) => void;
|
|
6
|
+
declare const drawText: (drawer: Drawer, text: Text) => void;
|
|
7
|
+
declare const drawRect: (drawer: Drawer, rect: Rect) => void;
|
|
8
|
+
declare const drawCircle: (drawer: Drawer, circle: Circle) => void;
|
|
9
|
+
declare const drawPrimitive: (drawer: Drawer, primitive: Primitive) => void;
|
|
10
|
+
declare const drawPrimitives: (drawer: Drawer, primitives: Primitive[]) => void;
|
|
11
|
+
|
|
12
|
+
export { drawCircle, drawLine, drawPrimitive, drawPrimitives, drawRect, drawText };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/lib/draw-primitives.ts
|
|
20
|
+
var draw_primitives_exports = {};
|
|
21
|
+
__export(draw_primitives_exports, {
|
|
22
|
+
drawCircle: () => drawCircle,
|
|
23
|
+
drawLine: () => drawLine,
|
|
24
|
+
drawPrimitive: () => drawPrimitive,
|
|
25
|
+
drawPrimitives: () => drawPrimitives,
|
|
26
|
+
drawRect: () => drawRect,
|
|
27
|
+
drawText: () => drawText
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(draw_primitives_exports);
|
|
30
|
+
|
|
31
|
+
// src/assets/alphabet.ts
|
|
32
|
+
var svgAlphabet = {
|
|
33
|
+
"0": "M0.4544564813877358 0L0.2723441540828736 0.03592830447352719L0.1086847233315459 0.14528754990019965L0.020630545837255005 0.3040632652221331L0 0.5395277421960205L0.049259221760993496 0.7369487828466779L0.18080513776237842 0.9005494166306564L0.37036887043974215 0.9872116270037247L0.5864663759301132 1L0.8148695622827444 0.9332890276148733L0.9326583645506394 0.8113052246023419L1 0.4031281830668562L0.833288960385582 0.09886798567812842L0.6801767918233781 0.02483708485091681L0.4544564813877358 0",
|
|
34
|
+
"1": "M 0.198 0.272 L 0.537 0 L 0.54 1",
|
|
35
|
+
"2": "M0.069593147751606 0.19461498231706575L0.1039380353319058 0.1224291500164194L0.20543361884368308 0.05510832064153169L0.3717712794432549 0.009452970962689482L0.4785344452623127 0L0.663238590738758 0.008714098643339864L0.8017933618843684 0.04769189395915288L0.8775637379550322 0.10746757678258442L0.9047778372591005 0.17693069668193287L0.9029710920770878 0.2231347105796246L0.8704496788008566 0.30047744598157516L0.7292906538577354 0.4508486051631194L0.3737955032119913 0.7369006417749693L0 1L1 1",
|
|
36
|
+
"3": "M0.03917438899874637 0.19855364635107545L0.15510940508963084 0.06745632622133718L0.37598645522339846 0L0.8486391893813088 0.0652271323161611L0.9782182415054349 0.21747394183735683L0.9213133780517754 0.3547560290117714L0.6504271515903481 0.4543436297681271L0.22975249764129613 0.48476611625264143L0.7659038682744629 0.5411919558122493L0.9258712987734741 0.6203185665660985L1 0.7458360609169667L0.8938813281118737 0.9059190913045964L0.6166890258875837 1L0.261528440153542 0.9874861530507921L0 0.8837289530851273",
|
|
37
|
+
"4": "M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1",
|
|
38
|
+
"5": "M 0 0 L 0 0.4973 L 0.4262 0.4319 L 0.7305 0.4565 L 0.8516 0.5009 L 0.9357 0.5639 L 1 0.7356 L 0.9696 0.8248 L 0.8898 0.895 L 0.733 0.9602 L 0.5518 0.9945 L 0.3814 1 L 0.2379 0.9821 L 0.1219 0.947 L 0 0.8748 M 0 0 L 1 0",
|
|
39
|
+
"6": "M0.6964601700926856 0L0.3639239026215478 0.0743562375769351L0.1415931962925719 0.21735490179786915L0.009977939399608712 0.46336322325406004L0.00029622007592593224 0.7083131475173043L0.09408885043224748 0.8746809149767036L0.3379247445101846 0.9876686500961888L0.7109203869569624 1L0.9260852957913362 0.9103558029693921L1 0.7716571969091733L0.9824294723385016 0.6390635485705886L0.7446504992867332 0.4733643097729175L0.31028858071607296 0.47578021640899115L0.1208702146816024 0.5481452483973847L0 0.6616669755788906",
|
|
40
|
+
"7": "M0 0L1 0L0.9246479649697582 0.030539772727272752L0.8850302419354837 0.05075757575757579L0.7922946068548385 0.11079545454545457L0.7419268208165322 0.15213068181818185L0.6907258064516127 0.20202020202020204L0.6400666267641127 0.26122159090909086L0.5913243447580644 0.33049242424242414L0.5458740234374998 0.4105902777777778L0.5050907258064514 0.5022727272727272L0.4703495148689514 0.6062973484848484L0.43257456133442534 0.787133049242424L0.41612903225806447 1",
|
|
41
|
+
"8": "M0.5143001078924863 0L0.16007477667923162 0.10731570786949331L0.14924628550868277 0.3146018498698755L0.2939585848842112 0.41617921794558677L0.8648302624811545 0.5385163833653317L1 0.7775820770511038L0.8180842915260376 0.9505845566922285L0.41968938540525413 1L0.08062381919779889 0.882831681184498L0 0.6936376947135333L0.17150171673893433 0.5188652309607817L0.6529263782780712 0.4242818653203618L0.8650205888491803 0.29644027376796367L0.8702067371119496 0.09910067291661573L0.5143001078924863 0",
|
|
42
|
+
"9": "M1 0.25379591792994305L0.9514789771111742 0.11679361536614272L0.8702482473521467 0.05711741614054847L0.7327445265851579 0.015213872471965633L0.525248180711544 0L0.3292056884418538 0.012928195113745608L0.15997632037247655 0.058762870026191856L0.05266940041228321 0.12882439350476L0 0.2562067822770946L0.11316462894512366 0.4121335905917837L0.2403060136479954 0.4603365890068938L0.4097241967586011 0.4745978388276783L0.8642414300184816 0.420815170259988L0.9732054796346318 0.34537434075898393L1 0.25379591792994305M0.9647426784191072 0.35488595400360495L0.4756895081034974 1",
|
|
43
|
+
A: "M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365",
|
|
44
|
+
B: "M0 1L0 0.0117369978777208L0.30665717153513444 0L0.5874522807082946 0.03451403469442413L0.7766202217193218 0.15033936404895643L0.7471969743588041 0.31967962568332936L0.5246013359741988 0.4102978954282461L0.04378745314885416 0.44918617613783574L0.5112949594180156 0.469692928091109L0.8540266515643348 0.5552749498651879L1 0.6868463175009967L0.9880091196159324 0.8570018204672155L0.922301719975498 0.9321708046604659L0.7584266951758925 0.9932594737131338L0 1",
|
|
45
|
+
C: "M1 0.23038928858890784L0.9328355511865092 0.12426412616785204L0.8096380839483327 0.04912601676267708L0.5763225801788256 0L0.4039037709527492 0.015028068281399815L0.2519579390951737 0.06533979308999706L0.10359458463139784 0.18146243506591617L0 0.4862728453971315L0.08129580872733055 0.792689266886982L0.20257034847159672 0.9160822255736587L0.3286572892798542 0.9738230826074175L0.5742878414421707 1L0.7883510303801312 0.9665431511195721L0.946851033994232 0.8689071500976585L1 0.7311049027121912",
|
|
46
|
+
D: "M0 1L0.015604366822624637 0.020770988281483303L0.22564758265176144 0L0.3865476147957666 0.0024153386496795644L0.6479126635475078 0.051745644338731314L0.841191887805517 0.15827717679529366L0.9517008345536152 0.30172260586872185L0.9957536578687336 0.4504541551987709L1 0.5624359222498485L0.9798483279164735 0.6584121775234548L0.9386273319285215 0.7395945263504481L0.806292129480815 0.8624239259880274L0.6296239151398265 0.9406169638094516L0.3397492767598845 0.9954164354263132L0 1",
|
|
47
|
+
E: "M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1",
|
|
48
|
+
F: "M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823",
|
|
49
|
+
G: "M0.902666857540557 0.03860785012651126L0.6504261864675637 0L0.3838947267237336 0.015442305268228053L0.21293332876776194 0.07706794377239819L0.07799659974941617 0.1994951236187481L0 0.46380381528937314L0.04159964421546915 0.7502491408002389L0.13176692977834842 0.8535497868383203L0.2709176262273927 0.936767572377719L0.4386472596876406 0.9891638569283179L0.6145513562841309 1L0.7782254421419019 0.9585373611026471L0.9092650433859927 0.8540372997461425L1 0.5556012645283437L0.5583959277303046 0.55491741080559",
|
|
50
|
+
H: "M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1",
|
|
51
|
+
I: "MNaN 0LNaN 1",
|
|
52
|
+
J: "M0.9976457238788704 0L1 0.7396412315872798L0.9773931362096968 0.8322033314977973L0.9345115952458736 0.882296255506608L0.8743862896259549 0.9221331222466961L0.8024024079884948 0.9526431718061675L0.6443996712151668 0.9893997797356828L0.5035848940343224 1L0.3127211130319937 0.9877004749449337L0.17201910858386513 0.9539509911894274L0.10357419806379677 0.9212555066079295L0.053656568662899015 0.8816079295154184L0.020759483663648916 0.8360407488986785L0.003376206348523566 0.7855864537444934L0 0.7312775330396476",
|
|
53
|
+
K: "M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777",
|
|
54
|
+
L: "M0 0L0 1L1 1",
|
|
55
|
+
M: "M0 1L0 0L0.5 0.6512L1 0L1 1",
|
|
56
|
+
N: "M0 1L0 0L1 1L0.9803729146221786 0",
|
|
57
|
+
O: "M0.4718499217948183 1L0.2896765846490613 0.9606979309189402L0.12315162147934663 0.8411184486080473L0 0.4352399966492615L0.11730398524516283 0.13145645436014852L0.2612197451988078 0.04493357858878059L0.5104071592772554 0L0.7450113425917159 0.05393013710105273L0.882367950645524 0.15242300282020502L1 0.5224527406249126L0.9414597290654386 0.7560662329321755L0.8371289514446183 0.8910800547287298L0.6518259868433511 0.9830452628933628L0.4718499217948183 1",
|
|
58
|
+
P: "M0 1L0 0.018871774228013626L0.29609603495819875 0L0.5609840637427541 0.011794858892508529L0.7332142696692472 0.04353904702296349L0.8102258645858864 0.0691965055027166L0.9330504315465442 0.14445061754775845L0.9876391714147118 0.22527816445836535L1 0.3434414070631638L0.9510549958116356 0.41772808046663146L0.8746646891596713 0.45879131862541683L0.7528523813396283 0.49171525113425024L0.5766919939969619 0.5153253033973054L0.33725744877712827 0.5284469008187558L0.025622667325582785 0.529905468802775",
|
|
59
|
+
Q: "M0.4618887943546369 0.9755918167206952L0.28356128136544534 0.9372490397450218L0.12055179272160406 0.8205882753548176L0 0.4246165790405623L0.1148276047430244 0.12824784112887844L0.25570518844754375 0.043836831567190586L0.49963205786237674 0L0.7292835601228574 0.0526138004304122L0.8637404608452104 0.14870263423138746L0.9788892040030622 0.5097006183769648L0.9215847647858059 0.7376120297474734L0.8194564929275405 0.869330409436378L0.6380654214095985 0.9590509139448092L0.4618887943546369 0.9755918167206952M0.5824181120212351 0.6861805006946525L1 1",
|
|
60
|
+
R: "M0 0.9928375167236815L0 0.02590227442068435L0.3611517274211098 0L0.6146286724700761 0.008660554424468435L0.7675462459194776 0.035269459580494614L0.831839975516866 0.056961676692569484L0.8847592491838954 0.08519560521497332L0.9238557535364527 0.120683646438422L0.9583303225312839 0.21691797435320384L0.955092470586235 0.3022616904894429L0.9198097669001631 0.3640573439322699L0.8564862239866702 0.40639258627024005L0.7691258543593579 0.43335506909190874L0.601775027203482 0.4539166070813109L0.023939064200217658 0.46997623755243123M0.5038084874863982 0.5108023922274467L1 1",
|
|
61
|
+
S: "M0.8886929689221953 0.15146982162688968L0.7276173683050475 0.013780286031594946L0.34582323121005076 0L0.1318235250900008 0.09920162734298861L0.0444543935052531 0.2811287071349243L0.08064065829108809 0.3709571405906485L0.21603115127470426 0.4485505768228281L0.7525409135992945 0.5111160926769565L0.9330263665417677 0.5850732219351329L1 0.7129938124702524L0.9117772389978691 0.9130572743138187L0.6423187128058188 1L0.29586019579751677 0.9935291584506244L0.10638454191462794 0.9229845198431584L0 0.7570771288048773",
|
|
62
|
+
T: "M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1",
|
|
63
|
+
U: "M0 0L0.0023103778751369115 0.5467447428390111L0.01823032542100219 0.6954785891481812L0.05895528135268338 0.8056480226151669L0.13703402031421133 0.8894445726483398L0.23918400876232196 0.9448524533417946L0.3917887458926616 0.9848674531975652L0.584341627875137 1L0.7194816196604602 0.9848501456716763L0.8303268115073934 0.9449411544119768L0.8966613970084885 0.898186315516197L0.9251437568455642 0.867453197565408L0.9687114937020809 0.7890904895145239L0.9890470974808324 0.6852857184065537L1 0.0014769088758762145",
|
|
64
|
+
V: "M0 0L0.5348837209302325 1L1 0",
|
|
65
|
+
W: "M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845",
|
|
66
|
+
X: "M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1",
|
|
67
|
+
Y: "M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1",
|
|
68
|
+
Z: "M0 0L1 0L0 1L1 1",
|
|
69
|
+
".": "M 0.49 1 L 0.41 1"
|
|
70
|
+
};
|
|
71
|
+
var lineAlphabet = {};
|
|
72
|
+
for (const letter in svgAlphabet) {
|
|
73
|
+
lineAlphabet[letter] = [];
|
|
74
|
+
const segs = svgAlphabet[letter].split("M").slice(1).map(
|
|
75
|
+
(seg) => seg.split("L").map((pr) => pr.trim().split(" ").map(parseFloat))
|
|
76
|
+
);
|
|
77
|
+
for (const seg of segs) {
|
|
78
|
+
for (let i = 0; i < seg.length - 1; i++) {
|
|
79
|
+
lineAlphabet[letter].push({
|
|
80
|
+
x1: seg[i][0],
|
|
81
|
+
y1: 1 - seg[i][1],
|
|
82
|
+
x2: seg[i + 1][0],
|
|
83
|
+
y2: 1 - seg[i + 1][1]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/lib/convert-text-to-lines.ts
|
|
90
|
+
var convertTextToLines = (text) => {
|
|
91
|
+
const strokeWidth = text.size / 8;
|
|
92
|
+
const letterWidth = text.size * 0.6;
|
|
93
|
+
const letterSpace = text.size * 0.2;
|
|
94
|
+
const lines = [];
|
|
95
|
+
for (let letterIndex = 0; letterIndex < text.text.length; letterIndex++) {
|
|
96
|
+
const letter = text.text[letterIndex];
|
|
97
|
+
const letterLines = lineAlphabet[letter.toUpperCase()];
|
|
98
|
+
if (!letterLines)
|
|
99
|
+
continue;
|
|
100
|
+
for (const { x1, y1, x2, y2 } of letterLines) {
|
|
101
|
+
lines.push({
|
|
102
|
+
pcb_drawing_type: "line",
|
|
103
|
+
x1: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x1,
|
|
104
|
+
y1: text.y + text.size * y1,
|
|
105
|
+
x2: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x2,
|
|
106
|
+
y2: text.y + text.size * y2,
|
|
107
|
+
width: strokeWidth,
|
|
108
|
+
layer: text.layer,
|
|
109
|
+
unit: text.unit
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return lines;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/lib/draw-primitives.ts
|
|
117
|
+
var drawLine = (drawer, line) => {
|
|
118
|
+
drawer.equip({
|
|
119
|
+
size: line.width,
|
|
120
|
+
shape: line.squareCap ? "square" : "circle",
|
|
121
|
+
color: line.layer.name
|
|
122
|
+
});
|
|
123
|
+
drawer.moveTo(line.x1, line.y1);
|
|
124
|
+
drawer.lineTo(line.x2, line.y2);
|
|
125
|
+
};
|
|
126
|
+
var drawText = (drawer, text) => {
|
|
127
|
+
drawer.equip({
|
|
128
|
+
fontSize: text.size,
|
|
129
|
+
color: text.layer.name
|
|
130
|
+
});
|
|
131
|
+
if (text.align && text.align !== "top-left") {
|
|
132
|
+
console.warn("Unhandled text align", text.align);
|
|
133
|
+
}
|
|
134
|
+
const lines = convertTextToLines(text);
|
|
135
|
+
for (const line of lines) {
|
|
136
|
+
drawLine(drawer, line);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var drawRect = (drawer, rect) => {
|
|
140
|
+
drawer.equip({
|
|
141
|
+
color: rect.layer.name
|
|
142
|
+
});
|
|
143
|
+
if (rect.align && rect.align !== "center") {
|
|
144
|
+
console.warn("Unhandled rect align", rect.align);
|
|
145
|
+
}
|
|
146
|
+
drawer.rect(rect.x, rect.y, rect.w, rect.h);
|
|
147
|
+
};
|
|
148
|
+
var drawCircle = (drawer, circle) => {
|
|
149
|
+
drawer.equip({
|
|
150
|
+
color: circle.layer.name
|
|
151
|
+
});
|
|
152
|
+
drawer.circle(circle.x, circle.y, circle.r);
|
|
153
|
+
};
|
|
154
|
+
var drawPrimitive = (drawer, primitive) => {
|
|
155
|
+
switch (primitive.pcb_drawing_type) {
|
|
156
|
+
case "line":
|
|
157
|
+
return drawLine(drawer, primitive);
|
|
158
|
+
case "text":
|
|
159
|
+
return drawText(drawer, primitive);
|
|
160
|
+
case "rect":
|
|
161
|
+
return drawRect(drawer, primitive);
|
|
162
|
+
case "circle":
|
|
163
|
+
return drawCircle(drawer, primitive);
|
|
164
|
+
}
|
|
165
|
+
throw new Error(
|
|
166
|
+
`Unknown primitive type: ${primitive.pcb_drawing_type}`
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
var drawPrimitives = (drawer, primitives) => {
|
|
170
|
+
primitives.forEach((primitive) => drawPrimitive(drawer, primitive));
|
|
171
|
+
};
|
|
172
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
173
|
+
0 && (module.exports = {
|
|
174
|
+
drawCircle,
|
|
175
|
+
drawLine,
|
|
176
|
+
drawPrimitive,
|
|
177
|
+
drawPrimitives,
|
|
178
|
+
drawRect,
|
|
179
|
+
drawText
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=draw-primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/draw-primitives.ts","../../src/assets/alphabet.ts","../../src/lib/convert-text-to-lines.ts"],"sourcesContent":["import { Primitive, Line, Text, Circle, Rect } from \"./types\"\nimport { Drawer } from \"./Drawer\"\nimport { convertTextToLines } from \"./convert-text-to-lines\"\n\nexport const drawLine = (drawer: Drawer, line: Line) => {\n drawer.equip({\n size: line.width,\n shape: line.squareCap ? \"square\" : \"circle\",\n color: line.layer.name,\n })\n drawer.moveTo(line.x1, line.y1)\n drawer.lineTo(line.x2, line.y2)\n}\n\nexport const drawText = (drawer: Drawer, text: Text) => {\n drawer.equip({\n fontSize: text.size,\n color: text.layer.name,\n })\n // TODO handle align\n if (text.align && text.align !== \"top-left\") {\n console.warn(\"Unhandled text align\", text.align)\n }\n\n // Non-gerber compatible\n // drawer.text(text.text, text.x, text.y)\n\n const lines = convertTextToLines(text)\n for (const line of lines) {\n drawLine(drawer, line)\n }\n}\n\nexport const drawRect = (drawer: Drawer, rect: Rect) => {\n drawer.equip({\n color: rect.layer.name,\n })\n if (rect.align && rect.align !== \"center\") {\n console.warn(\"Unhandled rect align\", rect.align)\n }\n drawer.rect(rect.x, rect.y, rect.w, rect.h)\n}\n\nexport const drawCircle = (drawer: Drawer, circle: Circle) => {\n drawer.equip({\n color: circle.layer.name,\n })\n drawer.circle(circle.x, circle.y, circle.r)\n}\n\nexport const drawPrimitive = (drawer: Drawer, primitive: Primitive) => {\n switch (primitive.pcb_drawing_type) {\n case \"line\":\n return drawLine(drawer, primitive)\n case \"text\":\n return drawText(drawer, primitive)\n case \"rect\":\n return drawRect(drawer, primitive)\n case \"circle\":\n return drawCircle(drawer, primitive)\n }\n throw new Error(\n `Unknown primitive type: ${(primitive as any).pcb_drawing_type}`\n )\n}\n\nexport const drawPrimitives = (drawer: Drawer, primitives: Primitive[]) => {\n primitives.forEach((primitive) => drawPrimitive(drawer, primitive))\n}\n","/*\n * Maps letters/numbers to an SVG path\n * You must normalize the path prior to putting it here! That means it needs to\n * be entirely in the bounds [0,1] for both x and y.\n * You can use this svg editor tool to add characters: https://yqnn.github.io/svg-path-editor/\n */\nexport const svgAlphabet = {\n \"0\": \"M0.4544564813877358 0L0.2723441540828736 0.03592830447352719L0.1086847233315459 0.14528754990019965L0.020630545837255005 0.3040632652221331L0 0.5395277421960205L0.049259221760993496 0.7369487828466779L0.18080513776237842 0.9005494166306564L0.37036887043974215 0.9872116270037247L0.5864663759301132 1L0.8148695622827444 0.9332890276148733L0.9326583645506394 0.8113052246023419L1 0.4031281830668562L0.833288960385582 0.09886798567812842L0.6801767918233781 0.02483708485091681L0.4544564813877358 0\",\n \"1\": \"M 0.198 0.272 L 0.537 0 L 0.54 1\",\n \"2\": \"M0.069593147751606 0.19461498231706575L0.1039380353319058 0.1224291500164194L0.20543361884368308 0.05510832064153169L0.3717712794432549 0.009452970962689482L0.4785344452623127 0L0.663238590738758 0.008714098643339864L0.8017933618843684 0.04769189395915288L0.8775637379550322 0.10746757678258442L0.9047778372591005 0.17693069668193287L0.9029710920770878 0.2231347105796246L0.8704496788008566 0.30047744598157516L0.7292906538577354 0.4508486051631194L0.3737955032119913 0.7369006417749693L0 1L1 1\",\n \"3\": \"M0.03917438899874637 0.19855364635107545L0.15510940508963084 0.06745632622133718L0.37598645522339846 0L0.8486391893813088 0.0652271323161611L0.9782182415054349 0.21747394183735683L0.9213133780517754 0.3547560290117714L0.6504271515903481 0.4543436297681271L0.22975249764129613 0.48476611625264143L0.7659038682744629 0.5411919558122493L0.9258712987734741 0.6203185665660985L1 0.7458360609169667L0.8938813281118737 0.9059190913045964L0.6166890258875837 1L0.261528440153542 0.9874861530507921L0 0.8837289530851273\",\n \"4\": \"M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1\",\n \"5\": \"M 0 0 L 0 0.4973 L 0.4262 0.4319 L 0.7305 0.4565 L 0.8516 0.5009 L 0.9357 0.5639 L 1 0.7356 L 0.9696 0.8248 L 0.8898 0.895 L 0.733 0.9602 L 0.5518 0.9945 L 0.3814 1 L 0.2379 0.9821 L 0.1219 0.947 L 0 0.8748 M 0 0 L 1 0\",\n \"6\": \"M0.6964601700926856 0L0.3639239026215478 0.0743562375769351L0.1415931962925719 0.21735490179786915L0.009977939399608712 0.46336322325406004L0.00029622007592593224 0.7083131475173043L0.09408885043224748 0.8746809149767036L0.3379247445101846 0.9876686500961888L0.7109203869569624 1L0.9260852957913362 0.9103558029693921L1 0.7716571969091733L0.9824294723385016 0.6390635485705886L0.7446504992867332 0.4733643097729175L0.31028858071607296 0.47578021640899115L0.1208702146816024 0.5481452483973847L0 0.6616669755788906\",\n \"7\": \"M0 0L1 0L0.9246479649697582 0.030539772727272752L0.8850302419354837 0.05075757575757579L0.7922946068548385 0.11079545454545457L0.7419268208165322 0.15213068181818185L0.6907258064516127 0.20202020202020204L0.6400666267641127 0.26122159090909086L0.5913243447580644 0.33049242424242414L0.5458740234374998 0.4105902777777778L0.5050907258064514 0.5022727272727272L0.4703495148689514 0.6062973484848484L0.43257456133442534 0.787133049242424L0.41612903225806447 1\",\n \"8\": \"M0.5143001078924863 0L0.16007477667923162 0.10731570786949331L0.14924628550868277 0.3146018498698755L0.2939585848842112 0.41617921794558677L0.8648302624811545 0.5385163833653317L1 0.7775820770511038L0.8180842915260376 0.9505845566922285L0.41968938540525413 1L0.08062381919779889 0.882831681184498L0 0.6936376947135333L0.17150171673893433 0.5188652309607817L0.6529263782780712 0.4242818653203618L0.8650205888491803 0.29644027376796367L0.8702067371119496 0.09910067291661573L0.5143001078924863 0\",\n \"9\": \"M1 0.25379591792994305L0.9514789771111742 0.11679361536614272L0.8702482473521467 0.05711741614054847L0.7327445265851579 0.015213872471965633L0.525248180711544 0L0.3292056884418538 0.012928195113745608L0.15997632037247655 0.058762870026191856L0.05266940041228321 0.12882439350476L0 0.2562067822770946L0.11316462894512366 0.4121335905917837L0.2403060136479954 0.4603365890068938L0.4097241967586011 0.4745978388276783L0.8642414300184816 0.420815170259988L0.9732054796346318 0.34537434075898393L1 0.25379591792994305M0.9647426784191072 0.35488595400360495L0.4756895081034974 1\",\n A: \"M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365\",\n B: \"M0 1L0 0.0117369978777208L0.30665717153513444 0L0.5874522807082946 0.03451403469442413L0.7766202217193218 0.15033936404895643L0.7471969743588041 0.31967962568332936L0.5246013359741988 0.4102978954282461L0.04378745314885416 0.44918617613783574L0.5112949594180156 0.469692928091109L0.8540266515643348 0.5552749498651879L1 0.6868463175009967L0.9880091196159324 0.8570018204672155L0.922301719975498 0.9321708046604659L0.7584266951758925 0.9932594737131338L0 1\",\n C: \"M1 0.23038928858890784L0.9328355511865092 0.12426412616785204L0.8096380839483327 0.04912601676267708L0.5763225801788256 0L0.4039037709527492 0.015028068281399815L0.2519579390951737 0.06533979308999706L0.10359458463139784 0.18146243506591617L0 0.4862728453971315L0.08129580872733055 0.792689266886982L0.20257034847159672 0.9160822255736587L0.3286572892798542 0.9738230826074175L0.5742878414421707 1L0.7883510303801312 0.9665431511195721L0.946851033994232 0.8689071500976585L1 0.7311049027121912\",\n D: \"M0 1L0.015604366822624637 0.020770988281483303L0.22564758265176144 0L0.3865476147957666 0.0024153386496795644L0.6479126635475078 0.051745644338731314L0.841191887805517 0.15827717679529366L0.9517008345536152 0.30172260586872185L0.9957536578687336 0.4504541551987709L1 0.5624359222498485L0.9798483279164735 0.6584121775234548L0.9386273319285215 0.7395945263504481L0.806292129480815 0.8624239259880274L0.6296239151398265 0.9406169638094516L0.3397492767598845 0.9954164354263132L0 1\",\n E: \"M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1\",\n F: \"M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823\",\n G: \"M0.902666857540557 0.03860785012651126L0.6504261864675637 0L0.3838947267237336 0.015442305268228053L0.21293332876776194 0.07706794377239819L0.07799659974941617 0.1994951236187481L0 0.46380381528937314L0.04159964421546915 0.7502491408002389L0.13176692977834842 0.8535497868383203L0.2709176262273927 0.936767572377719L0.4386472596876406 0.9891638569283179L0.6145513562841309 1L0.7782254421419019 0.9585373611026471L0.9092650433859927 0.8540372997461425L1 0.5556012645283437L0.5583959277303046 0.55491741080559\",\n H: \"M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1\",\n I: \"MNaN 0LNaN 1\",\n J: \"M0.9976457238788704 0L1 0.7396412315872798L0.9773931362096968 0.8322033314977973L0.9345115952458736 0.882296255506608L0.8743862896259549 0.9221331222466961L0.8024024079884948 0.9526431718061675L0.6443996712151668 0.9893997797356828L0.5035848940343224 1L0.3127211130319937 0.9877004749449337L0.17201910858386513 0.9539509911894274L0.10357419806379677 0.9212555066079295L0.053656568662899015 0.8816079295154184L0.020759483663648916 0.8360407488986785L0.003376206348523566 0.7855864537444934L0 0.7312775330396476\",\n K: \"M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777\",\n L: \"M0 0L0 1L1 1\",\n M: \"M0 1L0 0L0.5 0.6512L1 0L1 1\",\n N: \"M0 1L0 0L1 1L0.9803729146221786 0\",\n O: \"M0.4718499217948183 1L0.2896765846490613 0.9606979309189402L0.12315162147934663 0.8411184486080473L0 0.4352399966492615L0.11730398524516283 0.13145645436014852L0.2612197451988078 0.04493357858878059L0.5104071592772554 0L0.7450113425917159 0.05393013710105273L0.882367950645524 0.15242300282020502L1 0.5224527406249126L0.9414597290654386 0.7560662329321755L0.8371289514446183 0.8910800547287298L0.6518259868433511 0.9830452628933628L0.4718499217948183 1\",\n P: \"M0 1L0 0.018871774228013626L0.29609603495819875 0L0.5609840637427541 0.011794858892508529L0.7332142696692472 0.04353904702296349L0.8102258645858864 0.0691965055027166L0.9330504315465442 0.14445061754775845L0.9876391714147118 0.22527816445836535L1 0.3434414070631638L0.9510549958116356 0.41772808046663146L0.8746646891596713 0.45879131862541683L0.7528523813396283 0.49171525113425024L0.5766919939969619 0.5153253033973054L0.33725744877712827 0.5284469008187558L0.025622667325582785 0.529905468802775\",\n Q: \"M0.4618887943546369 0.9755918167206952L0.28356128136544534 0.9372490397450218L0.12055179272160406 0.8205882753548176L0 0.4246165790405623L0.1148276047430244 0.12824784112887844L0.25570518844754375 0.043836831567190586L0.49963205786237674 0L0.7292835601228574 0.0526138004304122L0.8637404608452104 0.14870263423138746L0.9788892040030622 0.5097006183769648L0.9215847647858059 0.7376120297474734L0.8194564929275405 0.869330409436378L0.6380654214095985 0.9590509139448092L0.4618887943546369 0.9755918167206952M0.5824181120212351 0.6861805006946525L1 1\",\n R: \"M0 0.9928375167236815L0 0.02590227442068435L0.3611517274211098 0L0.6146286724700761 0.008660554424468435L0.7675462459194776 0.035269459580494614L0.831839975516866 0.056961676692569484L0.8847592491838954 0.08519560521497332L0.9238557535364527 0.120683646438422L0.9583303225312839 0.21691797435320384L0.955092470586235 0.3022616904894429L0.9198097669001631 0.3640573439322699L0.8564862239866702 0.40639258627024005L0.7691258543593579 0.43335506909190874L0.601775027203482 0.4539166070813109L0.023939064200217658 0.46997623755243123M0.5038084874863982 0.5108023922274467L1 1\",\n S: \"M0.8886929689221953 0.15146982162688968L0.7276173683050475 0.013780286031594946L0.34582323121005076 0L0.1318235250900008 0.09920162734298861L0.0444543935052531 0.2811287071349243L0.08064065829108809 0.3709571405906485L0.21603115127470426 0.4485505768228281L0.7525409135992945 0.5111160926769565L0.9330263665417677 0.5850732219351329L1 0.7129938124702524L0.9117772389978691 0.9130572743138187L0.6423187128058188 1L0.29586019579751677 0.9935291584506244L0.10638454191462794 0.9229845198431584L0 0.7570771288048773\",\n T: \"M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1\",\n U: \"M0 0L0.0023103778751369115 0.5467447428390111L0.01823032542100219 0.6954785891481812L0.05895528135268338 0.8056480226151669L0.13703402031421133 0.8894445726483398L0.23918400876232196 0.9448524533417946L0.3917887458926616 0.9848674531975652L0.584341627875137 1L0.7194816196604602 0.9848501456716763L0.8303268115073934 0.9449411544119768L0.8966613970084885 0.898186315516197L0.9251437568455642 0.867453197565408L0.9687114937020809 0.7890904895145239L0.9890470974808324 0.6852857184065537L1 0.0014769088758762145\",\n V: \"M0 0L0.5348837209302325 1L1 0\",\n W: \"M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845\",\n X: \"M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1\",\n Y: \"M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1\",\n Z: \"M0 0L1 0L0 1L1 1\",\n \".\": \"M 0.49 1 L 0.41 1\",\n}\n\nexport const lineAlphabet: Record<\n string,\n Array<{ x1: number; y1: number; x2: number; y2: number }>\n> = {}\nfor (const letter in svgAlphabet) {\n lineAlphabet[letter] = []\n const segs = svgAlphabet[letter]\n .split(\"M\")\n .slice(1)\n .map((seg) =>\n seg.split(\"L\").map((pr) => pr.trim().split(\" \").map(parseFloat))\n )\n for (const seg of segs) {\n for (let i = 0; i < seg.length - 1; i++) {\n // We also flip the y axis to make it cartesian here\n lineAlphabet[letter].push({\n x1: seg[i][0],\n y1: 1 - seg[i][1],\n x2: seg[i + 1][0],\n y2: 1 - seg[i + 1][1],\n })\n }\n }\n}\n","import { lineAlphabet } from \"../assets/alphabet\"\nimport { Line, Text } from \"./types\"\n\nexport const convertTextToLines = (text: Text): Line[] => {\n const strokeWidth = text.size / 8\n const letterWidth = text.size * 0.6\n const letterSpace = text.size * 0.2\n\n const lines: Line[] = []\n for (let letterIndex = 0; letterIndex < text.text.length; letterIndex++) {\n const letter = text.text[letterIndex]\n const letterLines = lineAlphabet[letter.toUpperCase()]\n if (!letterLines) continue\n for (const { x1, y1, x2, y2 } of letterLines) {\n lines.push({\n pcb_drawing_type: \"line\",\n x1:\n text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x1,\n y1: text.y + text.size * y1,\n x2:\n text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x2,\n y2: text.y + text.size * y2,\n width: strokeWidth,\n layer: text.layer,\n unit: text.unit,\n })\n }\n }\n\n return lines\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,cAAc;AAAA,EACzB,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,KAAK;AACP;AAEO,IAAM,eAGT,CAAC;AACL,WAAW,UAAU,aAAa;AAChC,eAAa,UAAU,CAAC;AACxB,QAAM,OAAO,YAAY,QACtB,MAAM,GAAG,EACT,MAAM,CAAC,EACP;AAAA,IAAI,CAAC,QACJ,IAAI,MAAM,GAAG,EAAE,IAAI,CAAC,OAAO,GAAG,KAAK,EAAE,MAAM,GAAG,EAAE,IAAI,UAAU,CAAC;AAAA,EACjE;AACF,aAAW,OAAO,MAAM;AACtB,aAAS,IAAI,GAAG,IAAI,IAAI,SAAS,GAAG,KAAK;AAEvC,mBAAa,QAAQ,KAAK;AAAA,QACxB,IAAI,IAAI,GAAG;AAAA,QACX,IAAI,IAAI,IAAI,GAAG;AAAA,QACf,IAAI,IAAI,IAAI,GAAG;AAAA,QACf,IAAI,IAAI,IAAI,IAAI,GAAG;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;AClEO,IAAM,qBAAqB,CAAC,SAAuB;AACxD,QAAM,cAAc,KAAK,OAAO;AAChC,QAAM,cAAc,KAAK,OAAO;AAChC,QAAM,cAAc,KAAK,OAAO;AAEhC,QAAM,QAAgB,CAAC;AACvB,WAAS,cAAc,GAAG,cAAc,KAAK,KAAK,QAAQ,eAAe;AACvE,UAAM,SAAS,KAAK,KAAK;AACzB,UAAM,cAAc,aAAa,OAAO,YAAY;AACpD,QAAI,CAAC;AAAa;AAClB,eAAW,EAAE,IAAI,IAAI,IAAI,GAAG,KAAK,aAAa;AAC5C,YAAM,KAAK;AAAA,QACT,kBAAkB;AAAA,QAClB,IACE,KAAK,KAAK,cAAc,eAAe,cAAc,cAAc;AAAA,QACrE,IAAI,KAAK,IAAI,KAAK,OAAO;AAAA,QACzB,IACE,KAAK,KAAK,cAAc,eAAe,cAAc,cAAc;AAAA,QACrE,IAAI,KAAK,IAAI,KAAK,OAAO;AAAA,QACzB,OAAO;AAAA,QACP,OAAO,KAAK;AAAA,QACZ,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;;;AF1BO,IAAM,WAAW,CAAC,QAAgB,SAAe;AACtD,SAAO,MAAM;AAAA,IACX,MAAM,KAAK;AAAA,IACX,OAAO,KAAK,YAAY,WAAW;AAAA,IACnC,OAAO,KAAK,MAAM;AAAA,EACpB,CAAC;AACD,SAAO,OAAO,KAAK,IAAI,KAAK,EAAE;AAC9B,SAAO,OAAO,KAAK,IAAI,KAAK,EAAE;AAChC;AAEO,IAAM,WAAW,CAAC,QAAgB,SAAe;AACtD,SAAO,MAAM;AAAA,IACX,UAAU,KAAK;AAAA,IACf,OAAO,KAAK,MAAM;AAAA,EACpB,CAAC;AAED,MAAI,KAAK,SAAS,KAAK,UAAU,YAAY;AAC3C,YAAQ,KAAK,wBAAwB,KAAK,KAAK;AAAA,EACjD;AAKA,QAAM,QAAQ,mBAAmB,IAAI;AACrC,aAAW,QAAQ,OAAO;AACxB,aAAS,QAAQ,IAAI;AAAA,EACvB;AACF;AAEO,IAAM,WAAW,CAAC,QAAgB,SAAe;AACtD,SAAO,MAAM;AAAA,IACX,OAAO,KAAK,MAAM;AAAA,EACpB,CAAC;AACD,MAAI,KAAK,SAAS,KAAK,UAAU,UAAU;AACzC,YAAQ,KAAK,wBAAwB,KAAK,KAAK;AAAA,EACjD;AACA,SAAO,KAAK,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAC5C;AAEO,IAAM,aAAa,CAAC,QAAgB,WAAmB;AAC5D,SAAO,MAAM;AAAA,IACX,OAAO,OAAO,MAAM;AAAA,EACtB,CAAC;AACD,SAAO,OAAO,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAC5C;AAEO,IAAM,gBAAgB,CAAC,QAAgB,cAAyB;AACrE,UAAQ,UAAU,kBAAkB;AAAA,IAClC,KAAK;AACH,aAAO,SAAS,QAAQ,SAAS;AAAA,IACnC,KAAK;AACH,aAAO,SAAS,QAAQ,SAAS;AAAA,IACnC,KAAK;AACH,aAAO,SAAS,QAAQ,SAAS;AAAA,IACnC,KAAK;AACH,aAAO,WAAW,QAAQ,SAAS;AAAA,EACvC;AACA,QAAM,IAAI;AAAA,IACR,2BAA4B,UAAkB;AAAA,EAChD;AACF;AAEO,IAAM,iBAAiB,CAAC,QAAgB,eAA4B;AACzE,aAAW,QAAQ,CAAC,cAAc,cAAc,QAAQ,SAAS,CAAC;AACpE;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
declare type AlignString = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
2
|
+
interface LayerRef {
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
interface PCBDrawingObject {
|
|
6
|
+
layer: LayerRef;
|
|
7
|
+
unit?: string;
|
|
8
|
+
}
|
|
9
|
+
interface Line extends PCBDrawingObject {
|
|
10
|
+
pcb_drawing_type: "line";
|
|
11
|
+
x1: number;
|
|
12
|
+
y1: number;
|
|
13
|
+
x2: number;
|
|
14
|
+
y2: number;
|
|
15
|
+
squareCap?: boolean;
|
|
16
|
+
width: number;
|
|
17
|
+
}
|
|
18
|
+
interface Text extends PCBDrawingObject {
|
|
19
|
+
pcb_drawing_type: "text";
|
|
20
|
+
text: string;
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
size: number;
|
|
24
|
+
align?: AlignString;
|
|
25
|
+
}
|
|
26
|
+
interface Rect extends PCBDrawingObject {
|
|
27
|
+
pcb_drawing_type: "rect";
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
w: number;
|
|
31
|
+
h: number;
|
|
32
|
+
roundness?: number;
|
|
33
|
+
align?: AlignString;
|
|
34
|
+
}
|
|
35
|
+
interface Circle extends PCBDrawingObject {
|
|
36
|
+
pcb_drawing_type: "circle";
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
r: number;
|
|
40
|
+
}
|
|
41
|
+
declare type Primitive = Line | Text | Rect | Circle;
|
|
42
|
+
declare type GridConfig = {
|
|
43
|
+
spacing: number;
|
|
44
|
+
view_window: {
|
|
45
|
+
left: number;
|
|
46
|
+
right: number;
|
|
47
|
+
top: number;
|
|
48
|
+
bottom: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { AlignString, Circle, GridConfig, LayerRef, Line, PCBDrawingObject, Primitive, Rect, Text };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/lib/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/types.ts"],"sourcesContent":["export type AlignString =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"center-left\"\n | \"center\"\n | \"center-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\"\n\nexport interface LayerRef {\n name: string\n}\n\nexport interface PCBDrawingObject {\n layer: LayerRef\n unit?: string\n}\n\nexport interface Line extends PCBDrawingObject {\n pcb_drawing_type: \"line\"\n x1: number\n y1: number\n x2: number\n y2: number\n squareCap?: boolean\n width: number\n}\nexport interface Text extends PCBDrawingObject {\n pcb_drawing_type: \"text\"\n text: string\n x: number\n y: number\n size: number\n align?: AlignString\n}\nexport interface Rect extends PCBDrawingObject {\n pcb_drawing_type: \"rect\"\n x: number\n y: number\n w: number\n h: number\n roundness?: number\n align?: AlignString\n}\nexport interface Circle extends PCBDrawingObject {\n pcb_drawing_type: \"circle\"\n x: number\n y: number\n r: number\n}\n\nexport type Primitive = Line | Text | Rect | Circle\n\nexport type GridConfig = {\n spacing: number\n view_window: {\n left: number\n right: number\n top: number\n bottom: number\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/lib/util/scale-only.ts
|
|
20
|
+
var scale_only_exports = {};
|
|
21
|
+
__export(scale_only_exports, {
|
|
22
|
+
scaleOnly: () => scaleOnly
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(scale_only_exports);
|
|
25
|
+
var scaleOnly = (mat, value = 1) => {
|
|
26
|
+
if (Math.abs(mat.a) !== Math.abs(mat.d))
|
|
27
|
+
throw new Error("Cannot scale non-uniformly");
|
|
28
|
+
return value * Math.abs(mat.a);
|
|
29
|
+
};
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
scaleOnly
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=scale-only.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/util/scale-only.ts"],"sourcesContent":["import { Matrix } from \"transformation-matrix\"\n\nexport const scaleOnly = (mat: Matrix, value: number = 1) => {\n if (Math.abs(mat.a) !== Math.abs(mat.d))\n throw new Error(\"Cannot scale non-uniformly\")\n return value * Math.abs(mat.a)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,YAAY,CAAC,KAAa,QAAgB,MAAM;AAC3D,MAAI,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,CAAC;AACpC,UAAM,IAAI,MAAM,4BAA4B;AAC9C,SAAO,QAAQ,KAAK,IAAI,IAAI,CAAC;AAC/B;","names":[]}
|