@tscircuit/pcb-viewer 1.0.3 → 1.1.0
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/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @tscircuit/pcb-viewer
|
|
2
|
+
|
|
3
|
+
Render PCBs w/ React
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @tscircuit/pcb-viewer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import React, { useEffect, useRef } from "react"
|
|
13
|
+
import { PCBViewer } from "@tscircuit/pcb-viewer"
|
|
14
|
+
|
|
15
|
+
export default () => {
|
|
16
|
+
return (
|
|
17
|
+
<div style={{ backgroundColor: "black" }}>
|
|
18
|
+
<PCBViewer>
|
|
19
|
+
<resistor footprint="0805" resistance="10k" />
|
|
20
|
+
</PCBViewer>
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
```
|
|
@@ -0,0 +1,855 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
|
|
28
|
+
// node_modules/use-mouse-matrix-transform/dist/index.js
|
|
29
|
+
var require_dist = __commonJS({
|
|
30
|
+
"node_modules/use-mouse-matrix-transform/dist/index.js"(exports, module2) {
|
|
31
|
+
"use strict";
|
|
32
|
+
var __defProp2 = Object.defineProperty;
|
|
33
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
34
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
35
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
36
|
+
var __export2 = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
41
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
+
for (let key of __getOwnPropNames2(from))
|
|
43
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
44
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
49
|
+
var src_exports = {};
|
|
50
|
+
__export2(src_exports, {
|
|
51
|
+
default: () => src_default,
|
|
52
|
+
useMouseMatrixTransform: () => useMouseMatrixTransform2
|
|
53
|
+
});
|
|
54
|
+
module2.exports = __toCommonJS2(src_exports);
|
|
55
|
+
var import_transformation_matrix4 = require("transformation-matrix");
|
|
56
|
+
var import_react5 = require("react");
|
|
57
|
+
var useMouseMatrixTransform2 = (props = {}) => {
|
|
58
|
+
const extRef = (0, import_react5.useRef)(null);
|
|
59
|
+
const canvasElm = props.canvasElm ?? extRef.current;
|
|
60
|
+
const [internalTransform, setInternalTransform] = (0, import_react5.useState)(
|
|
61
|
+
props.initialTransform ?? (0, import_transformation_matrix4.identity)()
|
|
62
|
+
);
|
|
63
|
+
const setTransform = (newTransform) => {
|
|
64
|
+
if (props.onSetTransform) {
|
|
65
|
+
props.onSetTransform(newTransform);
|
|
66
|
+
} else {
|
|
67
|
+
setInternalTransform(newTransform);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const transform = props.transform ?? internalTransform;
|
|
71
|
+
(0, import_react5.useEffect)(() => {
|
|
72
|
+
const canvasElm2 = props.canvasElm ?? extRef.current;
|
|
73
|
+
if (!canvasElm2)
|
|
74
|
+
return;
|
|
75
|
+
let init_tf = props.transform ?? internalTransform;
|
|
76
|
+
let m0 = { x: 0, y: 0 }, m1 = { x: 0, y: 0 }, md = false, mlastrel = { x: 0, y: 0 };
|
|
77
|
+
const getMousePos = (e) => {
|
|
78
|
+
const rect = canvasElm2.getBoundingClientRect();
|
|
79
|
+
return {
|
|
80
|
+
x: e.clientX - rect.left,
|
|
81
|
+
y: e.clientY - rect.top
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
function handleMouseDown(e) {
|
|
85
|
+
m0 = getMousePos(e);
|
|
86
|
+
md = true;
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
}
|
|
89
|
+
function handleMouseUp(e) {
|
|
90
|
+
m1 = getMousePos(e);
|
|
91
|
+
const new_tf = (0, import_transformation_matrix4.compose)((0, import_transformation_matrix4.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
|
|
92
|
+
setTransform(new_tf);
|
|
93
|
+
init_tf = new_tf;
|
|
94
|
+
md = false;
|
|
95
|
+
}
|
|
96
|
+
function handleMouseMove(e) {
|
|
97
|
+
mlastrel = getMousePos(e);
|
|
98
|
+
if (!md)
|
|
99
|
+
return;
|
|
100
|
+
m1 = getMousePos(e);
|
|
101
|
+
setTransform((0, import_transformation_matrix4.compose)((0, import_transformation_matrix4.translate)(m1.x - m0.x, m1.y - m0.y), init_tf));
|
|
102
|
+
}
|
|
103
|
+
function handleMouseWheel(e) {
|
|
104
|
+
const center = getMousePos(e);
|
|
105
|
+
const new_tf = (0, import_transformation_matrix4.compose)(
|
|
106
|
+
(0, import_transformation_matrix4.translate)(center.x, center.y),
|
|
107
|
+
(0, import_transformation_matrix4.scale)(1 - e.deltaY / 1e3, 1 - e.deltaY / 1e3),
|
|
108
|
+
(0, import_transformation_matrix4.translate)(-center.x, -center.y),
|
|
109
|
+
init_tf
|
|
110
|
+
);
|
|
111
|
+
setTransform(new_tf);
|
|
112
|
+
init_tf = new_tf;
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
}
|
|
115
|
+
function handleMouseOut(e) {
|
|
116
|
+
if (!md)
|
|
117
|
+
return;
|
|
118
|
+
md = false;
|
|
119
|
+
m1 = getMousePos(e);
|
|
120
|
+
const new_tf = (0, import_transformation_matrix4.compose)((0, import_transformation_matrix4.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
|
|
121
|
+
setTransform(new_tf);
|
|
122
|
+
init_tf = new_tf;
|
|
123
|
+
}
|
|
124
|
+
canvasElm2.addEventListener("mousedown", handleMouseDown);
|
|
125
|
+
canvasElm2.addEventListener("mouseup", handleMouseUp);
|
|
126
|
+
canvasElm2.addEventListener("mousemove", handleMouseMove);
|
|
127
|
+
canvasElm2.addEventListener("mouseout", handleMouseOut);
|
|
128
|
+
canvasElm2.addEventListener("wheel", handleMouseWheel);
|
|
129
|
+
return () => {
|
|
130
|
+
canvasElm2.removeEventListener("mousedown", handleMouseDown);
|
|
131
|
+
canvasElm2.removeEventListener("mouseup", handleMouseUp);
|
|
132
|
+
canvasElm2.removeEventListener("mousemove", handleMouseMove);
|
|
133
|
+
canvasElm2.removeEventListener("mouseout", handleMouseOut);
|
|
134
|
+
canvasElm2.removeEventListener("wheel", handleMouseWheel);
|
|
135
|
+
};
|
|
136
|
+
}, [canvasElm]);
|
|
137
|
+
const applyTransformToPoint = (0, import_react5.useCallback)(
|
|
138
|
+
(obj) => (0, import_transformation_matrix4.applyToPoint)(transform, obj),
|
|
139
|
+
[transform]
|
|
140
|
+
);
|
|
141
|
+
return {
|
|
142
|
+
ref: extRef,
|
|
143
|
+
transform,
|
|
144
|
+
applyTransformToPoint
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
var src_default = useMouseMatrixTransform2;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// src/pages/canvas-elements-renderer.tsx
|
|
152
|
+
var canvas_elements_renderer_exports = {};
|
|
153
|
+
__export(canvas_elements_renderer_exports, {
|
|
154
|
+
default: () => canvas_elements_renderer_default
|
|
155
|
+
});
|
|
156
|
+
module.exports = __toCommonJS(canvas_elements_renderer_exports);
|
|
157
|
+
var import_react4 = __toESM(require("react"));
|
|
158
|
+
|
|
159
|
+
// src/components/CanvasElementsRenderer.tsx
|
|
160
|
+
var import_react2 = __toESM(require("react"));
|
|
161
|
+
|
|
162
|
+
// src/lib/draw-grid.ts
|
|
163
|
+
var import_transformation_matrix = require("transformation-matrix");
|
|
164
|
+
|
|
165
|
+
// src/lib/util/scale-only.ts
|
|
166
|
+
var scaleOnly = (mat, value = 1) => {
|
|
167
|
+
if (Math.abs(mat.a) !== Math.abs(mat.d))
|
|
168
|
+
throw new Error("Cannot scale non-uniformly");
|
|
169
|
+
return value * Math.abs(mat.a);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/lib/draw-grid.ts
|
|
173
|
+
var transformBounds = (transform, bounds) => {
|
|
174
|
+
const { left, right, top, bottom } = bounds;
|
|
175
|
+
const [left$, top$] = (0, import_transformation_matrix.applyToPoint)(transform, [left, top]);
|
|
176
|
+
const [right$, bottom$] = (0, import_transformation_matrix.applyToPoint)(transform, [right, bottom]);
|
|
177
|
+
return {
|
|
178
|
+
left: Math.min(left$, right$),
|
|
179
|
+
right: Math.max(left$, right$),
|
|
180
|
+
top: Math.max(bottom$, top$),
|
|
181
|
+
bottom: Math.min(bottom$, top$)
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
var drawGrid = (drawer, grid_config) => {
|
|
185
|
+
const { spacing, view_window } = grid_config;
|
|
186
|
+
const transformed_window = transformBounds(
|
|
187
|
+
(0, import_transformation_matrix.inverse)(drawer.transform),
|
|
188
|
+
view_window
|
|
189
|
+
);
|
|
190
|
+
console.log({ view_window, transformed_window });
|
|
191
|
+
const { left, right, top, bottom } = transformed_window;
|
|
192
|
+
const startx = Math.floor(left / spacing) * spacing;
|
|
193
|
+
const starty = Math.floor(bottom / spacing) * spacing;
|
|
194
|
+
const px = scaleOnly((0, import_transformation_matrix.inverse)(drawer.transform));
|
|
195
|
+
drawer.equip({
|
|
196
|
+
color: "green",
|
|
197
|
+
mode: "add",
|
|
198
|
+
shape: "circle",
|
|
199
|
+
size: px
|
|
200
|
+
});
|
|
201
|
+
for (let x = startx; x < right; x += spacing) {
|
|
202
|
+
drawer.moveTo(x, bottom);
|
|
203
|
+
drawer.lineTo(x, top);
|
|
204
|
+
}
|
|
205
|
+
for (let y = starty; y < top; y += spacing) {
|
|
206
|
+
drawer.moveTo(left, y);
|
|
207
|
+
drawer.lineTo(right, y);
|
|
208
|
+
}
|
|
209
|
+
for (let x = startx; x < right; x += spacing) {
|
|
210
|
+
for (let y = starty; y < top; y += spacing) {
|
|
211
|
+
drawer.debugText(`${x}, ${y}`, x + px * 3, y - px * 3);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// src/components/CanvasPrimitiveRenderer.tsx
|
|
217
|
+
var import_react = __toESM(require("react"));
|
|
218
|
+
|
|
219
|
+
// src/assets/alphabet.ts
|
|
220
|
+
var svgAlphabet = {
|
|
221
|
+
"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",
|
|
222
|
+
"1": "M 0.198 0.272 L 0.537 0 L 0.54 1",
|
|
223
|
+
"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",
|
|
224
|
+
"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",
|
|
225
|
+
"4": "M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1",
|
|
226
|
+
"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",
|
|
227
|
+
"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",
|
|
228
|
+
"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",
|
|
229
|
+
"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",
|
|
230
|
+
"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",
|
|
231
|
+
A: "M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365",
|
|
232
|
+
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",
|
|
233
|
+
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",
|
|
234
|
+
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",
|
|
235
|
+
E: "M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1",
|
|
236
|
+
F: "M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823",
|
|
237
|
+
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",
|
|
238
|
+
H: "M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1",
|
|
239
|
+
I: "MNaN 0LNaN 1",
|
|
240
|
+
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",
|
|
241
|
+
K: "M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777",
|
|
242
|
+
L: "M0 0L0 1L1 1",
|
|
243
|
+
M: "M0 1L0 0L0.5 0.6512L1 0L1 1",
|
|
244
|
+
N: "M0 1L0 0L1 1L0.9803729146221786 0",
|
|
245
|
+
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",
|
|
246
|
+
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",
|
|
247
|
+
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",
|
|
248
|
+
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",
|
|
249
|
+
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",
|
|
250
|
+
T: "M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1",
|
|
251
|
+
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",
|
|
252
|
+
V: "M0 0L0.5348837209302325 1L1 0",
|
|
253
|
+
W: "M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845",
|
|
254
|
+
X: "M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1",
|
|
255
|
+
Y: "M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1",
|
|
256
|
+
Z: "M0 0L1 0L0 1L1 1",
|
|
257
|
+
".": "M 0.49 1 L 0.41 1"
|
|
258
|
+
};
|
|
259
|
+
var lineAlphabet = {};
|
|
260
|
+
for (const letter in svgAlphabet) {
|
|
261
|
+
lineAlphabet[letter] = [];
|
|
262
|
+
const segs = svgAlphabet[letter].split("M").slice(1).map(
|
|
263
|
+
(seg) => seg.split("L").map((pr) => pr.trim().split(" ").map(parseFloat))
|
|
264
|
+
);
|
|
265
|
+
for (const seg of segs) {
|
|
266
|
+
for (let i = 0; i < seg.length - 1; i++) {
|
|
267
|
+
lineAlphabet[letter].push({
|
|
268
|
+
x1: seg[i][0],
|
|
269
|
+
y1: 1 - seg[i][1],
|
|
270
|
+
x2: seg[i + 1][0],
|
|
271
|
+
y2: 1 - seg[i + 1][1]
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/lib/convert-text-to-lines.ts
|
|
278
|
+
var convertTextToLines = (text) => {
|
|
279
|
+
const strokeWidth = text.size / 8;
|
|
280
|
+
const letterWidth = text.size * 0.6;
|
|
281
|
+
const letterSpace = text.size * 0.2;
|
|
282
|
+
const lines = [];
|
|
283
|
+
for (let letterIndex = 0; letterIndex < text.text.length; letterIndex++) {
|
|
284
|
+
const letter = text.text[letterIndex];
|
|
285
|
+
const letterLines = lineAlphabet[letter.toUpperCase()];
|
|
286
|
+
if (!letterLines)
|
|
287
|
+
continue;
|
|
288
|
+
for (const { x1, y1, x2, y2 } of letterLines) {
|
|
289
|
+
lines.push({
|
|
290
|
+
pcb_drawing_type: "line",
|
|
291
|
+
x1: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x1,
|
|
292
|
+
y1: text.y + text.size * y1,
|
|
293
|
+
x2: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x2,
|
|
294
|
+
y2: text.y + text.size * y2,
|
|
295
|
+
width: strokeWidth,
|
|
296
|
+
layer: text.layer,
|
|
297
|
+
unit: text.unit
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return lines;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// src/lib/draw-primitives.ts
|
|
305
|
+
var drawLine = (drawer, line) => {
|
|
306
|
+
drawer.equip({
|
|
307
|
+
size: line.width,
|
|
308
|
+
shape: line.squareCap ? "square" : "circle",
|
|
309
|
+
color: line.layer.name
|
|
310
|
+
});
|
|
311
|
+
drawer.moveTo(line.x1, line.y1);
|
|
312
|
+
drawer.lineTo(line.x2, line.y2);
|
|
313
|
+
};
|
|
314
|
+
var drawText = (drawer, text) => {
|
|
315
|
+
drawer.equip({
|
|
316
|
+
fontSize: text.size,
|
|
317
|
+
color: text.layer.name
|
|
318
|
+
});
|
|
319
|
+
if (text.align && text.align !== "top-left") {
|
|
320
|
+
console.warn("Unhandled text align", text.align);
|
|
321
|
+
}
|
|
322
|
+
const lines = convertTextToLines(text);
|
|
323
|
+
for (const line of lines) {
|
|
324
|
+
drawLine(drawer, line);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
var drawRect = (drawer, rect) => {
|
|
328
|
+
drawer.equip({
|
|
329
|
+
color: rect.layer.name
|
|
330
|
+
});
|
|
331
|
+
if (rect.align && rect.align !== "center") {
|
|
332
|
+
console.warn("Unhandled rect align", rect.align);
|
|
333
|
+
}
|
|
334
|
+
drawer.rect(rect.x, rect.y, rect.w, rect.h);
|
|
335
|
+
};
|
|
336
|
+
var drawCircle = (drawer, circle) => {
|
|
337
|
+
drawer.equip({
|
|
338
|
+
color: circle.layer.name
|
|
339
|
+
});
|
|
340
|
+
drawer.circle(circle.x, circle.y, circle.r);
|
|
341
|
+
};
|
|
342
|
+
var drawPrimitive = (drawer, primitive) => {
|
|
343
|
+
switch (primitive.pcb_drawing_type) {
|
|
344
|
+
case "line":
|
|
345
|
+
return drawLine(drawer, primitive);
|
|
346
|
+
case "text":
|
|
347
|
+
return drawText(drawer, primitive);
|
|
348
|
+
case "rect":
|
|
349
|
+
return drawRect(drawer, primitive);
|
|
350
|
+
case "circle":
|
|
351
|
+
return drawCircle(drawer, primitive);
|
|
352
|
+
}
|
|
353
|
+
throw new Error(
|
|
354
|
+
`Unknown primitive type: ${primitive.pcb_drawing_type}`
|
|
355
|
+
);
|
|
356
|
+
};
|
|
357
|
+
var drawPrimitives = (drawer, primitives) => {
|
|
358
|
+
primitives.forEach((primitive) => drawPrimitive(drawer, primitive));
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// src/lib/Drawer.ts
|
|
362
|
+
var import_transformation_matrix2 = require("transformation-matrix");
|
|
363
|
+
|
|
364
|
+
// src/lib/colors.ts
|
|
365
|
+
var colors_default = {
|
|
366
|
+
"3d_viewer": {
|
|
367
|
+
background_bottom: "rgb(102, 102, 128)",
|
|
368
|
+
background_top: "rgb(204, 204, 230)",
|
|
369
|
+
board: "rgb(51, 43, 23)",
|
|
370
|
+
copper: "rgb(179, 156, 0)",
|
|
371
|
+
silkscreen_bottom: "rgb(230, 230, 230)",
|
|
372
|
+
silkscreen_top: "rgb(230, 230, 230)",
|
|
373
|
+
soldermask: "rgb(20, 51, 36)",
|
|
374
|
+
solderpaste: "rgb(128, 128, 128)"
|
|
375
|
+
},
|
|
376
|
+
board: {
|
|
377
|
+
anchor: "rgb(255, 38, 226)",
|
|
378
|
+
aux_items: "rgb(255, 255, 255)",
|
|
379
|
+
b_adhes: "rgb(0, 0, 132)",
|
|
380
|
+
b_crtyd: "rgb(255, 38, 226)",
|
|
381
|
+
b_fab: "rgb(88, 93, 132)",
|
|
382
|
+
b_mask: "rgba(2, 255, 238, 0.400)",
|
|
383
|
+
b_paste: "rgb(0, 194, 194)",
|
|
384
|
+
b_silks: "rgb(232, 178, 167)",
|
|
385
|
+
background: "rgb(0, 16, 35)",
|
|
386
|
+
cmts_user: "rgb(89, 148, 220)",
|
|
387
|
+
copper: {
|
|
388
|
+
b: "rgb(77, 127, 196)",
|
|
389
|
+
f: "rgb(200, 52, 52)",
|
|
390
|
+
in1: "rgb(127, 200, 127)",
|
|
391
|
+
in10: "rgb(237, 124, 51)",
|
|
392
|
+
in11: "rgb(91, 195, 235)",
|
|
393
|
+
in12: "rgb(247, 111, 142)",
|
|
394
|
+
in13: "rgb(167, 165, 198)",
|
|
395
|
+
in14: "rgb(40, 204, 217)",
|
|
396
|
+
in15: "rgb(232, 178, 167)",
|
|
397
|
+
in16: "rgb(242, 237, 161)",
|
|
398
|
+
in17: "rgb(237, 124, 51)",
|
|
399
|
+
in18: "rgb(91, 195, 235)",
|
|
400
|
+
in19: "rgb(247, 111, 142)",
|
|
401
|
+
in2: "rgb(206, 125, 44)",
|
|
402
|
+
in20: "rgb(167, 165, 198)",
|
|
403
|
+
in21: "rgb(40, 204, 217)",
|
|
404
|
+
in22: "rgb(232, 178, 167)",
|
|
405
|
+
in23: "rgb(242, 237, 161)",
|
|
406
|
+
in24: "rgb(237, 124, 51)",
|
|
407
|
+
in25: "rgb(91, 195, 235)",
|
|
408
|
+
in26: "rgb(247, 111, 142)",
|
|
409
|
+
in27: "rgb(167, 165, 198)",
|
|
410
|
+
in28: "rgb(40, 204, 217)",
|
|
411
|
+
in29: "rgb(232, 178, 167)",
|
|
412
|
+
in3: "rgb(79, 203, 203)",
|
|
413
|
+
in30: "rgb(242, 237, 161)",
|
|
414
|
+
in4: "rgb(219, 98, 139)",
|
|
415
|
+
in5: "rgb(167, 165, 198)",
|
|
416
|
+
in6: "rgb(40, 204, 217)",
|
|
417
|
+
in7: "rgb(232, 178, 167)",
|
|
418
|
+
in8: "rgb(242, 237, 161)",
|
|
419
|
+
in9: "rgb(141, 203, 129)"
|
|
420
|
+
},
|
|
421
|
+
cursor: "rgb(255, 255, 255)",
|
|
422
|
+
drc: "rgb(194, 194, 194)",
|
|
423
|
+
drc_error: "rgba(215, 91, 107, 0.800)",
|
|
424
|
+
drc_exclusion: "rgb(255, 255, 255)",
|
|
425
|
+
drc_warning: "rgba(255, 208, 66, 0.902)",
|
|
426
|
+
dwgs_user: "rgb(194, 194, 194)",
|
|
427
|
+
eco1_user: "rgb(180, 219, 210)",
|
|
428
|
+
eco2_user: "rgb(216, 200, 82)",
|
|
429
|
+
edge_cuts: "rgb(208, 210, 205)",
|
|
430
|
+
f_adhes: "rgb(132, 0, 132)",
|
|
431
|
+
f_crtyd: "rgb(255, 0, 245)",
|
|
432
|
+
f_fab: "rgb(175, 175, 175)",
|
|
433
|
+
f_mask: "rgba(216, 100, 255, 0.400)",
|
|
434
|
+
f_paste: "rgba(180, 160, 154, 0.902)",
|
|
435
|
+
f_silks: "rgb(242, 237, 161)",
|
|
436
|
+
footprint_text_back: "rgb(0, 0, 132)",
|
|
437
|
+
footprint_text_front: "rgb(194, 194, 194)",
|
|
438
|
+
footprint_text_invisible: "rgb(132, 132, 132)",
|
|
439
|
+
grid: "rgb(132, 132, 132)",
|
|
440
|
+
grid_axes: "rgb(194, 194, 194)",
|
|
441
|
+
margin: "rgb(255, 38, 226)",
|
|
442
|
+
microvia: "rgb(0, 132, 132)",
|
|
443
|
+
no_connect: "rgb(0, 0, 132)",
|
|
444
|
+
pad_back: "rgb(77, 127, 196)",
|
|
445
|
+
pad_front: "rgb(200, 52, 52)",
|
|
446
|
+
pad_plated_hole: "rgb(194, 194, 0)",
|
|
447
|
+
pad_through_hole: "rgb(227, 183, 46)",
|
|
448
|
+
plated_hole: "rgb(26, 196, 210)",
|
|
449
|
+
ratsnest: "rgba(245, 255, 213, 0.702)",
|
|
450
|
+
select_overlay: "rgb(4, 255, 67)",
|
|
451
|
+
through_via: "rgb(236, 236, 236)",
|
|
452
|
+
user_1: "rgb(194, 194, 194)",
|
|
453
|
+
user_2: "rgb(89, 148, 220)",
|
|
454
|
+
user_3: "rgb(180, 219, 210)",
|
|
455
|
+
user_4: "rgb(216, 200, 82)",
|
|
456
|
+
user_5: "rgb(194, 194, 194)",
|
|
457
|
+
user_6: "rgb(89, 148, 220)",
|
|
458
|
+
user_7: "rgb(180, 219, 210)",
|
|
459
|
+
user_8: "rgb(216, 200, 82)",
|
|
460
|
+
user_9: "rgb(232, 178, 167)",
|
|
461
|
+
via_blind_buried: "rgb(187, 151, 38)",
|
|
462
|
+
via_hole: "rgb(227, 183, 46)",
|
|
463
|
+
via_micro: "rgb(0, 132, 132)",
|
|
464
|
+
via_through: "rgb(236, 236, 236)",
|
|
465
|
+
worksheet: "rgb(200, 114, 171)"
|
|
466
|
+
},
|
|
467
|
+
gerbview: {
|
|
468
|
+
axes: "rgb(0, 0, 132)",
|
|
469
|
+
background: "rgb(0, 0, 0)",
|
|
470
|
+
dcodes: "rgb(255, 255, 255)",
|
|
471
|
+
grid: "rgb(132, 132, 132)",
|
|
472
|
+
layers: [
|
|
473
|
+
"rgb(132, 0, 0)",
|
|
474
|
+
"rgb(194, 194, 0)",
|
|
475
|
+
"rgb(194, 0, 194)",
|
|
476
|
+
"rgb(194, 0, 0)",
|
|
477
|
+
"rgb(0, 132, 132)",
|
|
478
|
+
"rgb(0, 132, 0)",
|
|
479
|
+
"rgb(0, 0, 132)",
|
|
480
|
+
"rgb(132, 132, 132)",
|
|
481
|
+
"rgb(132, 0, 132)",
|
|
482
|
+
"rgb(194, 194, 194)",
|
|
483
|
+
"rgb(132, 0, 132)",
|
|
484
|
+
"rgb(132, 0, 0)",
|
|
485
|
+
"rgb(132, 132, 0)",
|
|
486
|
+
"rgb(194, 194, 194)",
|
|
487
|
+
"rgb(0, 0, 132)",
|
|
488
|
+
"rgb(0, 132, 0)",
|
|
489
|
+
"rgb(132, 0, 0)",
|
|
490
|
+
"rgb(194, 194, 0)",
|
|
491
|
+
"rgb(194, 0, 194)",
|
|
492
|
+
"rgb(194, 0, 0)",
|
|
493
|
+
"rgb(0, 132, 132)",
|
|
494
|
+
"rgb(0, 132, 0)",
|
|
495
|
+
"rgb(0, 0, 132)",
|
|
496
|
+
"rgb(132, 132, 132)",
|
|
497
|
+
"rgb(132, 0, 132)",
|
|
498
|
+
"rgb(194, 194, 194)",
|
|
499
|
+
"rgb(132, 0, 132)",
|
|
500
|
+
"rgb(132, 0, 0)",
|
|
501
|
+
"rgb(132, 132, 0)",
|
|
502
|
+
"rgb(194, 194, 194)",
|
|
503
|
+
"rgb(0, 0, 132)",
|
|
504
|
+
"rgb(0, 132, 0)",
|
|
505
|
+
"rgb(132, 0, 0)",
|
|
506
|
+
"rgb(194, 194, 0)",
|
|
507
|
+
"rgb(194, 0, 194)",
|
|
508
|
+
"rgb(194, 0, 0)",
|
|
509
|
+
"rgb(0, 132, 132)",
|
|
510
|
+
"rgb(0, 132, 0)",
|
|
511
|
+
"rgb(0, 0, 132)",
|
|
512
|
+
"rgb(132, 132, 132)",
|
|
513
|
+
"rgb(132, 0, 132)",
|
|
514
|
+
"rgb(194, 194, 194)",
|
|
515
|
+
"rgb(132, 0, 132)",
|
|
516
|
+
"rgb(132, 0, 0)",
|
|
517
|
+
"rgb(132, 132, 0)",
|
|
518
|
+
"rgb(194, 194, 194)",
|
|
519
|
+
"rgb(0, 0, 132)",
|
|
520
|
+
"rgb(0, 132, 0)",
|
|
521
|
+
"rgb(132, 0, 0)",
|
|
522
|
+
"rgb(194, 194, 0)",
|
|
523
|
+
"rgb(194, 0, 194)",
|
|
524
|
+
"rgb(194, 0, 0)",
|
|
525
|
+
"rgb(0, 132, 132)",
|
|
526
|
+
"rgb(0, 132, 0)",
|
|
527
|
+
"rgb(0, 0, 132)",
|
|
528
|
+
"rgb(132, 132, 132)",
|
|
529
|
+
"rgb(132, 0, 132)",
|
|
530
|
+
"rgb(194, 194, 194)",
|
|
531
|
+
"rgb(132, 0, 132)",
|
|
532
|
+
"rgb(132, 0, 0)"
|
|
533
|
+
],
|
|
534
|
+
negative_objects: "rgb(132, 132, 132)",
|
|
535
|
+
worksheet: "rgb(0, 0, 132)"
|
|
536
|
+
},
|
|
537
|
+
palette: [
|
|
538
|
+
"rgb(132, 0, 0)",
|
|
539
|
+
"rgb(194, 194, 0)",
|
|
540
|
+
"rgb(194, 0, 194)",
|
|
541
|
+
"rgb(194, 0, 0)",
|
|
542
|
+
"rgb(0, 132, 132)",
|
|
543
|
+
"rgb(0, 132, 0)",
|
|
544
|
+
"rgb(0, 0, 132)",
|
|
545
|
+
"rgb(132, 132, 132)",
|
|
546
|
+
"rgb(132, 0, 132)",
|
|
547
|
+
"rgb(194, 194, 194)",
|
|
548
|
+
"rgb(132, 0, 132)",
|
|
549
|
+
"rgb(132, 0, 0)",
|
|
550
|
+
"rgb(132, 132, 0)",
|
|
551
|
+
"rgb(194, 194, 194)",
|
|
552
|
+
"rgb(0, 0, 132)",
|
|
553
|
+
"rgb(0, 132, 0)"
|
|
554
|
+
],
|
|
555
|
+
schematic: {
|
|
556
|
+
anchor: "rgb(0, 0, 255)",
|
|
557
|
+
aux_items: "rgb(0, 0, 0)",
|
|
558
|
+
background: "rgb(33, 33, 33)",
|
|
559
|
+
brightened: "rgb(204, 204, 204)",
|
|
560
|
+
bus: "rgb(0, 96, 192)",
|
|
561
|
+
bus_junction: "rgb(0, 96, 192)",
|
|
562
|
+
component_body: "rgb(44, 44, 44)",
|
|
563
|
+
component_outline: "rgb(192, 0, 0)",
|
|
564
|
+
cursor: "rgb(224, 224, 224)",
|
|
565
|
+
erc_error: "rgba(192, 48, 48, 0.800)",
|
|
566
|
+
erc_warning: "rgba(192, 140, 0, 0.800)",
|
|
567
|
+
fields: "rgb(128, 0, 160)",
|
|
568
|
+
grid: "rgb(60, 60, 60)",
|
|
569
|
+
grid_axes: "rgb(60, 60, 60)",
|
|
570
|
+
hidden: "rgb(194, 194, 194)",
|
|
571
|
+
junction: "rgb(0, 160, 0)",
|
|
572
|
+
label_global: "rgb(0, 160, 224)",
|
|
573
|
+
label_hier: "rgb(160, 160, 0)",
|
|
574
|
+
label_local: "rgb(192, 192, 192)",
|
|
575
|
+
net_name: "rgb(224, 224, 224)",
|
|
576
|
+
no_connect: "rgb(97, 43, 224)",
|
|
577
|
+
note: "rgb(192, 192, 0)",
|
|
578
|
+
override_item_colors: false,
|
|
579
|
+
pin: "rgb(192, 0, 0)",
|
|
580
|
+
pin_name: "rgb(192, 192, 192)",
|
|
581
|
+
pin_number: "rgb(192, 0, 0)",
|
|
582
|
+
reference: "rgb(192, 192, 192)",
|
|
583
|
+
shadow: "rgba(102, 179, 255, 0.800)",
|
|
584
|
+
sheet: "rgb(128, 0, 160)",
|
|
585
|
+
sheet_background: "rgba(255, 255, 255, 0.000)",
|
|
586
|
+
sheet_fields: "rgb(160, 160, 0)",
|
|
587
|
+
sheet_filename: "rgb(160, 160, 0)",
|
|
588
|
+
sheet_label: "rgb(160, 160, 0)",
|
|
589
|
+
sheet_name: "rgb(0, 160, 204)",
|
|
590
|
+
value: "rgb(192, 192, 192)",
|
|
591
|
+
wire: "rgb(0, 160, 0)",
|
|
592
|
+
worksheet: "rgb(192, 0, 0)"
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
// src/lib/Drawer.ts
|
|
597
|
+
var LAYER_NAME_TO_COLOR = {
|
|
598
|
+
red: "red",
|
|
599
|
+
black: "black",
|
|
600
|
+
green: "green",
|
|
601
|
+
top: colors_default.board.copper.f,
|
|
602
|
+
keepout: colors_default.board.background,
|
|
603
|
+
tkeepout: colors_default.board.b_crtyd,
|
|
604
|
+
tplace: colors_default.board.b_silks,
|
|
605
|
+
...colors_default.board
|
|
606
|
+
};
|
|
607
|
+
var Drawer = class {
|
|
608
|
+
constructor(canvas) {
|
|
609
|
+
this.canvas = canvas;
|
|
610
|
+
this.canvas = canvas;
|
|
611
|
+
this.ctx = canvas.getContext("2d");
|
|
612
|
+
this.transform = (0, import_transformation_matrix2.identity)();
|
|
613
|
+
this.transform.d *= -1;
|
|
614
|
+
this.transform = (0, import_transformation_matrix2.compose)(this.transform, (0, import_transformation_matrix2.translate)(0, -500));
|
|
615
|
+
}
|
|
616
|
+
clear() {
|
|
617
|
+
const { ctx, canvas } = this;
|
|
618
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
619
|
+
}
|
|
620
|
+
equip(aperature) {
|
|
621
|
+
this.aperture = {
|
|
622
|
+
fontSize: 0,
|
|
623
|
+
shape: "circle",
|
|
624
|
+
mode: "add",
|
|
625
|
+
size: 0,
|
|
626
|
+
color: "red",
|
|
627
|
+
...aperature
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
rect(x, y, w, h) {
|
|
631
|
+
const [x1$, y1$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x - w / 2, y - h / 2]);
|
|
632
|
+
const [x2$, y2$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x + w / 2, y + h / 2]);
|
|
633
|
+
this.applyAperture();
|
|
634
|
+
this.ctx.fillRect(x1$, y1$, x2$ - x1$, y2$ - y1$);
|
|
635
|
+
}
|
|
636
|
+
circle(x, y, r) {
|
|
637
|
+
const r$ = scaleOnly(this.transform, r);
|
|
638
|
+
const [x$, y$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x, y]);
|
|
639
|
+
this.applyAperture();
|
|
640
|
+
this.ctx.beginPath();
|
|
641
|
+
this.ctx.arc(x$, y$, r$, 0, 2 * Math.PI);
|
|
642
|
+
this.ctx.fill();
|
|
643
|
+
this.ctx.closePath();
|
|
644
|
+
}
|
|
645
|
+
debugText(text, x, y) {
|
|
646
|
+
const [x$, y$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x, y]);
|
|
647
|
+
this.applyAperture();
|
|
648
|
+
this.ctx.font = `10px sans-serif`;
|
|
649
|
+
this.ctx.fillText(text, x$, y$);
|
|
650
|
+
}
|
|
651
|
+
applyAperture() {
|
|
652
|
+
const { ctx, transform, aperture } = this;
|
|
653
|
+
const { size, mode, color, fontSize } = aperture;
|
|
654
|
+
ctx.lineWidth = scaleOnly(transform, size);
|
|
655
|
+
ctx.lineCap = "round";
|
|
656
|
+
if (mode === "add") {
|
|
657
|
+
let colorString = color[0] === "#" || color.startsWith("rgb") ? color : LAYER_NAME_TO_COLOR[color.toLowerCase()] ? LAYER_NAME_TO_COLOR[color.toLowerCase()] : null;
|
|
658
|
+
if (colorString === null) {
|
|
659
|
+
console.warn(`Color mapping for "${color}" not found`);
|
|
660
|
+
colorString = "white";
|
|
661
|
+
}
|
|
662
|
+
ctx.fillStyle = colorString;
|
|
663
|
+
ctx.strokeStyle = colorString;
|
|
664
|
+
} else {
|
|
665
|
+
ctx.globalCompositeOperation = "destination-out";
|
|
666
|
+
ctx.fillStyle = "rgba(0,0,0,1)";
|
|
667
|
+
ctx.strokeStyle = "rgba(0,0,0,1)";
|
|
668
|
+
}
|
|
669
|
+
ctx.font = `${scaleOnly((0, import_transformation_matrix2.inverse)(transform), fontSize)}px sans-serif`;
|
|
670
|
+
}
|
|
671
|
+
moveTo(x, y) {
|
|
672
|
+
this.lastPoint = { x, y };
|
|
673
|
+
}
|
|
674
|
+
lineTo(x, y) {
|
|
675
|
+
const [x$, y$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x, y]);
|
|
676
|
+
const { size, shape, mode } = this.aperture;
|
|
677
|
+
const size$ = scaleOnly(this.transform, size);
|
|
678
|
+
let { lastPoint, ctx } = this;
|
|
679
|
+
const lastPoint$ = (0, import_transformation_matrix2.applyToPoint)(this.transform, lastPoint);
|
|
680
|
+
this.applyAperture();
|
|
681
|
+
if (shape === "square")
|
|
682
|
+
ctx.fillRect(
|
|
683
|
+
lastPoint$.x - size$ / 2,
|
|
684
|
+
lastPoint$.y - size$ / 2,
|
|
685
|
+
size$,
|
|
686
|
+
size$
|
|
687
|
+
);
|
|
688
|
+
ctx.beginPath();
|
|
689
|
+
ctx.moveTo(lastPoint$.x, lastPoint$.y);
|
|
690
|
+
ctx.lineTo(x$, y$);
|
|
691
|
+
ctx.stroke();
|
|
692
|
+
ctx.closePath();
|
|
693
|
+
if (shape === "square")
|
|
694
|
+
ctx.fillRect(x$ - size$ / 2, y$ - size$ / 2, size$, size$);
|
|
695
|
+
this.lastPoint = { x, y };
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
// src/components/CanvasPrimitiveRenderer.tsx
|
|
700
|
+
var CanvasPrimitiveRenderer = ({
|
|
701
|
+
primitives,
|
|
702
|
+
transform,
|
|
703
|
+
grid,
|
|
704
|
+
width = 500,
|
|
705
|
+
height = 500
|
|
706
|
+
}) => {
|
|
707
|
+
const ref = (0, import_react.useRef)();
|
|
708
|
+
(0, import_react.useEffect)(() => {
|
|
709
|
+
const drawer = new Drawer(ref.current);
|
|
710
|
+
if (transform)
|
|
711
|
+
drawer.transform = transform;
|
|
712
|
+
drawer.clear();
|
|
713
|
+
if (grid)
|
|
714
|
+
drawGrid(drawer, grid);
|
|
715
|
+
drawPrimitives(drawer, primitives);
|
|
716
|
+
}, [primitives, transform]);
|
|
717
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
718
|
+
style: {
|
|
719
|
+
backgroundColor: "black",
|
|
720
|
+
width,
|
|
721
|
+
height,
|
|
722
|
+
border: "1px solid #f00"
|
|
723
|
+
}
|
|
724
|
+
}, /* @__PURE__ */ import_react.default.createElement("canvas", {
|
|
725
|
+
ref,
|
|
726
|
+
width,
|
|
727
|
+
height
|
|
728
|
+
}));
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
// src/components/CanvasElementsRenderer.tsx
|
|
732
|
+
var import_react3 = require("react");
|
|
733
|
+
|
|
734
|
+
// src/lib/convert-element-to-primitive.ts
|
|
735
|
+
var convertElementToPrimitives = (element) => {
|
|
736
|
+
switch (element.type) {
|
|
737
|
+
case "pcb_smtpad": {
|
|
738
|
+
if (element.shape === "rect") {
|
|
739
|
+
const { shape, x, y, width, height, layer } = element;
|
|
740
|
+
return [
|
|
741
|
+
{
|
|
742
|
+
pcb_drawing_type: "rect",
|
|
743
|
+
x,
|
|
744
|
+
y,
|
|
745
|
+
w: width,
|
|
746
|
+
h: height,
|
|
747
|
+
layer: layer || { name: "top" }
|
|
748
|
+
}
|
|
749
|
+
];
|
|
750
|
+
} else if (element.shape === "circle") {
|
|
751
|
+
console.warn(`Unsupported shape: ${element.shape} for pcb_smtpad`);
|
|
752
|
+
return [];
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
case "pcb_plated_hole": {
|
|
756
|
+
const { x, y, hole_diameter, outer_diameter } = element;
|
|
757
|
+
return [
|
|
758
|
+
{
|
|
759
|
+
pcb_drawing_type: "circle",
|
|
760
|
+
x,
|
|
761
|
+
y,
|
|
762
|
+
r: outer_diameter / 2,
|
|
763
|
+
layer: { name: "top" }
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
pcb_drawing_type: "circle",
|
|
767
|
+
x,
|
|
768
|
+
y,
|
|
769
|
+
r: hole_diameter / 2,
|
|
770
|
+
layer: { name: "drill" }
|
|
771
|
+
}
|
|
772
|
+
];
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
console.warn(`Unsupported element type: ${element.type}`);
|
|
776
|
+
return [];
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
// src/components/CanvasElementsRenderer.tsx
|
|
780
|
+
var CanvasElementsRenderer = (props) => {
|
|
781
|
+
const primitives = (0, import_react3.useMemo)(() => {
|
|
782
|
+
const primitives2 = props.elements.flatMap(
|
|
783
|
+
(elm) => convertElementToPrimitives(elm)
|
|
784
|
+
);
|
|
785
|
+
return primitives2;
|
|
786
|
+
}, [props.elements]);
|
|
787
|
+
return /* @__PURE__ */ import_react2.default.createElement(CanvasPrimitiveRenderer, {
|
|
788
|
+
transform: props.transform,
|
|
789
|
+
primitives,
|
|
790
|
+
width: props.width,
|
|
791
|
+
height: props.height,
|
|
792
|
+
grid: props.grid
|
|
793
|
+
});
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
// src/pages/canvas-elements-renderer.tsx
|
|
797
|
+
var import_transformation_matrix3 = require("transformation-matrix");
|
|
798
|
+
var import_use_mouse_matrix_transform = __toESM(require_dist());
|
|
799
|
+
var defaultTransform = (0, import_transformation_matrix3.compose)((0, import_transformation_matrix3.translate)(100, 100), (0, import_transformation_matrix3.scale)(40, 40));
|
|
800
|
+
var canvas_elements_renderer_default = () => {
|
|
801
|
+
const { ref: transformRef, transform } = (0, import_use_mouse_matrix_transform.useMouseMatrixTransform)({
|
|
802
|
+
initialTransform: defaultTransform
|
|
803
|
+
});
|
|
804
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
805
|
+
ref: transformRef
|
|
806
|
+
}, /* @__PURE__ */ import_react4.default.createElement(CanvasElementsRenderer, {
|
|
807
|
+
elements: [
|
|
808
|
+
{
|
|
809
|
+
type: "pcb_component",
|
|
810
|
+
source_component_id: "generic_0",
|
|
811
|
+
pcb_component_id: "pcb_generic_component_0",
|
|
812
|
+
source: {
|
|
813
|
+
type: "source_component",
|
|
814
|
+
source_component_id: "generic_0",
|
|
815
|
+
name: "C1"
|
|
816
|
+
}
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
type: "pcb_smtpad",
|
|
820
|
+
shape: "rect",
|
|
821
|
+
x: 0,
|
|
822
|
+
y: 0,
|
|
823
|
+
width: 1,
|
|
824
|
+
height: 1,
|
|
825
|
+
pcb_component_id: "pcb_generic_component_0",
|
|
826
|
+
source: null
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
type: "pcb_smtpad",
|
|
830
|
+
shape: "rect",
|
|
831
|
+
x: 2,
|
|
832
|
+
y: 0,
|
|
833
|
+
width: 1,
|
|
834
|
+
height: 1,
|
|
835
|
+
pcb_component_id: "pcb_generic_component_0",
|
|
836
|
+
source: null
|
|
837
|
+
}
|
|
838
|
+
],
|
|
839
|
+
height: 300,
|
|
840
|
+
width: 500,
|
|
841
|
+
transform,
|
|
842
|
+
grid: {
|
|
843
|
+
spacing: 1,
|
|
844
|
+
view_window: {
|
|
845
|
+
left: 0,
|
|
846
|
+
right: 500,
|
|
847
|
+
top: 300,
|
|
848
|
+
bottom: 0
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}));
|
|
852
|
+
};
|
|
853
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
854
|
+
0 && (module.exports = {});
|
|
855
|
+
//# sourceMappingURL=canvas-elements-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../node_modules/use-mouse-matrix-transform/src/index.ts","../../src/pages/canvas-elements-renderer.tsx","../../src/components/CanvasElementsRenderer.tsx","../../src/lib/draw-grid.ts","../../src/lib/util/scale-only.ts","../../src/components/CanvasPrimitiveRenderer.tsx","../../src/assets/alphabet.ts","../../src/lib/convert-text-to-lines.ts","../../src/lib/draw-primitives.ts","../../src/lib/Drawer.ts","../../src/lib/colors.ts","../../src/lib/convert-element-to-primitive.ts"],"sourcesContent":["import {\n Matrix,\n identity,\n scale,\n translate,\n compose,\n applyToPoint,\n} from \"transformation-matrix\"\nimport { useCallback, useEffect, useRef, useState } from \"react\"\n\ntype Point = { x: number; y: number }\n\ninterface Props {\n canvasElm?: HTMLElement\n transform?: Matrix\n initialTransform?: Matrix\n onSetTransform?: (transform: Matrix) => any\n}\n\nexport const useMouseMatrixTransform = (props: Props = {}) => {\n const extRef = useRef<any>(null)\n const canvasElm = props.canvasElm ?? extRef.current\n const [internalTransform, setInternalTransform] = useState<Matrix>(\n props.initialTransform ?? identity()\n )\n\n const setTransform = (newTransform: Matrix) => {\n if (props.onSetTransform) {\n props.onSetTransform(newTransform)\n } else {\n setInternalTransform(newTransform)\n }\n }\n\n const transform = props.transform ?? internalTransform\n\n useEffect(() => {\n // redefine canvasElm, it can sometimes not be defined in\n // render but be defined in effects due to SSR\n const canvasElm = props.canvasElm ?? extRef.current\n if (!canvasElm) return\n let init_tf = props.transform ?? internalTransform\n\n let m0: Point = { x: 0, y: 0 },\n m1: Point = { x: 0, y: 0 },\n md = false,\n mlastrel: Point = { x: 0, y: 0 }\n\n const getMousePos = (e: MouseEvent) => {\n const rect = canvasElm.getBoundingClientRect()\n return {\n x: e.clientX - rect.left,\n y: e.clientY - rect.top,\n }\n }\n\n function handleMouseDown(e: MouseEvent) {\n m0 = getMousePos(e)\n md = true\n e.preventDefault()\n }\n function handleMouseUp(e: MouseEvent) {\n m1 = getMousePos(e)\n\n const new_tf = compose(translate(m1.x - m0.x, m1.y - m0.y), init_tf)\n setTransform(new_tf)\n init_tf = new_tf\n\n md = false\n }\n function handleMouseMove(e: MouseEvent) {\n mlastrel = getMousePos(e)\n if (!md) return\n m1 = getMousePos(e)\n\n setTransform(compose(translate(m1.x - m0.x, m1.y - m0.y), init_tf))\n }\n function handleMouseWheel(e: WheelEvent) {\n const center = getMousePos(e)\n const new_tf = compose(\n translate(center.x, center.y),\n scale(1 - e.deltaY / 1000, 1 - e.deltaY / 1000),\n translate(-center.x, -center.y),\n init_tf\n )\n setTransform(new_tf)\n init_tf = new_tf\n e.preventDefault()\n }\n function handleMouseOut(e: MouseEvent) {\n if (!md) return\n md = false\n m1 = getMousePos(e)\n\n const new_tf = compose(translate(m1.x - m0.x, m1.y - m0.y), init_tf)\n setTransform(new_tf)\n init_tf = new_tf\n }\n\n canvasElm.addEventListener(\"mousedown\", handleMouseDown)\n canvasElm.addEventListener(\"mouseup\", handleMouseUp)\n canvasElm.addEventListener(\"mousemove\", handleMouseMove)\n canvasElm.addEventListener(\"mouseout\", handleMouseOut)\n canvasElm.addEventListener(\"wheel\", handleMouseWheel)\n\n return () => {\n canvasElm.removeEventListener(\"mousedown\", handleMouseDown)\n canvasElm.removeEventListener(\"mouseup\", handleMouseUp)\n canvasElm.removeEventListener(\"mousemove\", handleMouseMove)\n canvasElm.removeEventListener(\"mouseout\", handleMouseOut)\n canvasElm.removeEventListener(\"wheel\", handleMouseWheel)\n }\n }, [canvasElm])\n\n const applyTransformToPoint = useCallback(\n (obj: Point | [number, number]) => applyToPoint(transform, obj),\n [transform]\n )\n\n return {\n ref: extRef,\n transform,\n applyTransformToPoint,\n }\n}\n\nexport default useMouseMatrixTransform\n","import React from \"react\"\nimport { CanvasElementsRenderer } from \"../components/CanvasElementsRenderer\"\nimport { compose, scale, translate } from \"transformation-matrix\"\nimport { useMouseMatrixTransform } from \"use-mouse-matrix-transform\"\n\nconst defaultTransform = compose(translate(100, 100), scale(40, 40))\n\nexport default () => {\n const { ref: transformRef, transform } = useMouseMatrixTransform({\n initialTransform: defaultTransform,\n })\n\n return (\n <div ref={transformRef}>\n <CanvasElementsRenderer\n elements={\n [\n {\n type: \"pcb_component\",\n source_component_id: \"generic_0\",\n pcb_component_id: \"pcb_generic_component_0\",\n source: {\n type: \"source_component\",\n source_component_id: \"generic_0\",\n name: \"C1\",\n },\n },\n {\n type: \"pcb_smtpad\",\n shape: \"rect\",\n x: 0,\n y: 0,\n width: 1,\n height: 1,\n pcb_component_id: \"pcb_generic_component_0\",\n source: null,\n },\n {\n type: \"pcb_smtpad\",\n shape: \"rect\",\n x: 2,\n y: 0,\n width: 1,\n height: 1,\n pcb_component_id: \"pcb_generic_component_0\",\n source: null,\n },\n ] as any\n }\n height={300}\n width={500}\n transform={transform}\n grid={{\n spacing: 1,\n view_window: {\n left: 0,\n right: 500,\n top: 300,\n bottom: 0,\n },\n }}\n />\n </div>\n )\n}\n","import React from \"react\"\nimport { CanvasPrimitiveRenderer } from \"./CanvasPrimitiveRenderer\"\nimport { AnyElement } from \"@tscircuit/builder\"\nimport { useMemo } from \"react\"\nimport { convertElementToPrimitives } from \"../lib/convert-element-to-primitive\"\nimport { Matrix } from \"transformation-matrix\"\nimport { GridConfig } from \"lib/types\"\n\nexport interface CanvasElementsRendererProps {\n elements: AnyElement[]\n transform?: Matrix\n width?: number\n height?: number\n grid?: GridConfig\n}\n\nexport const CanvasElementsRenderer = (props: CanvasElementsRendererProps) => {\n const primitives = useMemo(() => {\n const primitives = props.elements.flatMap((elm) =>\n convertElementToPrimitives(elm)\n )\n return primitives\n }, [props.elements])\n return (\n <CanvasPrimitiveRenderer\n transform={props.transform}\n primitives={primitives}\n width={props.width}\n height={props.height}\n grid={props.grid}\n />\n )\n}\n","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(\n inverse(drawer.transform),\n view_window\n )\n\n console.log({ view_window, transformed_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","import { drawGrid } from \"lib/draw-grid\"\nimport React, { useEffect, useRef } from \"react\"\nimport { Matrix } from \"transformation-matrix\"\nimport { drawPrimitives } from \"../lib/draw-primitives\"\nimport { Drawer } from \"../lib/Drawer\"\nimport { GridConfig, Primitive } from \"../lib/types\"\n\ninterface Props {\n primitives: Primitive[]\n defaultUnit?: string\n transform?: Matrix\n grid?: GridConfig\n width?: number\n height?: number\n}\n\nexport const CanvasPrimitiveRenderer = ({\n primitives,\n transform,\n grid,\n width = 500,\n height = 500,\n}: Props) => {\n const ref = useRef()\n useEffect(() => {\n const drawer = new Drawer(ref.current)\n if (transform) drawer.transform = transform\n drawer.clear()\n if (grid) drawGrid(drawer, grid)\n drawPrimitives(drawer, primitives)\n }, [primitives, transform])\n\n return (\n <div\n style={{\n backgroundColor: \"black\",\n width,\n height,\n border: \"1px solid #f00\",\n }}\n >\n <canvas ref={ref} width={width} height={height}></canvas>\n </div>\n )\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","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","import { scaleOnly } from \"./util/scale-only\"\nimport {\n identity,\n Matrix,\n applyToPoint,\n translate,\n compose,\n inverse,\n} from \"transformation-matrix\"\nimport colors from \"./colors\"\nimport { convertTextToLines } from \"./convert-text-to-lines\"\n\nexport interface Aperture {\n shape: \"circle\" | \"square\"\n size: number\n mode: \"add\" | \"subtract\"\n fontSize: number\n color: string\n}\n\nexport const LAYER_NAME_TO_COLOR = {\n // Standard colors, you shouldn't use these except for testing\n red: \"red\",\n black: \"black\",\n green: \"green\",\n // TODO more builtin html colors\n\n // Common eagle names\n top: colors.board.copper.f,\n keepout: colors.board.background,\n tkeepout: colors.board.b_crtyd,\n tplace: colors.board.b_silks,\n\n ...colors.board,\n}\n\nexport const FILL_TYPES = {\n 0: \"Empty\",\n 1: \"Solid\",\n 2: \"Line\",\n 3: \"LtSlash\",\n 4: \"Slash\",\n 5: \"BkSlash\",\n 6: \"LtBkSlash\",\n 7: \"Hatch\",\n 8: \"XHatch\",\n 9: \"Interleave\",\n 10: \"WideDot\",\n 11: \"CloseDot\",\n 12: \"Stipple1\",\n 13: \"Stipple2\",\n 14: \"Stipple3\",\n 15: \"Stipple4\",\n}\n\nexport class Drawer {\n ctx: CanvasRenderingContext2D\n aperture: Aperture\n transform: Matrix\n lastPoint: { x: number; y: number }\n\n constructor(public canvas: HTMLCanvasElement) {\n this.canvas = canvas\n this.ctx = canvas.getContext(\"2d\")\n this.transform = identity()\n // positive is up (cartesian)\n this.transform.d *= -1\n this.transform = compose(this.transform, translate(0, -500))\n }\n\n clear() {\n const { ctx, canvas } = this\n ctx.clearRect(0, 0, canvas.width, canvas.height)\n }\n\n equip(aperature: Partial<Aperture>) {\n this.aperture = {\n fontSize: 0,\n shape: \"circle\",\n mode: \"add\",\n size: 0,\n color: \"red\",\n ...aperature,\n }\n }\n\n rect(x: number, y: number, w: number, h: number) {\n const [x1$, y1$] = applyToPoint(this.transform, [x - w / 2, y - h / 2])\n const [x2$, y2$] = applyToPoint(this.transform, [x + w / 2, y + h / 2])\n this.applyAperture()\n this.ctx.fillRect(x1$, y1$, x2$ - x1$, y2$ - y1$)\n }\n\n circle(x: number, y: number, r: number) {\n const r$ = scaleOnly(this.transform, r)\n const [x$, y$] = applyToPoint(this.transform, [x, y])\n this.applyAperture()\n this.ctx.beginPath()\n this.ctx.arc(x$, y$, r$, 0, 2 * Math.PI)\n this.ctx.fill()\n this.ctx.closePath()\n }\n\n /* NOTE: This is not gerber compatible */\n debugText(text: string, x: number, y: number) {\n const [x$, y$] = applyToPoint(this.transform, [x, y])\n this.applyAperture()\n\n this.ctx.font = `10px sans-serif`\n this.ctx.fillText(text, x$, y$)\n }\n\n applyAperture() {\n const { ctx, transform, aperture } = this\n const { size, mode, color, fontSize } = aperture\n ctx.lineWidth = scaleOnly(transform, size)\n ctx.lineCap = \"round\"\n if (mode === \"add\") {\n let colorString =\n color[0] === \"#\" || color.startsWith(\"rgb\")\n ? color\n : LAYER_NAME_TO_COLOR[color.toLowerCase()]\n ? LAYER_NAME_TO_COLOR[color.toLowerCase()]\n : null\n if (colorString === null) {\n console.warn(`Color mapping for \"${color}\" not found`)\n colorString = \"white\"\n }\n ctx.fillStyle = colorString\n ctx.strokeStyle = colorString\n } else {\n ctx.globalCompositeOperation = \"destination-out\"\n ctx.fillStyle = \"rgba(0,0,0,1)\"\n ctx.strokeStyle = \"rgba(0,0,0,1)\"\n }\n ctx.font = `${scaleOnly(inverse(transform), fontSize)}px sans-serif`\n }\n\n moveTo(x: number, y: number) {\n this.lastPoint = { x, y }\n }\n lineTo(x: number, y: number) {\n const [x$, y$] = applyToPoint(this.transform, [x, y])\n const { size, shape, mode } = this.aperture\n const size$ = scaleOnly(this.transform, size)\n let { lastPoint, ctx } = this\n const lastPoint$ = applyToPoint(this.transform, lastPoint)\n\n this.applyAperture()\n\n if (shape === \"square\")\n ctx.fillRect(\n lastPoint$.x - size$ / 2,\n lastPoint$.y - size$ / 2,\n size$,\n size$\n )\n ctx.beginPath()\n ctx.moveTo(lastPoint$.x, lastPoint$.y)\n ctx.lineTo(x$, y$)\n\n ctx.stroke()\n ctx.closePath()\n\n if (shape === \"square\")\n ctx.fillRect(x$ - size$ / 2, y$ - size$ / 2, size$, size$)\n\n this.lastPoint = { x, y }\n }\n}\n","// Mix of Eagle Dark for schematics and KiCAD 2020 for PCBs\n// https://github.com/pointhi/kicad-color-schemes/blob/master/eagle-dark/eagle-dark.jsonO\n// https://github.com/pointhi/kicad-color-schemes/blob/master/kicad-2020/kicad_2020.json\nexport default {\n \"3d_viewer\": {\n background_bottom: \"rgb(102, 102, 128)\",\n background_top: \"rgb(204, 204, 230)\",\n board: \"rgb(51, 43, 23)\",\n copper: \"rgb(179, 156, 0)\",\n silkscreen_bottom: \"rgb(230, 230, 230)\",\n silkscreen_top: \"rgb(230, 230, 230)\",\n soldermask: \"rgb(20, 51, 36)\",\n solderpaste: \"rgb(128, 128, 128)\",\n },\n board: {\n anchor: \"rgb(255, 38, 226)\",\n aux_items: \"rgb(255, 255, 255)\",\n b_adhes: \"rgb(0, 0, 132)\",\n b_crtyd: \"rgb(255, 38, 226)\",\n b_fab: \"rgb(88, 93, 132)\",\n b_mask: \"rgba(2, 255, 238, 0.400)\",\n b_paste: \"rgb(0, 194, 194)\",\n b_silks: \"rgb(232, 178, 167)\",\n background: \"rgb(0, 16, 35)\",\n cmts_user: \"rgb(89, 148, 220)\",\n copper: {\n b: \"rgb(77, 127, 196)\",\n f: \"rgb(200, 52, 52)\",\n in1: \"rgb(127, 200, 127)\",\n in10: \"rgb(237, 124, 51)\",\n in11: \"rgb(91, 195, 235)\",\n in12: \"rgb(247, 111, 142)\",\n in13: \"rgb(167, 165, 198)\",\n in14: \"rgb(40, 204, 217)\",\n in15: \"rgb(232, 178, 167)\",\n in16: \"rgb(242, 237, 161)\",\n in17: \"rgb(237, 124, 51)\",\n in18: \"rgb(91, 195, 235)\",\n in19: \"rgb(247, 111, 142)\",\n in2: \"rgb(206, 125, 44)\",\n in20: \"rgb(167, 165, 198)\",\n in21: \"rgb(40, 204, 217)\",\n in22: \"rgb(232, 178, 167)\",\n in23: \"rgb(242, 237, 161)\",\n in24: \"rgb(237, 124, 51)\",\n in25: \"rgb(91, 195, 235)\",\n in26: \"rgb(247, 111, 142)\",\n in27: \"rgb(167, 165, 198)\",\n in28: \"rgb(40, 204, 217)\",\n in29: \"rgb(232, 178, 167)\",\n in3: \"rgb(79, 203, 203)\",\n in30: \"rgb(242, 237, 161)\",\n in4: \"rgb(219, 98, 139)\",\n in5: \"rgb(167, 165, 198)\",\n in6: \"rgb(40, 204, 217)\",\n in7: \"rgb(232, 178, 167)\",\n in8: \"rgb(242, 237, 161)\",\n in9: \"rgb(141, 203, 129)\",\n },\n cursor: \"rgb(255, 255, 255)\",\n drc: \"rgb(194, 194, 194)\",\n drc_error: \"rgba(215, 91, 107, 0.800)\",\n drc_exclusion: \"rgb(255, 255, 255)\",\n drc_warning: \"rgba(255, 208, 66, 0.902)\",\n dwgs_user: \"rgb(194, 194, 194)\",\n eco1_user: \"rgb(180, 219, 210)\",\n eco2_user: \"rgb(216, 200, 82)\",\n edge_cuts: \"rgb(208, 210, 205)\",\n f_adhes: \"rgb(132, 0, 132)\",\n f_crtyd: \"rgb(255, 0, 245)\",\n f_fab: \"rgb(175, 175, 175)\",\n f_mask: \"rgba(216, 100, 255, 0.400)\",\n f_paste: \"rgba(180, 160, 154, 0.902)\",\n f_silks: \"rgb(242, 237, 161)\",\n footprint_text_back: \"rgb(0, 0, 132)\",\n footprint_text_front: \"rgb(194, 194, 194)\",\n footprint_text_invisible: \"rgb(132, 132, 132)\",\n grid: \"rgb(132, 132, 132)\",\n grid_axes: \"rgb(194, 194, 194)\",\n margin: \"rgb(255, 38, 226)\",\n microvia: \"rgb(0, 132, 132)\",\n no_connect: \"rgb(0, 0, 132)\",\n pad_back: \"rgb(77, 127, 196)\",\n pad_front: \"rgb(200, 52, 52)\",\n pad_plated_hole: \"rgb(194, 194, 0)\",\n pad_through_hole: \"rgb(227, 183, 46)\",\n plated_hole: \"rgb(26, 196, 210)\",\n ratsnest: \"rgba(245, 255, 213, 0.702)\",\n select_overlay: \"rgb(4, 255, 67)\",\n through_via: \"rgb(236, 236, 236)\",\n user_1: \"rgb(194, 194, 194)\",\n user_2: \"rgb(89, 148, 220)\",\n user_3: \"rgb(180, 219, 210)\",\n user_4: \"rgb(216, 200, 82)\",\n user_5: \"rgb(194, 194, 194)\",\n user_6: \"rgb(89, 148, 220)\",\n user_7: \"rgb(180, 219, 210)\",\n user_8: \"rgb(216, 200, 82)\",\n user_9: \"rgb(232, 178, 167)\",\n via_blind_buried: \"rgb(187, 151, 38)\",\n via_hole: \"rgb(227, 183, 46)\",\n via_micro: \"rgb(0, 132, 132)\",\n via_through: \"rgb(236, 236, 236)\",\n worksheet: \"rgb(200, 114, 171)\",\n },\n gerbview: {\n axes: \"rgb(0, 0, 132)\",\n background: \"rgb(0, 0, 0)\",\n dcodes: \"rgb(255, 255, 255)\",\n grid: \"rgb(132, 132, 132)\",\n layers: [\n \"rgb(132, 0, 0)\",\n \"rgb(194, 194, 0)\",\n \"rgb(194, 0, 194)\",\n \"rgb(194, 0, 0)\",\n \"rgb(0, 132, 132)\",\n \"rgb(0, 132, 0)\",\n \"rgb(0, 0, 132)\",\n \"rgb(132, 132, 132)\",\n \"rgb(132, 0, 132)\",\n \"rgb(194, 194, 194)\",\n \"rgb(132, 0, 132)\",\n \"rgb(132, 0, 0)\",\n \"rgb(132, 132, 0)\",\n \"rgb(194, 194, 194)\",\n \"rgb(0, 0, 132)\",\n \"rgb(0, 132, 0)\",\n \"rgb(132, 0, 0)\",\n \"rgb(194, 194, 0)\",\n \"rgb(194, 0, 194)\",\n \"rgb(194, 0, 0)\",\n \"rgb(0, 132, 132)\",\n \"rgb(0, 132, 0)\",\n \"rgb(0, 0, 132)\",\n \"rgb(132, 132, 132)\",\n \"rgb(132, 0, 132)\",\n \"rgb(194, 194, 194)\",\n \"rgb(132, 0, 132)\",\n \"rgb(132, 0, 0)\",\n \"rgb(132, 132, 0)\",\n \"rgb(194, 194, 194)\",\n \"rgb(0, 0, 132)\",\n \"rgb(0, 132, 0)\",\n \"rgb(132, 0, 0)\",\n \"rgb(194, 194, 0)\",\n \"rgb(194, 0, 194)\",\n \"rgb(194, 0, 0)\",\n \"rgb(0, 132, 132)\",\n \"rgb(0, 132, 0)\",\n \"rgb(0, 0, 132)\",\n \"rgb(132, 132, 132)\",\n \"rgb(132, 0, 132)\",\n \"rgb(194, 194, 194)\",\n \"rgb(132, 0, 132)\",\n \"rgb(132, 0, 0)\",\n \"rgb(132, 132, 0)\",\n \"rgb(194, 194, 194)\",\n \"rgb(0, 0, 132)\",\n \"rgb(0, 132, 0)\",\n \"rgb(132, 0, 0)\",\n \"rgb(194, 194, 0)\",\n \"rgb(194, 0, 194)\",\n \"rgb(194, 0, 0)\",\n \"rgb(0, 132, 132)\",\n \"rgb(0, 132, 0)\",\n \"rgb(0, 0, 132)\",\n \"rgb(132, 132, 132)\",\n \"rgb(132, 0, 132)\",\n \"rgb(194, 194, 194)\",\n \"rgb(132, 0, 132)\",\n \"rgb(132, 0, 0)\",\n ],\n negative_objects: \"rgb(132, 132, 132)\",\n worksheet: \"rgb(0, 0, 132)\",\n },\n palette: [\n \"rgb(132, 0, 0)\",\n \"rgb(194, 194, 0)\",\n \"rgb(194, 0, 194)\",\n \"rgb(194, 0, 0)\",\n \"rgb(0, 132, 132)\",\n \"rgb(0, 132, 0)\",\n \"rgb(0, 0, 132)\",\n \"rgb(132, 132, 132)\",\n \"rgb(132, 0, 132)\",\n \"rgb(194, 194, 194)\",\n \"rgb(132, 0, 132)\",\n \"rgb(132, 0, 0)\",\n \"rgb(132, 132, 0)\",\n \"rgb(194, 194, 194)\",\n \"rgb(0, 0, 132)\",\n \"rgb(0, 132, 0)\",\n ],\n schematic: {\n anchor: \"rgb(0, 0, 255)\",\n aux_items: \"rgb(0, 0, 0)\",\n background: \"rgb(33, 33, 33)\",\n brightened: \"rgb(204, 204, 204)\",\n bus: \"rgb(0, 96, 192)\",\n bus_junction: \"rgb(0, 96, 192)\",\n component_body: \"rgb(44, 44, 44)\",\n component_outline: \"rgb(192, 0, 0)\",\n cursor: \"rgb(224, 224, 224)\",\n erc_error: \"rgba(192, 48, 48, 0.800)\",\n erc_warning: \"rgba(192, 140, 0, 0.800)\",\n fields: \"rgb(128, 0, 160)\",\n grid: \"rgb(60, 60, 60)\",\n grid_axes: \"rgb(60, 60, 60)\",\n hidden: \"rgb(194, 194, 194)\",\n junction: \"rgb(0, 160, 0)\",\n label_global: \"rgb(0, 160, 224)\",\n label_hier: \"rgb(160, 160, 0)\",\n label_local: \"rgb(192, 192, 192)\",\n net_name: \"rgb(224, 224, 224)\",\n no_connect: \"rgb(97, 43, 224)\",\n note: \"rgb(192, 192, 0)\",\n override_item_colors: false,\n pin: \"rgb(192, 0, 0)\",\n pin_name: \"rgb(192, 192, 192)\",\n pin_number: \"rgb(192, 0, 0)\",\n reference: \"rgb(192, 192, 192)\",\n shadow: \"rgba(102, 179, 255, 0.800)\",\n sheet: \"rgb(128, 0, 160)\",\n sheet_background: \"rgba(255, 255, 255, 0.000)\",\n sheet_fields: \"rgb(160, 160, 0)\",\n sheet_filename: \"rgb(160, 160, 0)\",\n sheet_label: \"rgb(160, 160, 0)\",\n sheet_name: \"rgb(0, 160, 204)\",\n value: \"rgb(192, 192, 192)\",\n wire: \"rgb(0, 160, 0)\",\n worksheet: \"rgb(192, 0, 0)\",\n },\n}\n","import { AnyElement } from \"@tscircuit/builder\"\nimport { Primitive } from \"./types\"\n\nexport const convertElementToPrimitives = (\n element: AnyElement\n): Primitive[] => {\n switch (element.type) {\n case \"pcb_smtpad\": {\n if (element.shape === \"rect\") {\n const { shape, x, y, width, height, layer } = element\n\n return [\n {\n pcb_drawing_type: \"rect\",\n x,\n y,\n w: width,\n h: height,\n layer: layer || { name: \"top\" },\n },\n ]\n } else if (element.shape === \"circle\") {\n console.warn(`Unsupported shape: ${element.shape} for pcb_smtpad`)\n return []\n }\n }\n case \"pcb_plated_hole\": {\n const { x, y, hole_diameter, outer_diameter } = element\n\n return [\n {\n pcb_drawing_type: \"circle\",\n x,\n y,\n r: outer_diameter / 2,\n // TODO support layer on pcb_plated_hole\n layer: { name: \"top\" },\n },\n {\n pcb_drawing_type: \"circle\",\n x,\n y,\n r: hole_diameter / 2,\n // TODO support layer on pcb_plated_hole\n layer: { name: \"drill\" },\n },\n ]\n }\n }\n\n console.warn(`Unsupported element type: ${element.type}`)\n return []\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,QAAA,cAAA,CAAA;AAAA,IAAAA,UAAA,aAAA;MAAA,SAAA,MAAA;MAAA,yBAAA,MAAAC;IAAA,CAAA;AAAA,IAAAC,QAAA,UAAAC,cAAA,WAAA;AAAA,QAAAC,gCAOO,QAAA;AACP,QAAAC,gBAAyD,QAAA;AAWlD,QAAMJ,2BAA0B,CAAC,QAAe,CAAC,MAAM;AAC5D,YAAM,UAAA,GAASI,cAAA,QAAY,IAAI;AAC/B,YAAM,YAAY,MAAM,aAAa,OAAO;AAC5C,YAAM,CAAC,mBAAmB,oBAAoB,KAAA,GAAIA,cAAA;QAChD,MAAM,qBAAA,GAAoBD,8BAAA,UAAS;MACrC;AAEA,YAAM,eAAe,CAAC,iBAAyB;AAC7C,YAAI,MAAM,gBAAgB;AACxB,gBAAM,eAAe,YAAY;QACnC,OAAO;AACL,+BAAqB,YAAY;QACnC;MACF;AAEA,YAAM,YAAY,MAAM,aAAa;AAErC,OAAA,GAAAC,cAAA,WAAU,MAAM;AAGd,cAAMC,aAAY,MAAM,aAAa,OAAO;AAC5C,YAAI,CAACA;AAAW;AAChB,YAAI,UAAU,MAAM,aAAa;AAEjC,YAAI,KAAY,EAAE,GAAG,GAAG,GAAG,EAAE,GAC3B,KAAY,EAAE,GAAG,GAAG,GAAG,EAAE,GACzB,KAAK,OACL,WAAkB,EAAE,GAAG,GAAG,G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;AAAA,QACP,QAAQ;AAAA,QACR,kBAAkB;AAAA,QAClB,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEF,QAAQ;AAAA,IACR,OAAO;AAAA,IACP;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,QACX,MAAM;AAAA,QACN,OAAO;AAAA,QACP,KAAK;AAAA,QACL,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,GACF,CACF;AAEJ;","names":["__export","useMouseMatrixTransform","module","__toCommonJS","import_transformation_matrix","import_react","canvasElm","import_react","import_react","import_transformation_matrix","React","import_react","primitives","React","import_transformation_matrix","React"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/pcb-viewer",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -23,18 +23,19 @@
|
|
|
23
23
|
"@types/react": "^18.0.21",
|
|
24
24
|
"next": "^12.3.1",
|
|
25
25
|
"react": "^18.2.0",
|
|
26
|
+
"react-dom": "^18.2.0",
|
|
26
27
|
"tsup": "^6.2.3",
|
|
27
28
|
"type-fest": "^3.0.0",
|
|
28
|
-
"typescript": "^4.8.4"
|
|
29
|
+
"typescript": "^4.8.4",
|
|
30
|
+
"use-mouse-matrix-transform": "^1.0.4"
|
|
29
31
|
},
|
|
30
32
|
"peerDependencies": {
|
|
31
|
-
"@tscircuit/builder": "
|
|
32
|
-
"@tscircuit/eagle-xml-converter": "
|
|
33
|
-
"@tscircuit/react-fiber": "
|
|
34
|
-
"react": "
|
|
33
|
+
"@tscircuit/builder": "*",
|
|
34
|
+
"@tscircuit/eagle-xml-converter": "*",
|
|
35
|
+
"@tscircuit/react-fiber": "*",
|
|
36
|
+
"react": "*"
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
|
-
"react-dom": "^18.2.0",
|
|
38
39
|
"transformation-matrix": "^2.13.0"
|
|
39
40
|
}
|
|
40
41
|
}
|