@tscircuit/pcb-viewer 1.0.3 → 1.2.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 +24 -0
- package/dist/index.d.ts +27 -5
- package/dist/index.js +231 -6
- package/dist/index.js.map +1 -1
- package/package.json +23 -11
- package/dist/PCBViewer.d.ts +0 -5
- package/dist/PCBViewer.js +0 -689
- package/dist/PCBViewer.js.map +0 -1
- package/dist/assets/alphabet.d.ts +0 -47
- package/dist/assets/alphabet.js +0 -87
- package/dist/assets/alphabet.js.map +0 -1
- package/dist/assets/attiny-eagle.d.ts +0 -133
- package/dist/assets/attiny-eagle.js +0 -869
- package/dist/assets/attiny-eagle.js.map +0 -1
- package/dist/components/CanvasElementsRenderer.d.ts +0 -14
- package/dist/components/CanvasElementsRenderer.js +0 -670
- package/dist/components/CanvasElementsRenderer.js.map +0 -1
- package/dist/components/CanvasPrimitiveRenderer.d.ts +0 -14
- package/dist/components/CanvasPrimitiveRenderer.js +0 -604
- package/dist/components/CanvasPrimitiveRenderer.js.map +0 -1
- package/dist/lib/Drawer.d.ts +0 -146
- package/dist/lib/Drawer.js +0 -396
- package/dist/lib/Drawer.js.map +0 -1
- package/dist/lib/colors.d.ts +0 -154
- package/dist/lib/colors.js +0 -257
- package/dist/lib/colors.js.map +0 -1
- package/dist/lib/convert-element-to-primitive.d.ts +0 -6
- package/dist/lib/convert-element-to-primitive.js +0 -72
- package/dist/lib/convert-element-to-primitive.js.map +0 -1
- package/dist/lib/convert-text-to-lines.d.ts +0 -5
- package/dist/lib/convert-text-to-lines.js +0 -114
- package/dist/lib/convert-text-to-lines.js.map +0 -1
- package/dist/lib/draw-eagle.d.ts +0 -7
- package/dist/lib/draw-eagle.js +0 -63
- package/dist/lib/draw-eagle.js.map +0 -1
- package/dist/lib/draw-grid.d.ts +0 -18
- package/dist/lib/draw-grid.js +0 -83
- package/dist/lib/draw-grid.js.map +0 -1
- package/dist/lib/draw-primitives.d.ts +0 -12
- package/dist/lib/draw-primitives.js +0 -181
- package/dist/lib/draw-primitives.js.map +0 -1
- package/dist/lib/types.d.ts +0 -52
- package/dist/lib/types.js +0 -18
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/util/scale-only.d.ts +0 -5
- package/dist/lib/util/scale-only.js +0 -34
- package/dist/lib/util/scale-only.js.map +0 -1
- package/dist/pages/eagle.d.ts +0 -3
- package/dist/pages/eagle.js +0 -1277
- package/dist/pages/eagle.js.map +0 -1
- package/dist/pages/index.d.ts +0 -3
- package/dist/pages/index.js +0 -402
- package/dist/pages/index.js.map +0 -1
- package/dist/pages/primitives.d.ts +0 -3
- package/dist/pages/primitives.js +0 -635
- package/dist/pages/primitives.js.map +0 -1
- package/dist/pages/viewer.d.ts +0 -14
- package/dist/pages/viewer.js +0 -708
- package/dist/pages/viewer.js.map +0 -1
package/dist/pages/primitives.js
DELETED
|
@@ -1,635 +0,0 @@
|
|
|
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 __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
|
|
25
|
-
// src/pages/primitives.tsx
|
|
26
|
-
var primitives_exports = {};
|
|
27
|
-
__export(primitives_exports, {
|
|
28
|
-
default: () => primitives_default
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(primitives_exports);
|
|
31
|
-
|
|
32
|
-
// src/lib/draw-grid.ts
|
|
33
|
-
var import_transformation_matrix = require("transformation-matrix");
|
|
34
|
-
|
|
35
|
-
// src/lib/util/scale-only.ts
|
|
36
|
-
var scaleOnly = (mat, value = 1) => {
|
|
37
|
-
if (Math.abs(mat.a) !== Math.abs(mat.d))
|
|
38
|
-
throw new Error("Cannot scale non-uniformly");
|
|
39
|
-
return value * Math.abs(mat.a);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/lib/draw-grid.ts
|
|
43
|
-
var transformBounds = (transform, bounds) => {
|
|
44
|
-
const { left, right, top, bottom } = bounds;
|
|
45
|
-
const [left$, top$] = (0, import_transformation_matrix.applyToPoint)(transform, [left, top]);
|
|
46
|
-
const [right$, bottom$] = (0, import_transformation_matrix.applyToPoint)(transform, [right, bottom]);
|
|
47
|
-
return {
|
|
48
|
-
left: Math.min(left$, right$),
|
|
49
|
-
right: Math.max(left$, right$),
|
|
50
|
-
top: Math.max(bottom$, top$),
|
|
51
|
-
bottom: Math.min(bottom$, top$)
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
var drawGrid = (drawer, grid_config) => {
|
|
55
|
-
const { spacing, view_window } = grid_config;
|
|
56
|
-
const transformed_window = transformBounds(
|
|
57
|
-
(0, import_transformation_matrix.inverse)(drawer.transform),
|
|
58
|
-
view_window
|
|
59
|
-
);
|
|
60
|
-
console.log({ view_window, transformed_window });
|
|
61
|
-
const { left, right, top, bottom } = transformed_window;
|
|
62
|
-
const startx = Math.floor(left / spacing) * spacing;
|
|
63
|
-
const starty = Math.floor(bottom / spacing) * spacing;
|
|
64
|
-
const px = scaleOnly((0, import_transformation_matrix.inverse)(drawer.transform));
|
|
65
|
-
drawer.equip({
|
|
66
|
-
color: "green",
|
|
67
|
-
mode: "add",
|
|
68
|
-
shape: "circle",
|
|
69
|
-
size: px
|
|
70
|
-
});
|
|
71
|
-
for (let x = startx; x < right; x += spacing) {
|
|
72
|
-
drawer.moveTo(x, bottom);
|
|
73
|
-
drawer.lineTo(x, top);
|
|
74
|
-
}
|
|
75
|
-
for (let y = starty; y < top; y += spacing) {
|
|
76
|
-
drawer.moveTo(left, y);
|
|
77
|
-
drawer.lineTo(right, y);
|
|
78
|
-
}
|
|
79
|
-
for (let x = startx; x < right; x += spacing) {
|
|
80
|
-
for (let y = starty; y < top; y += spacing) {
|
|
81
|
-
drawer.debugText(`${x}, ${y}`, x + px * 3, y - px * 3);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// src/pages/primitives.tsx
|
|
87
|
-
var import_react = __toESM(require("react"));
|
|
88
|
-
|
|
89
|
-
// src/assets/alphabet.ts
|
|
90
|
-
var svgAlphabet = {
|
|
91
|
-
"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",
|
|
92
|
-
"1": "M 0.198 0.272 L 0.537 0 L 0.54 1",
|
|
93
|
-
"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",
|
|
94
|
-
"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",
|
|
95
|
-
"4": "M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1",
|
|
96
|
-
"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",
|
|
97
|
-
"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",
|
|
98
|
-
"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",
|
|
99
|
-
"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",
|
|
100
|
-
"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",
|
|
101
|
-
A: "M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365",
|
|
102
|
-
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",
|
|
103
|
-
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",
|
|
104
|
-
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",
|
|
105
|
-
E: "M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1",
|
|
106
|
-
F: "M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823",
|
|
107
|
-
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",
|
|
108
|
-
H: "M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1",
|
|
109
|
-
I: "MNaN 0LNaN 1",
|
|
110
|
-
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",
|
|
111
|
-
K: "M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777",
|
|
112
|
-
L: "M0 0L0 1L1 1",
|
|
113
|
-
M: "M0 1L0 0L0.5 0.6512L1 0L1 1",
|
|
114
|
-
N: "M0 1L0 0L1 1L0.9803729146221786 0",
|
|
115
|
-
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",
|
|
116
|
-
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",
|
|
117
|
-
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",
|
|
118
|
-
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",
|
|
119
|
-
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",
|
|
120
|
-
T: "M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1",
|
|
121
|
-
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",
|
|
122
|
-
V: "M0 0L0.5348837209302325 1L1 0",
|
|
123
|
-
W: "M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845",
|
|
124
|
-
X: "M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1",
|
|
125
|
-
Y: "M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1",
|
|
126
|
-
Z: "M0 0L1 0L0 1L1 1",
|
|
127
|
-
".": "M 0.49 1 L 0.41 1"
|
|
128
|
-
};
|
|
129
|
-
var lineAlphabet = {};
|
|
130
|
-
for (const letter in svgAlphabet) {
|
|
131
|
-
lineAlphabet[letter] = [];
|
|
132
|
-
const segs = svgAlphabet[letter].split("M").slice(1).map(
|
|
133
|
-
(seg) => seg.split("L").map((pr) => pr.trim().split(" ").map(parseFloat))
|
|
134
|
-
);
|
|
135
|
-
for (const seg of segs) {
|
|
136
|
-
for (let i = 0; i < seg.length - 1; i++) {
|
|
137
|
-
lineAlphabet[letter].push({
|
|
138
|
-
x1: seg[i][0],
|
|
139
|
-
y1: 1 - seg[i][1],
|
|
140
|
-
x2: seg[i + 1][0],
|
|
141
|
-
y2: 1 - seg[i + 1][1]
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// src/lib/convert-text-to-lines.ts
|
|
148
|
-
var convertTextToLines = (text) => {
|
|
149
|
-
const strokeWidth = text.size / 8;
|
|
150
|
-
const letterWidth = text.size * 0.6;
|
|
151
|
-
const letterSpace = text.size * 0.2;
|
|
152
|
-
const lines = [];
|
|
153
|
-
for (let letterIndex = 0; letterIndex < text.text.length; letterIndex++) {
|
|
154
|
-
const letter = text.text[letterIndex];
|
|
155
|
-
const letterLines = lineAlphabet[letter.toUpperCase()];
|
|
156
|
-
if (!letterLines)
|
|
157
|
-
continue;
|
|
158
|
-
for (const { x1, y1, x2, y2 } of letterLines) {
|
|
159
|
-
lines.push({
|
|
160
|
-
pcb_drawing_type: "line",
|
|
161
|
-
x1: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x1,
|
|
162
|
-
y1: text.y + text.size * y1,
|
|
163
|
-
x2: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x2,
|
|
164
|
-
y2: text.y + text.size * y2,
|
|
165
|
-
width: strokeWidth,
|
|
166
|
-
layer: text.layer,
|
|
167
|
-
unit: text.unit
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return lines;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
// src/lib/draw-primitives.ts
|
|
175
|
-
var drawLine = (drawer, line) => {
|
|
176
|
-
drawer.equip({
|
|
177
|
-
size: line.width,
|
|
178
|
-
shape: line.squareCap ? "square" : "circle",
|
|
179
|
-
color: line.layer.name
|
|
180
|
-
});
|
|
181
|
-
drawer.moveTo(line.x1, line.y1);
|
|
182
|
-
drawer.lineTo(line.x2, line.y2);
|
|
183
|
-
};
|
|
184
|
-
var drawText = (drawer, text) => {
|
|
185
|
-
drawer.equip({
|
|
186
|
-
fontSize: text.size,
|
|
187
|
-
color: text.layer.name
|
|
188
|
-
});
|
|
189
|
-
if (text.align && text.align !== "top-left") {
|
|
190
|
-
console.warn("Unhandled text align", text.align);
|
|
191
|
-
}
|
|
192
|
-
const lines = convertTextToLines(text);
|
|
193
|
-
for (const line of lines) {
|
|
194
|
-
drawLine(drawer, line);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
var drawRect = (drawer, rect) => {
|
|
198
|
-
drawer.equip({
|
|
199
|
-
color: rect.layer.name
|
|
200
|
-
});
|
|
201
|
-
if (rect.align && rect.align !== "center") {
|
|
202
|
-
console.warn("Unhandled rect align", rect.align);
|
|
203
|
-
}
|
|
204
|
-
drawer.rect(rect.x, rect.y, rect.w, rect.h);
|
|
205
|
-
};
|
|
206
|
-
var drawCircle = (drawer, circle) => {
|
|
207
|
-
drawer.equip({
|
|
208
|
-
color: circle.layer.name
|
|
209
|
-
});
|
|
210
|
-
drawer.circle(circle.x, circle.y, circle.r);
|
|
211
|
-
};
|
|
212
|
-
var drawPrimitive = (drawer, primitive) => {
|
|
213
|
-
switch (primitive.pcb_drawing_type) {
|
|
214
|
-
case "line":
|
|
215
|
-
return drawLine(drawer, primitive);
|
|
216
|
-
case "text":
|
|
217
|
-
return drawText(drawer, primitive);
|
|
218
|
-
case "rect":
|
|
219
|
-
return drawRect(drawer, primitive);
|
|
220
|
-
case "circle":
|
|
221
|
-
return drawCircle(drawer, primitive);
|
|
222
|
-
}
|
|
223
|
-
throw new Error(
|
|
224
|
-
`Unknown primitive type: ${primitive.pcb_drawing_type}`
|
|
225
|
-
);
|
|
226
|
-
};
|
|
227
|
-
var drawPrimitives = (drawer, primitives) => {
|
|
228
|
-
primitives.forEach((primitive) => drawPrimitive(drawer, primitive));
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// src/lib/Drawer.ts
|
|
232
|
-
var import_transformation_matrix2 = require("transformation-matrix");
|
|
233
|
-
|
|
234
|
-
// src/lib/colors.ts
|
|
235
|
-
var colors_default = {
|
|
236
|
-
"3d_viewer": {
|
|
237
|
-
background_bottom: "rgb(102, 102, 128)",
|
|
238
|
-
background_top: "rgb(204, 204, 230)",
|
|
239
|
-
board: "rgb(51, 43, 23)",
|
|
240
|
-
copper: "rgb(179, 156, 0)",
|
|
241
|
-
silkscreen_bottom: "rgb(230, 230, 230)",
|
|
242
|
-
silkscreen_top: "rgb(230, 230, 230)",
|
|
243
|
-
soldermask: "rgb(20, 51, 36)",
|
|
244
|
-
solderpaste: "rgb(128, 128, 128)"
|
|
245
|
-
},
|
|
246
|
-
board: {
|
|
247
|
-
anchor: "rgb(255, 38, 226)",
|
|
248
|
-
aux_items: "rgb(255, 255, 255)",
|
|
249
|
-
b_adhes: "rgb(0, 0, 132)",
|
|
250
|
-
b_crtyd: "rgb(255, 38, 226)",
|
|
251
|
-
b_fab: "rgb(88, 93, 132)",
|
|
252
|
-
b_mask: "rgba(2, 255, 238, 0.400)",
|
|
253
|
-
b_paste: "rgb(0, 194, 194)",
|
|
254
|
-
b_silks: "rgb(232, 178, 167)",
|
|
255
|
-
background: "rgb(0, 16, 35)",
|
|
256
|
-
cmts_user: "rgb(89, 148, 220)",
|
|
257
|
-
copper: {
|
|
258
|
-
b: "rgb(77, 127, 196)",
|
|
259
|
-
f: "rgb(200, 52, 52)",
|
|
260
|
-
in1: "rgb(127, 200, 127)",
|
|
261
|
-
in10: "rgb(237, 124, 51)",
|
|
262
|
-
in11: "rgb(91, 195, 235)",
|
|
263
|
-
in12: "rgb(247, 111, 142)",
|
|
264
|
-
in13: "rgb(167, 165, 198)",
|
|
265
|
-
in14: "rgb(40, 204, 217)",
|
|
266
|
-
in15: "rgb(232, 178, 167)",
|
|
267
|
-
in16: "rgb(242, 237, 161)",
|
|
268
|
-
in17: "rgb(237, 124, 51)",
|
|
269
|
-
in18: "rgb(91, 195, 235)",
|
|
270
|
-
in19: "rgb(247, 111, 142)",
|
|
271
|
-
in2: "rgb(206, 125, 44)",
|
|
272
|
-
in20: "rgb(167, 165, 198)",
|
|
273
|
-
in21: "rgb(40, 204, 217)",
|
|
274
|
-
in22: "rgb(232, 178, 167)",
|
|
275
|
-
in23: "rgb(242, 237, 161)",
|
|
276
|
-
in24: "rgb(237, 124, 51)",
|
|
277
|
-
in25: "rgb(91, 195, 235)",
|
|
278
|
-
in26: "rgb(247, 111, 142)",
|
|
279
|
-
in27: "rgb(167, 165, 198)",
|
|
280
|
-
in28: "rgb(40, 204, 217)",
|
|
281
|
-
in29: "rgb(232, 178, 167)",
|
|
282
|
-
in3: "rgb(79, 203, 203)",
|
|
283
|
-
in30: "rgb(242, 237, 161)",
|
|
284
|
-
in4: "rgb(219, 98, 139)",
|
|
285
|
-
in5: "rgb(167, 165, 198)",
|
|
286
|
-
in6: "rgb(40, 204, 217)",
|
|
287
|
-
in7: "rgb(232, 178, 167)",
|
|
288
|
-
in8: "rgb(242, 237, 161)",
|
|
289
|
-
in9: "rgb(141, 203, 129)"
|
|
290
|
-
},
|
|
291
|
-
cursor: "rgb(255, 255, 255)",
|
|
292
|
-
drc: "rgb(194, 194, 194)",
|
|
293
|
-
drc_error: "rgba(215, 91, 107, 0.800)",
|
|
294
|
-
drc_exclusion: "rgb(255, 255, 255)",
|
|
295
|
-
drc_warning: "rgba(255, 208, 66, 0.902)",
|
|
296
|
-
dwgs_user: "rgb(194, 194, 194)",
|
|
297
|
-
eco1_user: "rgb(180, 219, 210)",
|
|
298
|
-
eco2_user: "rgb(216, 200, 82)",
|
|
299
|
-
edge_cuts: "rgb(208, 210, 205)",
|
|
300
|
-
f_adhes: "rgb(132, 0, 132)",
|
|
301
|
-
f_crtyd: "rgb(255, 0, 245)",
|
|
302
|
-
f_fab: "rgb(175, 175, 175)",
|
|
303
|
-
f_mask: "rgba(216, 100, 255, 0.400)",
|
|
304
|
-
f_paste: "rgba(180, 160, 154, 0.902)",
|
|
305
|
-
f_silks: "rgb(242, 237, 161)",
|
|
306
|
-
footprint_text_back: "rgb(0, 0, 132)",
|
|
307
|
-
footprint_text_front: "rgb(194, 194, 194)",
|
|
308
|
-
footprint_text_invisible: "rgb(132, 132, 132)",
|
|
309
|
-
grid: "rgb(132, 132, 132)",
|
|
310
|
-
grid_axes: "rgb(194, 194, 194)",
|
|
311
|
-
margin: "rgb(255, 38, 226)",
|
|
312
|
-
microvia: "rgb(0, 132, 132)",
|
|
313
|
-
no_connect: "rgb(0, 0, 132)",
|
|
314
|
-
pad_back: "rgb(77, 127, 196)",
|
|
315
|
-
pad_front: "rgb(200, 52, 52)",
|
|
316
|
-
pad_plated_hole: "rgb(194, 194, 0)",
|
|
317
|
-
pad_through_hole: "rgb(227, 183, 46)",
|
|
318
|
-
plated_hole: "rgb(26, 196, 210)",
|
|
319
|
-
ratsnest: "rgba(245, 255, 213, 0.702)",
|
|
320
|
-
select_overlay: "rgb(4, 255, 67)",
|
|
321
|
-
through_via: "rgb(236, 236, 236)",
|
|
322
|
-
user_1: "rgb(194, 194, 194)",
|
|
323
|
-
user_2: "rgb(89, 148, 220)",
|
|
324
|
-
user_3: "rgb(180, 219, 210)",
|
|
325
|
-
user_4: "rgb(216, 200, 82)",
|
|
326
|
-
user_5: "rgb(194, 194, 194)",
|
|
327
|
-
user_6: "rgb(89, 148, 220)",
|
|
328
|
-
user_7: "rgb(180, 219, 210)",
|
|
329
|
-
user_8: "rgb(216, 200, 82)",
|
|
330
|
-
user_9: "rgb(232, 178, 167)",
|
|
331
|
-
via_blind_buried: "rgb(187, 151, 38)",
|
|
332
|
-
via_hole: "rgb(227, 183, 46)",
|
|
333
|
-
via_micro: "rgb(0, 132, 132)",
|
|
334
|
-
via_through: "rgb(236, 236, 236)",
|
|
335
|
-
worksheet: "rgb(200, 114, 171)"
|
|
336
|
-
},
|
|
337
|
-
gerbview: {
|
|
338
|
-
axes: "rgb(0, 0, 132)",
|
|
339
|
-
background: "rgb(0, 0, 0)",
|
|
340
|
-
dcodes: "rgb(255, 255, 255)",
|
|
341
|
-
grid: "rgb(132, 132, 132)",
|
|
342
|
-
layers: [
|
|
343
|
-
"rgb(132, 0, 0)",
|
|
344
|
-
"rgb(194, 194, 0)",
|
|
345
|
-
"rgb(194, 0, 194)",
|
|
346
|
-
"rgb(194, 0, 0)",
|
|
347
|
-
"rgb(0, 132, 132)",
|
|
348
|
-
"rgb(0, 132, 0)",
|
|
349
|
-
"rgb(0, 0, 132)",
|
|
350
|
-
"rgb(132, 132, 132)",
|
|
351
|
-
"rgb(132, 0, 132)",
|
|
352
|
-
"rgb(194, 194, 194)",
|
|
353
|
-
"rgb(132, 0, 132)",
|
|
354
|
-
"rgb(132, 0, 0)",
|
|
355
|
-
"rgb(132, 132, 0)",
|
|
356
|
-
"rgb(194, 194, 194)",
|
|
357
|
-
"rgb(0, 0, 132)",
|
|
358
|
-
"rgb(0, 132, 0)",
|
|
359
|
-
"rgb(132, 0, 0)",
|
|
360
|
-
"rgb(194, 194, 0)",
|
|
361
|
-
"rgb(194, 0, 194)",
|
|
362
|
-
"rgb(194, 0, 0)",
|
|
363
|
-
"rgb(0, 132, 132)",
|
|
364
|
-
"rgb(0, 132, 0)",
|
|
365
|
-
"rgb(0, 0, 132)",
|
|
366
|
-
"rgb(132, 132, 132)",
|
|
367
|
-
"rgb(132, 0, 132)",
|
|
368
|
-
"rgb(194, 194, 194)",
|
|
369
|
-
"rgb(132, 0, 132)",
|
|
370
|
-
"rgb(132, 0, 0)",
|
|
371
|
-
"rgb(132, 132, 0)",
|
|
372
|
-
"rgb(194, 194, 194)",
|
|
373
|
-
"rgb(0, 0, 132)",
|
|
374
|
-
"rgb(0, 132, 0)",
|
|
375
|
-
"rgb(132, 0, 0)",
|
|
376
|
-
"rgb(194, 194, 0)",
|
|
377
|
-
"rgb(194, 0, 194)",
|
|
378
|
-
"rgb(194, 0, 0)",
|
|
379
|
-
"rgb(0, 132, 132)",
|
|
380
|
-
"rgb(0, 132, 0)",
|
|
381
|
-
"rgb(0, 0, 132)",
|
|
382
|
-
"rgb(132, 132, 132)",
|
|
383
|
-
"rgb(132, 0, 132)",
|
|
384
|
-
"rgb(194, 194, 194)",
|
|
385
|
-
"rgb(132, 0, 132)",
|
|
386
|
-
"rgb(132, 0, 0)",
|
|
387
|
-
"rgb(132, 132, 0)",
|
|
388
|
-
"rgb(194, 194, 194)",
|
|
389
|
-
"rgb(0, 0, 132)",
|
|
390
|
-
"rgb(0, 132, 0)",
|
|
391
|
-
"rgb(132, 0, 0)",
|
|
392
|
-
"rgb(194, 194, 0)",
|
|
393
|
-
"rgb(194, 0, 194)",
|
|
394
|
-
"rgb(194, 0, 0)",
|
|
395
|
-
"rgb(0, 132, 132)",
|
|
396
|
-
"rgb(0, 132, 0)",
|
|
397
|
-
"rgb(0, 0, 132)",
|
|
398
|
-
"rgb(132, 132, 132)",
|
|
399
|
-
"rgb(132, 0, 132)",
|
|
400
|
-
"rgb(194, 194, 194)",
|
|
401
|
-
"rgb(132, 0, 132)",
|
|
402
|
-
"rgb(132, 0, 0)"
|
|
403
|
-
],
|
|
404
|
-
negative_objects: "rgb(132, 132, 132)",
|
|
405
|
-
worksheet: "rgb(0, 0, 132)"
|
|
406
|
-
},
|
|
407
|
-
palette: [
|
|
408
|
-
"rgb(132, 0, 0)",
|
|
409
|
-
"rgb(194, 194, 0)",
|
|
410
|
-
"rgb(194, 0, 194)",
|
|
411
|
-
"rgb(194, 0, 0)",
|
|
412
|
-
"rgb(0, 132, 132)",
|
|
413
|
-
"rgb(0, 132, 0)",
|
|
414
|
-
"rgb(0, 0, 132)",
|
|
415
|
-
"rgb(132, 132, 132)",
|
|
416
|
-
"rgb(132, 0, 132)",
|
|
417
|
-
"rgb(194, 194, 194)",
|
|
418
|
-
"rgb(132, 0, 132)",
|
|
419
|
-
"rgb(132, 0, 0)",
|
|
420
|
-
"rgb(132, 132, 0)",
|
|
421
|
-
"rgb(194, 194, 194)",
|
|
422
|
-
"rgb(0, 0, 132)",
|
|
423
|
-
"rgb(0, 132, 0)"
|
|
424
|
-
],
|
|
425
|
-
schematic: {
|
|
426
|
-
anchor: "rgb(0, 0, 255)",
|
|
427
|
-
aux_items: "rgb(0, 0, 0)",
|
|
428
|
-
background: "rgb(33, 33, 33)",
|
|
429
|
-
brightened: "rgb(204, 204, 204)",
|
|
430
|
-
bus: "rgb(0, 96, 192)",
|
|
431
|
-
bus_junction: "rgb(0, 96, 192)",
|
|
432
|
-
component_body: "rgb(44, 44, 44)",
|
|
433
|
-
component_outline: "rgb(192, 0, 0)",
|
|
434
|
-
cursor: "rgb(224, 224, 224)",
|
|
435
|
-
erc_error: "rgba(192, 48, 48, 0.800)",
|
|
436
|
-
erc_warning: "rgba(192, 140, 0, 0.800)",
|
|
437
|
-
fields: "rgb(128, 0, 160)",
|
|
438
|
-
grid: "rgb(60, 60, 60)",
|
|
439
|
-
grid_axes: "rgb(60, 60, 60)",
|
|
440
|
-
hidden: "rgb(194, 194, 194)",
|
|
441
|
-
junction: "rgb(0, 160, 0)",
|
|
442
|
-
label_global: "rgb(0, 160, 224)",
|
|
443
|
-
label_hier: "rgb(160, 160, 0)",
|
|
444
|
-
label_local: "rgb(192, 192, 192)",
|
|
445
|
-
net_name: "rgb(224, 224, 224)",
|
|
446
|
-
no_connect: "rgb(97, 43, 224)",
|
|
447
|
-
note: "rgb(192, 192, 0)",
|
|
448
|
-
override_item_colors: false,
|
|
449
|
-
pin: "rgb(192, 0, 0)",
|
|
450
|
-
pin_name: "rgb(192, 192, 192)",
|
|
451
|
-
pin_number: "rgb(192, 0, 0)",
|
|
452
|
-
reference: "rgb(192, 192, 192)",
|
|
453
|
-
shadow: "rgba(102, 179, 255, 0.800)",
|
|
454
|
-
sheet: "rgb(128, 0, 160)",
|
|
455
|
-
sheet_background: "rgba(255, 255, 255, 0.000)",
|
|
456
|
-
sheet_fields: "rgb(160, 160, 0)",
|
|
457
|
-
sheet_filename: "rgb(160, 160, 0)",
|
|
458
|
-
sheet_label: "rgb(160, 160, 0)",
|
|
459
|
-
sheet_name: "rgb(0, 160, 204)",
|
|
460
|
-
value: "rgb(192, 192, 192)",
|
|
461
|
-
wire: "rgb(0, 160, 0)",
|
|
462
|
-
worksheet: "rgb(192, 0, 0)"
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
// src/lib/Drawer.ts
|
|
467
|
-
var LAYER_NAME_TO_COLOR = {
|
|
468
|
-
red: "red",
|
|
469
|
-
black: "black",
|
|
470
|
-
green: "green",
|
|
471
|
-
top: colors_default.board.copper.f,
|
|
472
|
-
keepout: colors_default.board.background,
|
|
473
|
-
tkeepout: colors_default.board.b_crtyd,
|
|
474
|
-
tplace: colors_default.board.b_silks,
|
|
475
|
-
...colors_default.board
|
|
476
|
-
};
|
|
477
|
-
var Drawer = class {
|
|
478
|
-
constructor(canvas) {
|
|
479
|
-
this.canvas = canvas;
|
|
480
|
-
this.canvas = canvas;
|
|
481
|
-
this.ctx = canvas.getContext("2d");
|
|
482
|
-
this.transform = (0, import_transformation_matrix2.identity)();
|
|
483
|
-
this.transform.d *= -1;
|
|
484
|
-
this.transform = (0, import_transformation_matrix2.compose)(this.transform, (0, import_transformation_matrix2.translate)(0, -500));
|
|
485
|
-
}
|
|
486
|
-
clear() {
|
|
487
|
-
const { ctx, canvas } = this;
|
|
488
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
489
|
-
}
|
|
490
|
-
equip(aperature) {
|
|
491
|
-
this.aperture = {
|
|
492
|
-
fontSize: 0,
|
|
493
|
-
shape: "circle",
|
|
494
|
-
mode: "add",
|
|
495
|
-
size: 0,
|
|
496
|
-
color: "red",
|
|
497
|
-
...aperature
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
rect(x, y, w, h) {
|
|
501
|
-
const [x1$, y1$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x - w / 2, y - h / 2]);
|
|
502
|
-
const [x2$, y2$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x + w / 2, y + h / 2]);
|
|
503
|
-
this.applyAperture();
|
|
504
|
-
this.ctx.fillRect(x1$, y1$, x2$ - x1$, y2$ - y1$);
|
|
505
|
-
}
|
|
506
|
-
circle(x, y, r) {
|
|
507
|
-
const r$ = scaleOnly(this.transform, r);
|
|
508
|
-
const [x$, y$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x, y]);
|
|
509
|
-
this.applyAperture();
|
|
510
|
-
this.ctx.beginPath();
|
|
511
|
-
this.ctx.arc(x$, y$, r$, 0, 2 * Math.PI);
|
|
512
|
-
this.ctx.fill();
|
|
513
|
-
this.ctx.closePath();
|
|
514
|
-
}
|
|
515
|
-
debugText(text, x, y) {
|
|
516
|
-
const [x$, y$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x, y]);
|
|
517
|
-
this.applyAperture();
|
|
518
|
-
this.ctx.font = `10px sans-serif`;
|
|
519
|
-
this.ctx.fillText(text, x$, y$);
|
|
520
|
-
}
|
|
521
|
-
applyAperture() {
|
|
522
|
-
const { ctx, transform, aperture } = this;
|
|
523
|
-
const { size, mode, color, fontSize } = aperture;
|
|
524
|
-
ctx.lineWidth = scaleOnly(transform, size);
|
|
525
|
-
ctx.lineCap = "round";
|
|
526
|
-
if (mode === "add") {
|
|
527
|
-
let colorString = color[0] === "#" || color.startsWith("rgb") ? color : LAYER_NAME_TO_COLOR[color.toLowerCase()] ? LAYER_NAME_TO_COLOR[color.toLowerCase()] : null;
|
|
528
|
-
if (colorString === null) {
|
|
529
|
-
console.warn(`Color mapping for "${color}" not found`);
|
|
530
|
-
colorString = "white";
|
|
531
|
-
}
|
|
532
|
-
ctx.fillStyle = colorString;
|
|
533
|
-
ctx.strokeStyle = colorString;
|
|
534
|
-
} else {
|
|
535
|
-
ctx.globalCompositeOperation = "destination-out";
|
|
536
|
-
ctx.fillStyle = "rgba(0,0,0,1)";
|
|
537
|
-
ctx.strokeStyle = "rgba(0,0,0,1)";
|
|
538
|
-
}
|
|
539
|
-
ctx.font = `${scaleOnly((0, import_transformation_matrix2.inverse)(transform), fontSize)}px sans-serif`;
|
|
540
|
-
}
|
|
541
|
-
moveTo(x, y) {
|
|
542
|
-
this.lastPoint = { x, y };
|
|
543
|
-
}
|
|
544
|
-
lineTo(x, y) {
|
|
545
|
-
const [x$, y$] = (0, import_transformation_matrix2.applyToPoint)(this.transform, [x, y]);
|
|
546
|
-
const { size, shape, mode } = this.aperture;
|
|
547
|
-
const size$ = scaleOnly(this.transform, size);
|
|
548
|
-
let { lastPoint, ctx } = this;
|
|
549
|
-
const lastPoint$ = (0, import_transformation_matrix2.applyToPoint)(this.transform, lastPoint);
|
|
550
|
-
this.applyAperture();
|
|
551
|
-
if (shape === "square")
|
|
552
|
-
ctx.fillRect(
|
|
553
|
-
lastPoint$.x - size$ / 2,
|
|
554
|
-
lastPoint$.y - size$ / 2,
|
|
555
|
-
size$,
|
|
556
|
-
size$
|
|
557
|
-
);
|
|
558
|
-
ctx.beginPath();
|
|
559
|
-
ctx.moveTo(lastPoint$.x, lastPoint$.y);
|
|
560
|
-
ctx.lineTo(x$, y$);
|
|
561
|
-
ctx.stroke();
|
|
562
|
-
ctx.closePath();
|
|
563
|
-
if (shape === "square")
|
|
564
|
-
ctx.fillRect(x$ - size$ / 2, y$ - size$ / 2, size$, size$);
|
|
565
|
-
this.lastPoint = { x, y };
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
// src/pages/primitives.tsx
|
|
570
|
-
var primitives_default = () => {
|
|
571
|
-
const ref = (0, import_react.useRef)();
|
|
572
|
-
let [width, height] = [500, 500];
|
|
573
|
-
(0, import_react.useEffect)(() => {
|
|
574
|
-
const drawer = new Drawer(ref.current);
|
|
575
|
-
drawer.clear();
|
|
576
|
-
drawGrid(drawer, {
|
|
577
|
-
spacing: 100,
|
|
578
|
-
view_window: { left: 0, bottom: 0, right: width, top: height }
|
|
579
|
-
});
|
|
580
|
-
drawPrimitives(drawer, [
|
|
581
|
-
{
|
|
582
|
-
pcb_drawing_type: "circle",
|
|
583
|
-
x: 100,
|
|
584
|
-
y: 100,
|
|
585
|
-
r: 50,
|
|
586
|
-
layer: { name: "top" }
|
|
587
|
-
},
|
|
588
|
-
{
|
|
589
|
-
pcb_drawing_type: "rect",
|
|
590
|
-
x: 100,
|
|
591
|
-
y: 270,
|
|
592
|
-
w: 100,
|
|
593
|
-
h: 100,
|
|
594
|
-
layer: { name: "top" }
|
|
595
|
-
},
|
|
596
|
-
{
|
|
597
|
-
pcb_drawing_type: "text",
|
|
598
|
-
x: 50,
|
|
599
|
-
y: 210,
|
|
600
|
-
size: 45,
|
|
601
|
-
text: "Hello World1",
|
|
602
|
-
layer: { name: "top" }
|
|
603
|
-
},
|
|
604
|
-
{
|
|
605
|
-
pcb_drawing_type: "line",
|
|
606
|
-
x1: 0,
|
|
607
|
-
y1: 500,
|
|
608
|
-
x2: 100,
|
|
609
|
-
y2: 400,
|
|
610
|
-
width: 10,
|
|
611
|
-
layer: { name: "top" }
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
pcb_drawing_type: "line",
|
|
615
|
-
x1: 0,
|
|
616
|
-
y1: 400,
|
|
617
|
-
x2: 100,
|
|
618
|
-
y2: 450,
|
|
619
|
-
width: 10,
|
|
620
|
-
squareCap: true,
|
|
621
|
-
layer: { name: "top" }
|
|
622
|
-
}
|
|
623
|
-
]);
|
|
624
|
-
}, []);
|
|
625
|
-
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
626
|
-
style: { backgroundColor: "black" }
|
|
627
|
-
}, /* @__PURE__ */ import_react.default.createElement("canvas", {
|
|
628
|
-
ref,
|
|
629
|
-
width,
|
|
630
|
-
height
|
|
631
|
-
}));
|
|
632
|
-
};
|
|
633
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
634
|
-
0 && (module.exports = {});
|
|
635
|
-
//# sourceMappingURL=primitives.js.map
|