diff --git a/DOCS/DEV_LOG.md b/DOCS/DEV_LOG.md index 5db934d..69f3b36 100644 --- a/DOCS/DEV_LOG.md +++ b/DOCS/DEV_LOG.md @@ -1,5 +1,31 @@ # DEV LOG +### April 10, 2024 + +Changes to make + +- change net list structure +- draw rats nest +- change layer object to layer list +- make components and wire directly manipulable + - maybe should verify structure of data in specific spot (new PCB({...})) +- no ids when not passed +- remove wire list +- make layer order match code and ui + +- update examples +- update footprint structure + - { pads: {...} } + - maybe should be list of pads so they don't need names/ids + +- convert board into a footprint + - how to determine what is a pad and what is just a shape + + +### April 4, 2024 + +updated examples to use id instead of label + ### Aug 21, 2023 layer menu gives options from all layers in board diff --git a/examples/USB-FT230XS-UPDI.js b/examples/USB-FT230XS-UPDI.js index ce64bb4..2769f04 100644 --- a/examples/USB-FT230XS-UPDI.js +++ b/examples/USB-FT230XS-UPDI.js @@ -30,25 +30,25 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(FT230XS, {translate: pt(x+width/2.0, y+.7), label: 'IC1\nFT230XS'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("CB3")+.1, IC1.posY), rotate: 90, label: 'C1\n1uF'}); -let J1 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+.29), rotate: -90, label: 'J1 USB\n'}); -let R1 = board.add(R_1206, {translate: pt(IC1.posX+.05, IC1.posY-.22), rotate: 90, label: 'R1\n49'}); -let R2 = board.add(R_1206, {translate: pt(IC1.posX-.05, R1.posY), rotate: 90, label: 'R2\n49'}); -let C2 = board.add(C_1206, {translate: pt(J1.padX("5V")+.065, R1.posY), label: 'C2\n10pF'}); -let C3 = board.add(C_1206, {translate: pt(J1.padX("GND")-.065, R1.posY), label: 'C3\n10pF'}); -let J2 = board.add(header_UPDI_reverse, {translate: pt(IC1.posX, y+height-.23), rotate: -90, label: 'J2\nUPDI'}); -let R3 = board.add(R_1206, {translate: pt(IC1.padX("TXD")-.1, IC1.padY("TXD")+.05), rotate: 90, label: 'R3\n4.99k'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(FT230XS, {translate: pt(x+width/2.0, y+.7), id: 'IC1\nFT230XS'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("CB3")+.1, IC1.posY), rotate: 90, id: 'C1\n1uF'}); +let J1 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+.29), rotate: -90, id: 'J1 USB\n'}); +let R1 = board.add(R_1206, {translate: pt(IC1.posX+.05, IC1.posY-.22), rotate: 90, id: 'R1\n49'}); +let R2 = board.add(R_1206, {translate: pt(IC1.posX-.05, R1.posY), rotate: 90, id: 'R2\n49'}); +let C2 = board.add(C_1206, {translate: pt(J1.padX("5V")+.065, R1.posY), id: 'C2\n10pF'}); +let C3 = board.add(C_1206, {translate: pt(J1.padX("GND")-.065, R1.posY), id: 'C3\n10pF'}); +let J2 = board.add(header_UPDI_reverse, {translate: pt(IC1.posX, y+height-.23), rotate: -90, id: 'J2\nUPDI'}); +let R3 = board.add(R_1206, {translate: pt(IC1.padX("TXD")-.1, IC1.padY("TXD")+.05), rotate: 90, id: 'R3\n4.99k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J1.posX, 5.12+J1.posY]), -90.00000001, J1.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J1.posX, -5.12+J1.posY]), -90.00000001, J1.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J1.posX, 5.12+J1.posY]), -90.00000001, J1.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J1.posX, -5.12+J1.posY]), -90.00000001, J1.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -174,7 +174,7 @@ board.wire(path([C3.posX, IC1.padY("GND1")-.003], renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -186,5 +186,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/USB-FT230XS-serial.js b/examples/USB-FT230XS-serial.js index 49f3b89..89e4a99 100644 --- a/examples/USB-FT230XS-serial.js +++ b/examples/USB-FT230XS-serial.js @@ -30,24 +30,24 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(FT230XS, {translate: pt(x+width/2.0, y+.7), label: 'IC1\nFT230XS'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("CB3")+.1, IC1.posY), rotate: 90, label: 'C1\n1uF'}); -let J1 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+.29), rotate: -90, label: 'J1 USB\n'}); -let R1 = board.add(R_1206, {translate: pt(IC1.posX+.05, IC1.posY-.22), rotate: 90, label: 'R1\n49'}); -let R2 = board.add(R_1206, {translate: pt(IC1.posX-.05, R1.posY), rotate: 90, label: 'R2\n49'}); -let C2 = board.add(C_1206, {translate: pt(J1.padX("5V")+.065, R1.posY), label: 'C2\n10pF'}); -let C3 = board.add(C_1206, {translate: pt(J1.padX("GND")-.065, R1.posY), label: 'C3\n10pF'}); -let J2 = board.add(header_serial_reverse, {translate: pt(IC1.posX, y+height-.23), rotate: 90, label: 'J2\nserial'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(FT230XS, {translate: pt(x+width/2.0, y+.7), id: 'IC1\nFT230XS'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("CB3")+.1, IC1.posY), rotate: 90, id: 'C1\n1uF'}); +let J1 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+.29), rotate: -90, id: 'J1 USB\n'}); +let R1 = board.add(R_1206, {translate: pt(IC1.posX+.05, IC1.posY-.22), rotate: 90, id: 'R1\n49'}); +let R2 = board.add(R_1206, {translate: pt(IC1.posX-.05, R1.posY), rotate: 90, id: 'R2\n49'}); +let C2 = board.add(C_1206, {translate: pt(J1.padX("5V")+.065, R1.posY), id: 'C2\n10pF'}); +let C3 = board.add(C_1206, {translate: pt(J1.padX("GND")-.065, R1.posY), id: 'C3\n10pF'}); +let J2 = board.add(header_serial_reverse, {translate: pt(IC1.posX, y+height-.23), rotate: 90, id: 'J2\nserial'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J1.posX, 5.12+J1.posY]), -90.00000001, J1.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J1.posX, -5.12+J1.posY]), -90.00000001, J1.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J1.posX, 5.12+J1.posY]), -90.00000001, J1.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J1.posX, -5.12+J1.posY]), -90.00000001, J1.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -178,7 +178,7 @@ board.wire(path(J2.pad("Rx"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -190,5 +190,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/crown.js b/examples/crown.js index f487b9c..a7d596d 100644 --- a/examples/crown.js +++ b/examples/crown.js @@ -102,7 +102,7 @@ if (do_holes) { } } -board.addShape("interior", crown); +board.addShape("outline", crown); let copper = structuredClone(crown); @@ -124,25 +124,25 @@ geo.difference(copper, middle_band); board.addShape("F.Cu", copper); /* -- ADD_COMPONENTS -- */ -let R10 = board.add(R_1206, { translate: pt(-0.023, 0.521), rotate: -90, name: "R10" }) -let LED4 = board.add(LED_1206, { translate: pt(-0.337, 0.218), rotate: 0, name: "LED4" }) -let LED5 = board.add(LED_1206, { translate: pt(0.279, 0.224), rotate: 0, name: "LED5" }) -let R7 = board.add(R_1206, { translate: pt(0.068, 0.523), rotate: -90, name: "R7" }) -let R9 = board.add(R_1206, { translate: pt(0.154, 0.524), rotate: -90, name: "R9" }) - -let R8 = board.add(R_1206, { translate: pt(0.333, 0.723), rotate: 0, name: "R8" }) -let PT = board.add(phototransistor_1206, { translate: pt(-0.396, 0.892), rotate: 180, name: "photo" }) -let J2 = board.add(USB_A_plug, { translate: pt(0, 2.45), rotate: 90, name: "USB" }) -let IC1 = board.add(SAMD21E, { translate: pt(-0.01, 0.879), rotate: 0, name: "D21E", padLabelSize: 0.0109 }) -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("DIO")+.34), rotate: -90, name: 'J1 SWD'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND2"), IC1.padY("A27")+0.15), name: 'C1 1uF'}); -let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-0.015, IC1.padY("VAN")-0.116), rotate: 90, name: 'C2\n1uF'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-0.157, C2.posY), rotate: -90, name: 'IC2\n3.3V'}); -let LED1 = board.add(LED_1206, { translate: pt(-3.252, 0.452), rotate: -90, name: "LED1" }) -let LED2 = board.add(LED_1206, { translate: pt(0.257, 1.947), rotate: 90, name: "LED2" }) -let R2 = board.add(R_1206, { translate: pt(0.337, 0.894), rotate: 0, name: "R2" }) -let LED3 = board.add(LED_1206, { translate: pt(3.27, 0.44), rotate: 270, name: "LED3" }) -let R5 = board.add(R_1206, { translate: pt(-0.339, 1.04), rotate: 270, name: "R5" }) +let R10 = board.add(R_1206, { translate: pt(-0.023, 0.521), rotate: -90, id: "R10" }) +let LED4 = board.add(LED_1206, { translate: pt(-0.337, 0.218), rotate: 0, id: "LED4" }) +let LED5 = board.add(LED_1206, { translate: pt(0.279, 0.224), rotate: 0, id: "LED5" }) +let R7 = board.add(R_1206, { translate: pt(0.068, 0.523), rotate: -90, id: "R7" }) +let R9 = board.add(R_1206, { translate: pt(0.154, 0.524), rotate: -90, id: "R9" }) + +let R8 = board.add(R_1206, { translate: pt(0.333, 0.723), rotate: 0, id: "R8" }) +let PT = board.add(phototransistor_1206, { translate: pt(-0.396, 0.892), rotate: 180, id: "photo" }) +let J2 = board.add(USB_A_plug, { translate: pt(0, 2.45), rotate: 90, id: "USB" }) +let IC1 = board.add(SAMD21E, { translate: pt(-0.01, 0.879), rotate: 0, id: "D21E", padLabelSize: 0.0109 }) +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("DIO")+.34), rotate: -90, id: 'J1 SWD'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND2"), IC1.padY("A27")+0.15), id: 'C1 1uF'}); +let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-0.015, IC1.padY("VAN")-0.116), rotate: 90, id: 'C2\n1uF'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-0.157, C2.posY), rotate: -90, id: 'IC2\n3.3V'}); +let LED1 = board.add(LED_1206, { translate: pt(-3.252, 0.452), rotate: -90, id: "LED1" }) +let LED2 = board.add(LED_1206, { translate: pt(0.257, 1.947), rotate: 90, id: "LED2" }) +let R2 = board.add(R_1206, { translate: pt(0.337, 0.894), rotate: 0, id: "R2" }) +let LED3 = board.add(LED_1206, { translate: pt(3.27, 0.44), rotate: 270, id: "LED3" }) +let R5 = board.add(R_1206, { translate: pt(-0.339, 1.04), rotate: 270, id: "R5" }) @@ -155,7 +155,7 @@ let USB_rect = geo.path([[-w_USB/2, -0.2], geo.translate(USB_rect, J2.pos); -board.addShape("interior", USB_rect); +board.addShape("outline", USB_rect); /* -- ADD_WIRES -- */ board.wire(path( @@ -454,7 +454,7 @@ renderPCB({ //"F.Cu": "#ffffffff", - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#ff8c00cc", "drill": "#ffffffff", @@ -465,5 +465,5 @@ renderPCB({ x: [-width/2, width/2], y: [-lip, height] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }); diff --git a/examples/fablab_bezier.js b/examples/fablab_bezier.js index 6b55866..2e514e8 100644 --- a/examples/fablab_bezier.js +++ b/examples/fablab_bezier.js @@ -50,19 +50,19 @@ const border = 0 // rendering border let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let R1 = board.add(R_1206, { translate: pt(-0.02482028, -0.8121274), rotate: 24, name: "R1" }) -let LED1 = board.add(LED_1206, { translate: pt(-0.19264138, -0.81919355), rotate: 295, name: "LED1" }) +let R1 = board.add(R_1206, { translate: pt(-0.02482028, -0.8121274), rotate: 24, id: "R1" }) +let LED1 = board.add(LED_1206, { translate: pt(-0.19264138, -0.81919355), rotate: 295, id: "LED1" }) let fab = board.add(test_fablab, { translate: pt(-0.81171559, -0.57349695)}); -let IC1 = board.add(SAMD11C, {translate: pt(-0.04403899, -0.31184937), name: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+0, IC1.padY("CLK")-0.15), name: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(-0.05916114, 0.01358479), rotate: 90, name: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.15, IC1.padY("A08")-.005), rotate: 90, name: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-0.2), rotate: 90, name: 'C1\n1uF'}); +let IC1 = board.add(SAMD11C, {translate: pt(-0.04403899, -0.31184937), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+0, IC1.padY("CLK")-0.15), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(-0.05916114, 0.01358479), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.15, IC1.padY("A08")-.005), rotate: 90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-0.2), rotate: 90, id: 'C1\n1uF'}); -let interior = geo.translate(geo.rectangle(0.48, 0.58), [J2.posX, J2.posY]); +let outline = geo.translate(geo.rectangle(0.48, 0.58), [J2.posX, J2.posY]); -let interior2 = path([-0.2, -0.04], +let outline2 = path([-0.2, -0.04], ["bezier", [-2.6, -0.04], [0.47, 0.17], [-4.86, -3.23], @@ -72,8 +72,8 @@ let interior2 = path([-0.2, -0.04], [0.2, -0.04]], [0.2, -0.04]); -board.addShape("interior", interior); -board.addShape("interior", interior2); +board.addShape("outline", outline); +board.addShape("outline", outline2); /* -- ADD_WIRES -- */ board.wire(path(J1.pad("CLK"), @@ -175,7 +175,7 @@ board.wire(path(J2.pad("5V"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#ff8c00cc", "drill": "#ff3300e5", @@ -186,5 +186,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.128DB32.echo.js b/examples/hello.128DB32.echo.js index 8bb48ea..3e7a134 100644 --- a/examples/hello.128DB32.echo.js +++ b/examples/hello.128DB32.echo.js @@ -28,19 +28,19 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(AVRDB32, {translate: pt(x+.56, y+.38), label: 'IC1\n128DB32'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.03), rotate: 180, label: 'J1\nserial\n5V'}); -let J2 = board.add(header_UPDI, {translate: pt(x+width-.23, IC1.posY+.23), rotate: 180, label: 'J2\nUPDI'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("VIO2"), IC1.posY-.28), label: 'C1 1uF'}); -let C2 = board.add(C_1206, {translate: pt(IC1.posX+.32, IC1.padY("AVDD")), rotate: 90, label: 'C2\n1uF'}); -let C3 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY+.35), label: 'C3 1uF'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(AVRDB32, {translate: pt(x+.56, y+.38), id: 'IC1\n128DB32'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.03), rotate: 180, id: 'J1\nserial\n5V'}); +let J2 = board.add(header_UPDI, {translate: pt(x+width-.23, IC1.posY+.23), rotate: 180, id: 'J2\nUPDI'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("VIO2"), IC1.posY-.28), id: 'C1 1uF'}); +let C2 = board.add(C_1206, {translate: pt(IC1.posX+.32, IC1.padY("AVDD")), rotate: 90, id: 'C2\n1uF'}); +let C3 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY+.35), id: 'C3 1uF'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -122,7 +122,7 @@ board.wire(path(C3.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -134,5 +134,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.CMM-4030D-261-I2S-TR.t1614.js b/examples/hello.CMM-4030D-261-I2S-TR.t1614.js index d397ee8..0b77607 100644 --- a/examples/hello.CMM-4030D-261-I2S-TR.t1614.js +++ b/examples/hello.CMM-4030D-261-I2S-TR.t1614.js @@ -31,22 +31,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny1614, {translate: pt(x+.57, y+.55), label: 'IC1\nt1614'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY), rotate: 180, label: 'J1\nFTDI'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(J1.posX, J1.padY("GND")-.13), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX+.15, IC2.posY), rotate: 90, label: 'C1\n1uF'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let IC3 = board.add(CMM4030D261I2STR, {translate: pt(IC1.posX+.26, IC1.posY-.014), label: 'I2S'}); -let C2 = board.add(C_1206, {translate: pt(IC3.posX+.04, IC3.posY-.15), label: 'C2 .1u'}); -let C3 = board.add(C_1206, {translate: pt(C2.posX, C2.posY-.1), label: 'C3 10u'}); -let R1 = board.add(R_1206, {translate: pt(J2.posX+.145, J2.posY+.02), rotate: 90, label: 'R1\n100k'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny1614, {translate: pt(x+.57, y+.55), id: 'IC1\nt1614'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY), rotate: 180, id: 'J1\nFTDI'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(J1.posX, J1.padY("GND")-.13), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX+.15, IC2.posY), rotate: 90, id: 'C1\n1uF'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let IC3 = board.add(CMM4030D261I2STR, {translate: pt(IC1.posX+.26, IC1.posY-.014), id: 'I2S'}); +let C2 = board.add(C_1206, {translate: pt(IC3.posX+.04, IC3.posY-.15), id: 'C2 .1u'}); +let C3 = board.add(C_1206, {translate: pt(C2.posX, C2.posY-.1), id: 'C3 10u'}); +let R1 = board.add(R_1206, {translate: pt(J2.posX+.145, J2.posY+.02), rotate: 90, id: 'R1\n100k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -163,7 +163,7 @@ board.wire(path(IC3.pad("SD"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -175,5 +175,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.CMSIS-DAP.10.D11C.js b/examples/hello.CMSIS-DAP.10.D11C.js index 203c1a3..48fbb05 100644 --- a/examples/hello.CMSIS-DAP.10.D11C.js +++ b/examples/hello.CMSIS-DAP.10.D11C.js @@ -30,23 +30,23 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.58, y+.55), label: 'IC1\nD11'}); -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("CLK")-.2), rotate: 90, label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.39, IC1.padY("CLK")-.06), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); -let R1 = board.add(R_1206, {translate: pt(J1.padX("VCC")+.07, J1.posY), rotate: 90, label: 'R1\n0'}); -let J3 = board.add(header_SWD, {translate: pt(IC1.posX-.33, IC1.padY("A09")), rotate: 180, label: 'J3\ntarget'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.58, y+.55), id: 'IC1\nD11'}); +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("CLK")-.2), rotate: 90, id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.39, IC1.padY("CLK")-.06), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); +let R1 = board.add(R_1206, {translate: pt(J1.padX("VCC")+.07, J1.posY), rotate: 90, id: 'R1\n0'}); +let J3 = board.add(header_SWD, {translate: pt(IC1.posX-.33, IC1.padY("A09")), rotate: 180, id: 'J3\ntarget'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -162,7 +162,7 @@ board.wire(path(J3.pad("RST"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -174,5 +174,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.CMSIS-DAP.4.D11C.js b/examples/hello.CMSIS-DAP.4.D11C.js index c6630bf..10f0d19 100644 --- a/examples/hello.CMSIS-DAP.4.D11C.js +++ b/examples/hello.CMSIS-DAP.4.D11C.js @@ -32,24 +32,24 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.57, y+.44), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_05, {translate: pt(IC1.posX, IC1.padY("CLK")-.11), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.39, IC1.padY("CLK")-.05), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX+.04, IC2.posY-.15), rotate: 0, label: 'C1 1uF'}); -let J3 = board.add(header_SWD, {translate: pt(IC1.posX-.37, IC1.padY("A09")-.01), rotate: 180, label: 'J3\ntarget'}); -let R1 = board.add(R_1206, {translate: pt(IC2.posX+.115, IC2.posY), rotate: 90, label: 'R1\n1k'}); -let LED1 = board.add(LED_1206, {translate: pt(R1.posX+.1, R1.posY), rotate: -90, label: 'LED1'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.57, y+.44), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_05, {translate: pt(IC1.posX, IC1.padY("CLK")-.11), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.39, IC1.padY("CLK")-.05), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX+.04, IC2.posY-.15), rotate: 0, id: 'C1 1uF'}); +let J3 = board.add(header_SWD, {translate: pt(IC1.posX-.37, IC1.padY("A09")-.01), rotate: 180, id: 'J3\ntarget'}); +let R1 = board.add(R_1206, {translate: pt(IC2.posX+.115, IC2.posY), rotate: 90, id: 'R1\n1k'}); +let LED1 = board.add(LED_1206, {translate: pt(R1.posX+.1, R1.posY), rotate: -90, id: 'LED1'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -157,7 +157,7 @@ board.wire(path(LED1.pad("C"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -169,5 +169,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.blink.js b/examples/hello.D11C.blink.js index 99f4884..c21be20 100644 --- a/examples/hello.D11C.blink.js +++ b/examples/hello.D11C.blink.js @@ -31,24 +31,24 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.47, y+.55), label: 'IC1\nD11'}); -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("CLK")-.2), rotate: 90, label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.27, IC1.padY("CLK")-.06), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); -let R1 = board.add(R_1206, {translate: pt(J1.padX("VCC")+.07, J1.posY), rotate: 90, label: 'R1\n0'}); -let R2 = board.add(R_1206, {translate: pt(IC1.padX("A08")-.1, IC1.padY("A08")-.03), rotate: 90, label: 'R2\n1k'}); -let LED1 = board.add(LED_1206, {translate: pt(R2.posX-.1, R2.posY), rotate: 90, label: 'LED1'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.47, y+.55), id: 'IC1\nD11'}); +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("CLK")-.2), rotate: 90, id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.27, IC1.padY("CLK")-.06), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); +let R1 = board.add(R_1206, {translate: pt(J1.padX("VCC")+.07, J1.posY), rotate: 90, id: 'R1\n0'}); +let R2 = board.add(R_1206, {translate: pt(IC1.padX("A08")-.1, IC1.padY("A08")-.03), rotate: 90, id: 'R2\n1k'}); +let LED1 = board.add(LED_1206, {translate: pt(R2.posX-.1, R2.posY), rotate: 90, id: 'LED1'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -152,7 +152,7 @@ board.wire(path(LED1.pad("C"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -164,5 +164,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.blink.reset.clock.js b/examples/hello.D11C.blink.reset.clock.js index b45f87a..6851e3e 100644 --- a/examples/hello.D11C.blink.reset.clock.js +++ b/examples/hello.D11C.blink.reset.clock.js @@ -31,27 +31,27 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.62, y+.55), label: 'IC1\nD11'}); -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("CLK")-.2), rotate: 90, label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.42, IC1.padY("CLK")), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); -let R1 = board.add(R_1206, {translate: pt(J1.padX("VCC")+.07, J1.posY), rotate: 90, label: 'R1\n0'}); -let R2 = board.add(R_1206, {translate: pt(IC1.padX("A08")-.15, IC1.padY("A08")-.03), rotate: 90, label: 'R2\n1k'}); -let LED1 = board.add(LED_1206, {translate: pt(R2.posX-.1, R2.posY), rotate: 90, label: 'LED1'}); -let R3 = board.add(R_1206, {translate: pt(J1.posX-.23, J1.posY), label: 'R3 10k'}); -let R4 = board.add(R_1206, {translate: pt(R3.padX("1"), R3.posY+.15), rotate: 90, label: 'R4\n10k'}); -let C2 = board.add(C_1206, {translate: pt(R4.posX-.12, R4.posY), rotate: 90, label: 'C2\n.1uF'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.62, y+.55), id: 'IC1\nD11'}); +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("CLK")-.2), rotate: 90, id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.42, IC1.padY("CLK")), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); +let R1 = board.add(R_1206, {translate: pt(J1.padX("VCC")+.07, J1.posY), rotate: 90, id: 'R1\n0'}); +let R2 = board.add(R_1206, {translate: pt(IC1.padX("A08")-.15, IC1.padY("A08")-.03), rotate: 90, id: 'R2\n1k'}); +let LED1 = board.add(LED_1206, {translate: pt(R2.posX-.1, R2.posY), rotate: 90, id: 'LED1'}); +let R3 = board.add(R_1206, {translate: pt(J1.posX-.23, J1.posY), id: 'R3 10k'}); +let R4 = board.add(R_1206, {translate: pt(R3.padX("1"), R3.posY+.15), rotate: 90, id: 'R4\n10k'}); +let C2 = board.add(C_1206, {translate: pt(R4.posX-.12, R4.posY), rotate: 90, id: 'C2\n.1uF'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -173,7 +173,7 @@ board.wire(path(R4.pad("1"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -185,5 +185,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.blink.reset.js b/examples/hello.D11C.blink.reset.js index 5372e6d..1dba695 100644 --- a/examples/hello.D11C.blink.reset.js +++ b/examples/hello.D11C.blink.reset.js @@ -31,25 +31,25 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.58, y+.39), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_05, {translate: pt(IC1.posX, IC1.padY("CLK")-.11), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.38, IC1.padY("A14")), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); -let C2 = board.add(C_1206, {translate: pt(C1.posX+.12, C1.posY), rotate: 90, label: 'C2\n.1uF'}); -let R1 = board.add(R_1206, {translate: pt(C2.posX+.12, C2.posY), rotate: 90, label: 'R1\n10k'}); -let R2 = board.add(R_1206, {translate: pt(R1.posX-.01, IC1.padY("A08")-.025), rotate: 90, label: 'R2\n1k'}); -let LED1 = board.add(LED_1206, {translate: pt(C2.posX+.01, R2.posY), rotate: 90, label: 'LED1'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.58, y+.39), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_05, {translate: pt(IC1.posX, IC1.padY("CLK")-.11), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.38, IC1.padY("A14")), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); +let C2 = board.add(C_1206, {translate: pt(C1.posX+.12, C1.posY), rotate: 90, id: 'C2\n.1uF'}); +let R1 = board.add(R_1206, {translate: pt(C2.posX+.12, C2.posY), rotate: 90, id: 'R1\n10k'}); +let R2 = board.add(R_1206, {translate: pt(R1.posX-.01, IC1.padY("A08")-.025), rotate: 90, id: 'R2\n1k'}); +let LED1 = board.add(LED_1206, {translate: pt(C2.posX+.01, R2.posY), rotate: 90, id: 'LED1'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -149,7 +149,7 @@ board.wire(path(LED1.pad("C"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -161,5 +161,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.echo.1.js b/examples/hello.D11C.echo.1.js index 57ccf4e..09915d5 100644 --- a/examples/hello.D11C.echo.1.js +++ b/examples/hello.D11C.echo.1.js @@ -31,21 +31,21 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.33, y+height-.63), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width/2, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.15, IC1.padY("A08")-.005), rotate: 90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); +let IC1 = board.add(SAMD11C, {translate: pt(x+.33, y+height-.63), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width/2, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.15, IC1.padY("A08")-.005), rotate: 90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -116,7 +116,7 @@ board.wire(path(J2.pad("5V"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -128,5 +128,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.echo.js b/examples/hello.D11C.echo.js index 5c5e8f4..3c58579 100644 --- a/examples/hello.D11C.echo.js +++ b/examples/hello.D11C.echo.js @@ -30,22 +30,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C_SOIC, {translate: pt(x+.39, y+.55), label: 'IC1\nD11'}); -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("CLK")-.2), rotate: 90, label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.17, J2.posY-.11), rotate: 180, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.12), label: 'C1 1uF'}); -let R1 = board.add(R_1206, {translate: pt(J1.padX("VCC")+.07, J1.posY), rotate: 90, label: '0'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C_SOIC, {translate: pt(x+.39, y+.55), id: 'IC1\nD11'}); +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("CLK")-.2), rotate: 90, id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.17, J2.posY-.11), rotate: 180, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.12), id: 'C1 1uF'}); +let R1 = board.add(R_1206, {translate: pt(J1.padX("VCC")+.07, J1.posY), rotate: 90, id: '0'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -134,7 +134,7 @@ board.wire(path(C1.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -146,5 +146,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.echo.micro.js b/examples/hello.D11C.echo.micro.js index 4818d3c..434960a 100644 --- a/examples/hello.D11C.echo.micro.js +++ b/examples/hello.D11C.echo.micro.js @@ -32,18 +32,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.24, y+height-.44), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), label: 'J1 SWD'}); -let J2 = board.add(USB_micro_Elektronik, {translate: pt(IC1.posX-.028, y+height-.05), rotate: 180, label: 'J2 USB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.18, IC1.padY("A08")-.005), rotate: 90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); +let IC1 = board.add(SAMD11C, {translate: pt(x+.24, y+height-.44), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), id: 'J1 SWD'}); +let J2 = board.add(USB_micro_Elektronik, {translate: pt(IC1.posX-.028, y+height-.05), rotate: 180, id: 'J2 USB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.18, IC1.padY("A08")-.005), rotate: 90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -137,7 +137,7 @@ board.wire(path([IC1.posX-.03, IC1.padY("A04")+.05], renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -149,5 +149,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.echo.mini.js b/examples/hello.D11C.echo.mini.js index 9bd311f..2c74351 100644 --- a/examples/hello.D11C.echo.mini.js +++ b/examples/hello.D11C.echo.mini.js @@ -31,18 +31,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.26, y+height-0.58), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), label: 'J1 SWD'}); -let J2 = board.add(USB_mini_CUI, {translate: pt(IC1.posX-.028, y+height-.05), rotate: 180, label: 'J2 USB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.18, IC1.padY("A08")-.005), rotate: 90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); +let IC1 = board.add(SAMD11C, {translate: pt(x+.26, y+height-0.58), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), id: 'J1 SWD'}); +let J2 = board.add(USB_mini_CUI, {translate: pt(IC1.posX-.028, y+height-.05), rotate: 180, id: 'J2 USB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.18, IC1.padY("A08")-.005), rotate: 90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -119,7 +119,7 @@ board.wire(path(IC1.pad("25+"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -131,5 +131,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.serial.5V.1.1.js b/examples/hello.D11C.serial.5V.1.1.js index 5a67467..b8c5521 100644 --- a/examples/hello.D11C.serial.5V.1.1.js +++ b/examples/hello.D11C.serial.5V.1.1.js @@ -33,25 +33,25 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.45, y+height-.59), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width/2, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let J3 = board.add(header_serial_reverse, {translate: pt(IC1.posX, y+.23), rotate: -90, label: 'J3 serial'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.21, IC1.padY("A09")), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.24), rotate: 90, label: 'C1\n1uF'}); -let R1 = board.add(R_1206, {translate: pt(J3.padX("Rx")-.02, J1.posY-.2), label: 'R1\n0'}); -let R2 = board.add(R_1206, {translate: pt(C1.posX-.03, J3.posY+.18), rotate: 90, label: 'R2\n0'}); -let R3 = board.add(R_1206, {translate: pt(R1.posX-.22, R1.posY), label: 'R3\n4.99k'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.45, y+height-.59), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width/2, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let J3 = board.add(header_serial_reverse, {translate: pt(IC1.posX, y+.23), rotate: -90, id: 'J3 serial'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.21, IC1.padY("A09")), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.24), rotate: 90, id: 'C1\n1uF'}); +let R1 = board.add(R_1206, {translate: pt(J3.padX("Rx")-.02, J1.posY-.2), id: 'R1\n0'}); +let R2 = board.add(R_1206, {translate: pt(C1.posX-.03, J3.posY+.18), rotate: 90, id: 'R2\n0'}); +let R3 = board.add(R_1206, {translate: pt(R1.posX-.22, R1.posY), id: 'R3\n4.99k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -191,7 +191,7 @@ board.wire(path(R3.pad("1"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -203,5 +203,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.serial.5V.2.large.js b/examples/hello.D11C.serial.5V.2.large.js index 1b6b59f..ce1dac9 100644 --- a/examples/hello.D11C.serial.5V.2.large.js +++ b/examples/hello.D11C.serial.5V.2.large.js @@ -33,27 +33,27 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.37, y+height-.63), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width/2, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.17, IC1.padY("A08")-.04), rotate: 90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); -let J3 = board.add(header_serial_reverse, {translate: pt(IC1.posX+.02, y+.23), rotate: -90, label: 'J3 serial'}); -let R1 = board.add(R_1206, {translate: pt(J1.posX-.29, J1.posY), rotate: 90, label: 'R1\n4.99k'}); -let V1 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A14")-.1, IC1.padY("A14")), label: 'V1'}); -let V2 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("CTS")-.025, J3.padY("CTS")-.11), label: 'V2'}); -let V3 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A04")+.1, IC1.padY("A04")), label: 'V3'}); -let V4 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("Tx")+.025, J3.padY("Tx")-.11), label: 'V4'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.37, y+height-.63), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width/2, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.17, IC1.padY("A08")-.04), rotate: 90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); +let J3 = board.add(header_serial_reverse, {translate: pt(IC1.posX+.02, y+.23), rotate: -90, id: 'J3 serial'}); +let R1 = board.add(R_1206, {translate: pt(J1.posX-.29, J1.posY), rotate: 90, id: 'R1\n4.99k'}); +let V1 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A14")-.1, IC1.padY("A14")), id: 'V1'}); +let V2 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("CTS")-.025, J3.padY("CTS")-.11), id: 'V2'}); +let V3 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A04")+.1, IC1.padY("A04")), id: 'V3'}); +let V4 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("Tx")+.025, J3.padY("Tx")-.11), id: 'V4'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -174,7 +174,7 @@ board.wire(path(V3.pad("via"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -186,5 +186,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.serial.5V.2.small.js b/examples/hello.D11C.serial.5V.2.small.js index 522d612..8d877ad 100644 --- a/examples/hello.D11C.serial.5V.2.small.js +++ b/examples/hello.D11C.serial.5V.2.small.js @@ -33,27 +33,27 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.37, y+height-.63), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width/2, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.17, IC1.padY("A08")-.04), rotate: 90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); -let J3 = board.add(header_serial_reverse, {translate: pt(IC1.posX+.02, y+.23), rotate: -90, label: 'J3 serial'}); -let R1 = board.add(R_1206, {translate: pt(J1.posX-.29, J1.posY), rotate: 90, label: 'R1\n4.99k'}); -let V1 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A14")-.1, IC1.padY("A14")), label: 'V1'}); -let V2 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("CTS")-.025, J3.padY("CTS")-.11), label: 'V2'}); -let V3 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A04")+.1, IC1.padY("A04")), label: 'V3'}); -let V4 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("Tx")+.025, J3.padY("Tx")-.11), label: 'V4'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.37, y+height-.63), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX+.015, IC1.padY("CLK")-.14), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width/2, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.17, IC1.padY("A08")-.04), rotate: 90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); +let J3 = board.add(header_serial_reverse, {translate: pt(IC1.posX+.02, y+.23), rotate: -90, id: 'J3 serial'}); +let R1 = board.add(R_1206, {translate: pt(J1.posX-.29, J1.posY), rotate: 90, id: 'R1\n4.99k'}); +let V1 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A14")-.1, IC1.padY("A14")), id: 'V1'}); +let V2 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("CTS")-.025, J3.padY("CTS")-.11), id: 'V2'}); +let V3 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A04")+.1, IC1.padY("A04")), id: 'V3'}); +let V4 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("Tx")+.025, J3.padY("Tx")-.11), id: 'V4'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -174,7 +174,7 @@ board.wire(path(V3.pad("via"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -186,5 +186,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11C.serial.micro.4.js b/examples/hello.D11C.serial.micro.4.js index 0aaa5b3..3b15416 100644 --- a/examples/hello.D11C.serial.micro.4.js +++ b/examples/hello.D11C.serial.micro.4.js @@ -34,21 +34,21 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.36, y+height-.43), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX, IC1.padY("CLK")-.14), label: 'J1 SWD'}); -let J2 = board.add(USB_micro_Elektronik, {translate: pt(IC1.posX, y+height-.05), rotate: 180, label: 'J2\nmicro USB'}); -let J3 = board.add(header_serial_Frev, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J3\nserial F'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.2, IC1.padY("GND")-.01), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.24), rotate: 90, label: 'C1\n1uF'}); -let R3 = board.add(R_1206, {translate: pt(IC2.padX("in"), IC2.padY("in")+.1), label: 'R3 0'}); -let R4 = board.add(R_1206, {translate: pt(J3.padX("G")-.11, J3.posY+.11), rotate: 90, label: 'R4\n4.99k'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.36, y+height-.43), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.posX, IC1.padY("CLK")-.14), id: 'J1 SWD'}); +let J2 = board.add(USB_micro_Elektronik, {translate: pt(IC1.posX, y+height-.05), rotate: 180, id: 'J2\nmicro USB'}); +let J3 = board.add(header_serial_Frev, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J3\nserial F'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.2, IC1.padY("GND")-.01), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.24), rotate: 90, id: 'C1\n1uF'}); +let R3 = board.add(R_1206, {translate: pt(IC2.padX("in"), IC2.padY("in")+.1), id: 'R3 0'}); +let R4 = board.add(R_1206, {translate: pt(J3.padX("G")-.11, J3.posY+.11), rotate: 90, id: 'R4\n4.99k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -164,7 +164,7 @@ board.wire(path(J3.pad("G"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -176,5 +176,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D11D.echo.js b/examples/hello.D11D.echo.js index b33094d..aedf553 100644 --- a/examples/hello.D11D.echo.js +++ b/examples/hello.D11D.echo.js @@ -29,21 +29,21 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11D, {translate: pt(x+.43, y+.73), label: 'IC1\nD11D'}); -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("A23")-.24), rotate: 90, label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.14, IC1.padY("A06")), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, label: 'C1\n1uF'}); +let IC1 = board.add(SAMD11D, {translate: pt(x+.43, y+.73), id: 'IC1\nD11D'}); +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("A23")-.24), rotate: 90, id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.14, IC1.padY("A06")), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.2), rotate: 90, id: 'C1\n1uF'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -136,7 +136,7 @@ board.wire(path(C1.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -148,5 +148,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.D21E.echo.js b/examples/hello.D21E.echo.js index 3bb87b0..bce954e 100644 --- a/examples/hello.D21E.echo.js +++ b/examples/hello.D21E.echo.js @@ -29,22 +29,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD21E, {translate: pt(x+.37, y+.36), label: 'IC1\nD21E'}); -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("DIO")+.34), rotate: -90, label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC1.padY("25+")+.04), label: 'J2 USB'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND2"), IC1.padY("A27")+.15), label: 'C1 1uF'}); -let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-.02, IC1.padY("VAN")-.07), rotate: 90, label: 'C2\n1uF'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-.11, C2.posY), rotate: -90, label: 'IC2\n3.3V'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD21E, {translate: pt(x+.37, y+.36), id: 'IC1\nD21E'}); +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("DIO")+.34), rotate: -90, id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC1.padY("25+")+.04), id: 'J2 USB'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND2"), IC1.padY("A27")+.15), id: 'C1 1uF'}); +let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-.02, IC1.padY("VAN")-.07), rotate: 90, id: 'C2\n1uF'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-.11, C2.posY), rotate: -90, id: 'IC2\n3.3V'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY])); -geo.difference(interior, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY])); +geo.difference(outline, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY])); +geo.difference(outline, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -142,7 +142,7 @@ board.wire(path(IC2.pad("gnd"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -154,5 +154,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.DRV8428-D11C-NEMA17.js b/examples/hello.DRV8428-D11C-NEMA17.js index f04df5e..961ba86 100644 --- a/examples/hello.DRV8428-D11C-NEMA17.js +++ b/examples/hello.DRV8428-D11C-NEMA17.js @@ -39,32 +39,32 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(DRV8428_HTSSOP, {translate: pt(x+.56, y+height/2+.25), label: 'IC1\nDRV8428'}); -let J2 = board.add(header_4H, {translate: pt(x+.23, y+height/2), rotate: 180, label: 'J2\nstepper'}); -let R1 = board.add(ST4EB, {translate: pt(IC1.posX-.05, IC1.posY-.35), label: 'R1\n10k'}); -let C1 = board.add(C_1206, {translate: pt(J2.posX, J2.padY("1")-.16), rotate: 90, label: 'C1\n1uF'}); -let R2 = board.add(R_1206, {translate: pt(R1.padX("1")-.02, R1.posY-.24), rotate: 0, label: 'R2\n10k'}); -let C2 = board.add(C_FND, {translate: pt(IC1.posX+.08, IC1.posY+.27), rotate: 90, label: 'C2\n100uF'}); -let J4 = board.add(header_2H, {translate: pt(x+.23, IC1.padY("VM")+.05), rotate: 180, label: 'J4\npower'}); -let C3 = board.add(C_1206, {translate: pt(C2.posX+.31, C2.posY), label: 'C3\n.01uF'}); -let IC2 = board.add(SAMD11C, {translate: pt(x+width-.62, y+height/2), rotate: -90, label: 'IC2\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC2.padX("CLK")-.14, IC2.posY), rotate: -90, label: 'J1 SWD'}); -let J3 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC2.posY+.025), rotate: 0, label: 'J3\nUSB'}); -let IC3 = board.add(regulator_SOT23, {translate: pt(IC2.padX("DIO")-.1, IC2.padY("24-")-.21), rotate: 0, label: 'IC3\n3.3V'}); -let C4 = board.add(C_1206, {translate: pt(IC3.posX-.22, IC3.posY), label: 'C4\n1uF'}); -let R3 = board.add(R_1206, {translate: pt(C3.posX+.22, C3.posY), label: 'R3\n0'}); -let R4 = board.add(R_1206, {translate: pt(IC2.padX("GND")+.01, IC3.posY+.03), rotate: 0, label: 'R4\n1k'}); -let LED = board.add(LED_1206, {translate: pt(R4.posX, R4.posY-.09), rotate: 180, label: 'LED'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(DRV8428_HTSSOP, {translate: pt(x+.56, y+height/2+.25), id: 'IC1\nDRV8428'}); +let J2 = board.add(header_4H, {translate: pt(x+.23, y+height/2), rotate: 180, id: 'J2\nstepper'}); +let R1 = board.add(ST4EB, {translate: pt(IC1.posX-.05, IC1.posY-.35), id: 'R1\n10k'}); +let C1 = board.add(C_1206, {translate: pt(J2.posX, J2.padY("1")-.16), rotate: 90, id: 'C1\n1uF'}); +let R2 = board.add(R_1206, {translate: pt(R1.padX("1")-.02, R1.posY-.24), rotate: 0, id: 'R2\n10k'}); +let C2 = board.add(C_FND, {translate: pt(IC1.posX+.08, IC1.posY+.27), rotate: 90, id: 'C2\n100uF'}); +let J4 = board.add(header_2H, {translate: pt(x+.23, IC1.padY("VM")+.05), rotate: 180, id: 'J4\npower'}); +let C3 = board.add(C_1206, {translate: pt(C2.posX+.31, C2.posY), id: 'C3\n.01uF'}); +let IC2 = board.add(SAMD11C, {translate: pt(x+width-.62, y+height/2), rotate: -90, id: 'IC2\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC2.padX("CLK")-.14, IC2.posY), rotate: -90, id: 'J1 SWD'}); +let J3 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC2.posY+.025), rotate: 0, id: 'J3\nUSB'}); +let IC3 = board.add(regulator_SOT23, {translate: pt(IC2.padX("DIO")-.1, IC2.padY("24-")-.21), rotate: 0, id: 'IC3\n3.3V'}); +let C4 = board.add(C_1206, {translate: pt(IC3.posX-.22, IC3.posY), id: 'C4\n1uF'}); +let R3 = board.add(R_1206, {translate: pt(C3.posX+.22, C3.posY), id: 'R3\n0'}); +let R4 = board.add(R_1206, {translate: pt(IC2.padX("GND")+.01, IC3.posY+.03), rotate: 0, id: 'R4\n1k'}); +let LED = board.add(LED_1206, {translate: pt(R4.posX, R4.posY-.09), rotate: 180, id: 'LED'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J3.posX, 5.12+J3.posY]), 0.00000001, J3.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J3.posX, -5.12+J3.posY]), 0.00000001, J3.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J3.posX, 5.12+J3.posY]), 0.00000001, J3.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J3.posX, -5.12+J3.posY]), 0.00000001, J3.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -299,7 +299,7 @@ board.wire(path(LED.pad("C"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -311,5 +311,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.DRV8428-D11C.js b/examples/hello.DRV8428-D11C.js index 4badd4a..6da32ef 100644 --- a/examples/hello.DRV8428-D11C.js +++ b/examples/hello.DRV8428-D11C.js @@ -39,32 +39,32 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(DRV8428_HTSSOP, {translate: pt(x+.6, y+.62), label: 'IC1\nDRV8428'}); -let J2 = board.add(header_4H, {translate: pt(x+.23, IC1.posY-.24), rotate: 180, label: 'J2\nstepper'}); -let R1 = board.add(ST4EB, {translate: pt(IC1.posX+.12, IC1.posY-.35), label: 'R1\n10k'}); -let C1 = board.add(C_1206, {translate: pt(R1.posX-.32, J2.padY("1")-.07), rotate: 90, label: 'C1\n1uF'}); -let R2 = board.add(R_1206, {translate: pt(R1.posX-.2, R1.posY+.05), rotate: 90, label: 'R2\n10k'}); -let C2 = board.add(C_FND, {translate: pt(IC1.posX+.04, IC1.posY+.27), rotate: 90, label: 'C2\n100uF'}); -let J4 = board.add(header_2H, {translate: pt(x+.23, IC1.padY("VM")+.05), rotate: 180, label: 'J4\npower'}); -let C3 = board.add(C_1206, {translate: pt(C2.posX+.31, C2.posY), label: 'C3\n.01uF'}); -let IC2 = board.add(SAMD11C, {translate: pt(x+width-.68, y+.45), rotate: -90, label: 'IC2\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC2.padX("CLK")-.14, IC2.posY), rotate: -90, label: 'J1 SWD'}); -let J3 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC2.posY+.025), rotate: 0, label: 'J3\nUSB'}); -let IC3 = board.add(regulator_SOT23, {translate: pt(IC2.padX("A15"), IC2.padY("24-")-.18), rotate: 0, label: 'IC3\n3.3V'}); -let C4 = board.add(C_1206, {translate: pt(IC3.posX-.22, IC3.posY), label: 'C4\n1uF'}); -let R3 = board.add(R_1206, {translate: pt(C3.posX+.22, C3.posY), label: 'R3\n0'}); -let R4 = board.add(R_1206, {translate: pt(IC2.padX("A04")-.04, IC3.posY), rotate: 90, label: 'R4\n1k'}); -let LED = board.add(LED_1206, {translate: pt(R4.posX+.1, R4.posY), rotate: -90, label: 'LED'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(DRV8428_HTSSOP, {translate: pt(x+.6, y+.62), id: 'IC1\nDRV8428'}); +let J2 = board.add(header_4H, {translate: pt(x+.23, IC1.posY-.24), rotate: 180, id: 'J2\nstepper'}); +let R1 = board.add(ST4EB, {translate: pt(IC1.posX+.12, IC1.posY-.35), id: 'R1\n10k'}); +let C1 = board.add(C_1206, {translate: pt(R1.posX-.32, J2.padY("1")-.07), rotate: 90, id: 'C1\n1uF'}); +let R2 = board.add(R_1206, {translate: pt(R1.posX-.2, R1.posY+.05), rotate: 90, id: 'R2\n10k'}); +let C2 = board.add(C_FND, {translate: pt(IC1.posX+.04, IC1.posY+.27), rotate: 90, id: 'C2\n100uF'}); +let J4 = board.add(header_2H, {translate: pt(x+.23, IC1.padY("VM")+.05), rotate: 180, id: 'J4\npower'}); +let C3 = board.add(C_1206, {translate: pt(C2.posX+.31, C2.posY), id: 'C3\n.01uF'}); +let IC2 = board.add(SAMD11C, {translate: pt(x+width-.68, y+.45), rotate: -90, id: 'IC2\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC2.padX("CLK")-.14, IC2.posY), rotate: -90, id: 'J1 SWD'}); +let J3 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC2.posY+.025), rotate: 0, id: 'J3\nUSB'}); +let IC3 = board.add(regulator_SOT23, {translate: pt(IC2.padX("A15"), IC2.padY("24-")-.18), rotate: 0, id: 'IC3\n3.3V'}); +let C4 = board.add(C_1206, {translate: pt(IC3.posX-.22, IC3.posY), id: 'C4\n1uF'}); +let R3 = board.add(R_1206, {translate: pt(C3.posX+.22, C3.posY), id: 'R3\n0'}); +let R4 = board.add(R_1206, {translate: pt(IC2.padX("A04")-.04, IC3.posY), rotate: 90, id: 'R4\n1k'}); +let LED = board.add(LED_1206, {translate: pt(R4.posX+.1, R4.posY), rotate: -90, id: 'LED'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J3.posX, 5.12+J3.posY]), 0.00000001, J3.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J3.posX, -5.12+J3.posY]), 0.00000001, J3.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J3.posX, 5.12+J3.posY]), 0.00000001, J3.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J3.posX, -5.12+J3.posY]), 0.00000001, J3.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -290,7 +290,7 @@ board.wire(path(LED.pad("C"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -302,5 +302,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ESC.44.js b/examples/hello.ESC.44.js index 5518789..74229d8 100644 --- a/examples/hello.ESC.44.js +++ b/examples/hello.ESC.44.js @@ -30,20 +30,20 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.49, y+.59), label: 'IC1\nt44'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, label: 'J1\nISP'}); -let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, label: 'J2 FTDI'}); -let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB3")-.2, IC1.padY("PA0")+.003), rotate: -90, label: 'XTAL1\n20 MHz'}); -let R1 = board.add(R_1206, {translate: pt(IC1.padX("VCC"), IC1.padY("VCC")+.1), label: 'R1\n10k'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND"), R1.posY), label: 'C1\n1uF'}); -let J3 = board.add(ESC, {translate: pt(XTAL1.posX-.02, J1.posY+.025), rotate: 90, label: 'J3 ESC'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.49, y+.59), id: 'IC1\nt44'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, id: 'J1\nISP'}); +let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, id: 'J2 FTDI'}); +let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB3")-.2, IC1.padY("PA0")+.003), rotate: -90, id: 'XTAL1\n20 MHz'}); +let R1 = board.add(R_1206, {translate: pt(IC1.padX("VCC"), IC1.padY("VCC")+.1), id: 'R1\n10k'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND"), R1.posY), id: 'C1\n1uF'}); +let J3 = board.add(ESC, {translate: pt(XTAL1.posX-.02, J1.posY+.025), rotate: 90, id: 'J3 ESC'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -136,7 +136,7 @@ board.wire(path(J1.pad("GND"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -148,5 +148,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ESP-01.js b/examples/hello.ESP-01.js index cce7736..1f261d2 100644 --- a/examples/hello.ESP-01.js +++ b/examples/hello.ESP-01.js @@ -31,22 +31,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+.48), rotate: 0, label: 'J1 serial\n5V power\n3.3V logic'}); -let IC1 = board.add(regulator_SOT223, {translate: pt(J1.posX-.25, J1.posY), label: 'IC1\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY-.25), label: 'C1 10uF'}); -let C2 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY+.25), label: 'C2 1uF'}); -let J2 = board.add(ESP_01, {translate: pt(IC1.posX-.49, IC1.posY), rotate: 180, label: 'J2\nESP-01'}); -let R1 = board.add(R_1206, {translate: pt(J2.padX("EN")+.11, J2.padY("IO0")), rotate: 90, label: 'R1\n10k'}); -let S1 = board.add(button_6mm, {translate: pt(J2.padX("GND")+.12, J2.padY("GND")-.2), label: 'S1\nreset'}); -let S2 = board.add(slide_switch, {translate: pt(S1.posX, J2.padY("VCC")+.21), rotate: 180, label: 'S2\nprog run'}); -let R2 = board.add(R_1206, {translate: pt(J2.padX("IO0")-.11, J2.padY("IO0")), rotate: 90, label: 'R2\n10k'}); - -let interior = geo.path(path([x, y+height], +let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+.48), rotate: 0, id: 'J1 serial\n5V power\n3.3V logic'}); +let IC1 = board.add(regulator_SOT223, {translate: pt(J1.posX-.25, J1.posY), id: 'IC1\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY-.25), id: 'C1 10uF'}); +let C2 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY+.25), id: 'C2 1uF'}); +let J2 = board.add(ESP_01, {translate: pt(IC1.posX-.49, IC1.posY), rotate: 180, id: 'J2\nESP-01'}); +let R1 = board.add(R_1206, {translate: pt(J2.padX("EN")+.11, J2.padY("IO0")), rotate: 90, id: 'R1\n10k'}); +let S1 = board.add(button_6mm, {translate: pt(J2.padX("GND")+.12, J2.padY("GND")-.2), id: 'S1\nreset'}); +let S2 = board.add(slide_switch, {translate: pt(S1.posX, J2.padY("VCC")+.21), rotate: 180, id: 'S2\nprog run'}); +let R2 = board.add(R_1206, {translate: pt(J2.padX("IO0")-.11, J2.padY("IO0")), rotate: 90, id: 'R2\n10k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -152,7 +152,7 @@ board.wire(path(S1.pad("R1"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -164,5 +164,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ESP-WROOM-02D.js b/examples/hello.ESP-WROOM-02D.js index cbf5d05..149fac7 100644 --- a/examples/hello.ESP-WROOM-02D.js +++ b/examples/hello.ESP-WROOM-02D.js @@ -31,22 +31,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+.39), rotate: 0, label: 'J1 serial\n5V power\n3.3V data'}); -let IC1 = board.add(regulator_SOT223, {translate: pt(J1.posX-.2, J1.posY-.05), label: '\nIC1\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY-.25), label: 'C1\n10uF'}); -let C2 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY+.25), label: 'C2\n1uF'}); -let IC2 = board.add(ESP_WROOM_02D, {translate: pt(x+.28, J1.posY+.23), rotate: 90, label: "IC2\n \nESP-WROOM-02D"}); -let S1 = board.add(slide_switch, {translate: pt(IC2.padX("GND1")-.06, y+.06), rotate: 0, label: 'prog run\nS1'}); -let R1 = board.add(R_1206, {translate: pt(IC2.padX("IO12")-.05, IC2.padY("EN")-.15), label: 'R1 10k'}); -let S2 = board.add(button_6mm, {translate: pt(IC2.padX("IO4")+.26, IC2.padY("IO4")-.05), rotate: 0, label: 'S2\nreset'}); -let R2 = board.add(R_1206, {translate: pt(S2.posX+.25, S2.posY-.06), rotate: 90, label: 'R2\n10k'}); - -let interior = geo.path(path([x, y+height], +let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+.39), rotate: 0, id: 'J1 serial\n5V power\n3.3V data'}); +let IC1 = board.add(regulator_SOT223, {translate: pt(J1.posX-.2, J1.posY-.05), id: '\nIC1\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY-.25), id: 'C1\n10uF'}); +let C2 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY+.25), id: 'C2\n1uF'}); +let IC2 = board.add(ESP_WROOM_02D, {translate: pt(x+.28, J1.posY+.23), rotate: 90, id: "IC2\n \nESP-WROOM-02D"}); +let S1 = board.add(slide_switch, {translate: pt(IC2.padX("GND1")-.06, y+.06), rotate: 0, id: 'prog run\nS1'}); +let R1 = board.add(R_1206, {translate: pt(IC2.padX("IO12")-.05, IC2.padY("EN")-.15), id: 'R1 10k'}); +let S2 = board.add(button_6mm, {translate: pt(IC2.padX("IO4")+.26, IC2.padY("IO4")-.05), rotate: 0, id: 'S2\nreset'}); +let R2 = board.add(R_1206, {translate: pt(S2.posX+.25, S2.posY-.06), rotate: 90, id: 'R2\n10k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -162,7 +162,7 @@ board.wire(path(R2.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -174,5 +174,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ESP32-CAM.js b/examples/hello.ESP32-CAM.js index 0bc59f1..36b8902 100644 --- a/examples/hello.ESP32-CAM.js +++ b/examples/hello.ESP32-CAM.js @@ -27,16 +27,16 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+height/2), rotate: 0, label: 'J1 FTDI\n3.3V'}); -let ESP = board.add(ESP32_CAM, {translate: pt(x+.4, y+.74), rotate: -90, label: 'ESP32-CAM'}); -let S1 = board.add(slide_switch, {translate: pt(ESP.padX("IO0"), ESP.padY("IO0")-.19), label: 'prog run'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+height/2), rotate: 0, id: 'J1 FTDI\n3.3V'}); +let ESP = board.add(ESP32_CAM, {translate: pt(x+.4, y+.74), rotate: -90, id: 'ESP32-CAM'}); +let S1 = board.add(slide_switch, {translate: pt(ESP.padX("IO0"), ESP.padY("IO0")-.19), id: 'prog run'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -79,7 +79,7 @@ board.wire(path(S1.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -91,5 +91,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ESP32-WROOM.js b/examples/hello.ESP32-WROOM.js index d0d5a6a..174a169 100644 --- a/examples/hello.ESP32-WROOM.js +++ b/examples/hello.ESP32-WROOM.js @@ -31,22 +31,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+.5), rotate: 0, label: 'J1 FTDI\n3.3V'}); -let IC1 = board.add(regulator_SOT223, {translate: pt(J1.posX-.25, J1.posY), label: 'IC1\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY-.25), label: 'C1 10uF'}); -let C2 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY+.25), label: 'C2 1uF'}); -let IC2 = board.add(ESP32_WROOM, {translate: pt(x+.35, y+.69), rotate: 90, label: 'IC2\nESP32-WROOM'}); -let S1 = board.add(slide_switch, {translate: pt(IC1.posX, IC1.padY("out")+.4), rotate: 180, label: 'prog run'}); -let S2 = board.add(button_6mm, {translate: pt(IC2.posX, IC2.padY("EN")-.2), label: 'reset'}); -let R1 = board.add(R_1206, {translate: pt(S2.padX("L2")+.15, S2.posY), rotate: 90, label: 'R1\n10k'}); -let C3 = board.add(C_1206, {translate: pt(R1.posX+.12, R1.posY), rotate: 90, label: 'C3\n.1uF'}); - -let interior = geo.path(path([x, y+height], +let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+.5), rotate: 0, id: 'J1 FTDI\n3.3V'}); +let IC1 = board.add(regulator_SOT223, {translate: pt(J1.posX-.25, J1.posY), id: 'IC1\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY-.25), id: 'C1 10uF'}); +let C2 = board.add(C_1206, {translate: pt(IC1.posX, IC1.posY+.25), id: 'C2 1uF'}); +let IC2 = board.add(ESP32_WROOM, {translate: pt(x+.35, y+.69), rotate: 90, id: 'IC2\nESP32-WROOM'}); +let S1 = board.add(slide_switch, {translate: pt(IC1.posX, IC1.padY("out")+.4), rotate: 180, id: 'prog run'}); +let S2 = board.add(button_6mm, {translate: pt(IC2.posX, IC2.padY("EN")-.2), id: 'reset'}); +let R1 = board.add(R_1206, {translate: pt(S2.padX("L2")+.15, S2.posY), rotate: 90, id: 'R1\n10k'}); +let C3 = board.add(C_1206, {translate: pt(R1.posX+.12, R1.posY), rotate: 90, id: 'C3\n.1uF'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -148,7 +148,7 @@ board.wire(path(C3.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -160,5 +160,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.GPS.t1614.js b/examples/hello.GPS.t1614.js index 2522ea7..30e7f4d 100644 --- a/examples/hello.GPS.t1614.js +++ b/examples/hello.GPS.t1614.js @@ -29,18 +29,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny1614, {translate: pt(x+.53, y+.54), label: 'IC1\nt1614'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.07), rotate: 180, label: 'J1\nserial\n5V'}); -let C1 = board.add(C_1206, {translate: pt(J1.posX+.15, J1.padY("GND")), rotate: -90, label: 'C1\n1uF'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let J3 = board.add(header_GPS, {translate: pt(x+width-.15, y+height/2), label: 'J3\nGPS'}); +let IC1 = board.add(ATtiny1614, {translate: pt(x+.53, y+.54), id: 'IC1\nt1614'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.07), rotate: 180, id: 'J1\nserial\n5V'}); +let C1 = board.add(C_1206, {translate: pt(J1.posX+.15, J1.padY("GND")), rotate: -90, id: 'C1\n1uF'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let J3 = board.add(header_GPS, {translate: pt(x+width-.15, y+height/2), id: 'J3\nGPS'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -112,7 +112,7 @@ board.wire(path(C1.pad("1"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -124,5 +124,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.H-bridge.D11C.js b/examples/hello.H-bridge.D11C.js index d340c06..95a9925 100644 --- a/examples/hello.H-bridge.D11C.js +++ b/examples/hello.H-bridge.D11C.js @@ -32,25 +32,25 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+width-.87, y+.3), rotate: -90, label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.padX("CLK")-.14, IC1.posY), rotate: -90, label: 'J1\nSWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, y+height/2), rotate: 0, label: 'J2\nUSB'}); -let IC2 = board.add(A4953_SOICN, {translate: pt(IC1.posX-.1, IC1.posY+.4), rotate: 90, label: 'IC2\nTB67H451FNG'}); -let J3 = board.add(header_4, {translate: pt(IC2.posX-.29, IC2.posY+.15), rotate: 0, label: 'J3\nload'}); -let IC3 = board.add(regulator_SOT23, {translate: pt(IC2.posX+.47, IC2.posY-.08), rotate: 90, label: 'IC3\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC3.posX-.11, IC3.posY), rotate: 90, label: 'C1\n1uF'}); -let C2 = board.add(C_1206, {translate: pt(IC2.posX+.16, IC2.posY+.06), rotate: 90, label: 'C2\n.1'}); -let C3 = board.add(C_1206, {translate: pt(IC2.posX+.26, IC2.posY+.06), rotate: 90, label: 'C3\n10uF'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+width-.87, y+.3), rotate: -90, id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.padX("CLK")-.14, IC1.posY), rotate: -90, id: 'J1\nSWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, y+height/2), rotate: 0, id: 'J2\nUSB'}); +let IC2 = board.add(A4953_SOICN, {translate: pt(IC1.posX-.1, IC1.posY+.4), rotate: 90, id: 'IC2\nTB67H451FNG'}); +let J3 = board.add(header_4, {translate: pt(IC2.posX-.29, IC2.posY+.15), rotate: 0, id: 'J3\nload'}); +let IC3 = board.add(regulator_SOT23, {translate: pt(IC2.posX+.47, IC2.posY-.08), rotate: 90, id: 'IC3\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC3.posX-.11, IC3.posY), rotate: 90, id: 'C1\n1uF'}); +let C2 = board.add(C_1206, {translate: pt(IC2.posX+.16, IC2.posY+.06), rotate: 90, id: 'C2\n.1'}); +let C3 = board.add(C_1206, {translate: pt(IC2.posX+.26, IC2.posY+.06), rotate: 90, id: 'C3\n10uF'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 0.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 0.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 0.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 0.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -183,7 +183,7 @@ board.wire(path(C3.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -195,5 +195,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.HM-11.ftdi.js b/examples/hello.HM-11.ftdi.js index f774b01..29102b9 100644 --- a/examples/hello.HM-11.ftdi.js +++ b/examples/hello.HM-11.ftdi.js @@ -28,17 +28,17 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+height/2), rotate: 0, label: 'J1 FTDI\n3.3V'}); -let IC1 = board.add(regulator_SOT23, {translate: pt(J1.posX-.18, J1.padY("CTS")), rotate: 90, label: 'IC1\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX-.14, IC1.posY), rotate: 90, label: 'C1\n1uF'}); -let HM = board.add(HM11, {translate: pt(x+.15, J1.posY), rotate: 90, label: 'HM-11'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+height/2), rotate: 0, id: 'J1 FTDI\n3.3V'}); +let IC1 = board.add(regulator_SOT23, {translate: pt(J1.posX-.18, J1.padY("CTS")), rotate: 90, id: 'IC1\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX-.14, IC1.posY), rotate: 90, id: 'C1\n1uF'}); +let HM = board.add(HM11, {translate: pt(x+.15, J1.posY), rotate: 90, id: 'HM-11'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -82,7 +82,7 @@ board.wire(path(HM.pad("GND"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -94,5 +94,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ILI9341.HW.D21E.js b/examples/hello.ILI9341.HW.D21E.js index 868384f..77df6ae 100644 --- a/examples/hello.ILI9341.HW.D21E.js +++ b/examples/hello.ILI9341.HW.D21E.js @@ -33,28 +33,28 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD21E, {translate: pt(x+.65, y+.36), label: 'IC1\nD21E'}); -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("DIO")+.34), rotate: -90, label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC1.padY("25+")+.04), label: 'J2 USB'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND2"), IC1.padY("A27")+.15), label: 'C1 1uF'}); -let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-.275, IC1.padY("VAN")-.08), rotate: 90, label: 'C2\n1uF'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-.135, C2.posY), rotate: -90, label: 'IC2\n3.3V'}); -let J3 = board.add(TFT8x1v, {translate: pt(IC1.posX-.41, IC1.posY+.28), rotate: 0, label: 'J3 TFT'}); -let R1 = board.add(R_1206, {translate: pt(J3.padX("SCK")+.025, C2.padY("2")), rotate: 90, label: 'R1\n(0)'}); -let V1 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("MOSI")-.02, J3.padY("SCK")), label: 'V1'}); -let V2 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("SCK")+.02, J3.padY("SCK")-.075), label: 'V2'}); -let V3 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A16"), IC1.padY("A15")), label: 'V3'}); -let V4 = board.add(via(2*rv, 2*rp), {translate: pt(V3.posX, V3.posY-.09), label: 'V4'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD21E, {translate: pt(x+.65, y+.36), id: 'IC1\nD21E'}); +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("DIO")+.34), rotate: -90, id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC1.padY("25+")+.04), id: 'J2 USB'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND2"), IC1.padY("A27")+.15), id: 'C1 1uF'}); +let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-.275, IC1.padY("VAN")-.08), rotate: 90, id: 'C2\n1uF'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-.135, C2.posY), rotate: -90, id: 'IC2\n3.3V'}); +let J3 = board.add(TFT8x1v, {translate: pt(IC1.posX-.41, IC1.posY+.28), rotate: 0, id: 'J3 TFT'}); +let R1 = board.add(R_1206, {translate: pt(J3.padX("SCK")+.025, C2.padY("2")), rotate: 90, id: 'R1\n(0)'}); +let V1 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("MOSI")-.02, J3.padY("SCK")), id: 'V1'}); +let V2 = board.add(via(2*rv, 2*rp), {translate: pt(J3.padX("SCK")+.02, J3.padY("SCK")-.075), id: 'V2'}); +let V3 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("A16"), IC1.padY("A15")), id: 'V3'}); +let V4 = board.add(via(2*rv, 2*rp), {translate: pt(V3.posX, V3.posY-.09), id: 'V4'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY])); -geo.difference(interior, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY])); +geo.difference(outline, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY])); +geo.difference(outline, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -217,7 +217,7 @@ board.wire(path(V4.pad("via"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -229,5 +229,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ILI9341.SW.D21E.js b/examples/hello.ILI9341.SW.D21E.js index e453b6e..88e0570 100644 --- a/examples/hello.ILI9341.SW.D21E.js +++ b/examples/hello.ILI9341.SW.D21E.js @@ -31,24 +31,24 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD21E, {translate: pt(x+.62, y+.36), label: 'IC1\nD21E'}); -let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("DIO")+.34), rotate: -90, label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC1.padY("25+")+.04), label: 'J2 USB'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND2"), IC1.padY("A27")+.15), label: 'C1 1uF'}); -let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-.255, IC1.padY("VAN")-.08), rotate: 90, label: 'C2\n1uF'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-.125, C2.posY), rotate: -90, label: 'IC2\n3.3V'}); -let J3 = board.add(TFT8x1v, {translate: pt(IC1.posX-.39, IC1.posY+.25), rotate: 0, label: 'J3 TFT'}); -let R1 = board.add(R_1206, {translate: pt(J3.padX("SCK")+.025, C2.padY("2")), rotate: 90, label: 'R1\n(0)'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD21E, {translate: pt(x+.62, y+.36), id: 'IC1\nD21E'}); +let J1 = board.add(header_SWD, {translate: pt(IC1.posX, IC1.padY("DIO")+.34), rotate: -90, id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, IC1.padY("25+")+.04), id: 'J2 USB'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND2"), IC1.padY("A27")+.15), id: 'C1 1uF'}); +let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-.255, IC1.padY("VAN")-.08), rotate: 90, id: 'C2\n1uF'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-.125, C2.posY), rotate: -90, id: 'IC2\n3.3V'}); +let J3 = board.add(TFT8x1v, {translate: pt(IC1.posX-.39, IC1.posY+.25), rotate: 0, id: 'J3 TFT'}); +let R1 = board.add(R_1206, {translate: pt(J3.padX("SCK")+.025, C2.padY("2")), rotate: 90, id: 'R1\n(0)'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY])); -geo.difference(interior, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY])); +geo.difference(outline, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY])); +geo.difference(outline, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -196,7 +196,7 @@ board.wire(path(R1.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -208,5 +208,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ISP.44.js b/examples/hello.ISP.44.js index 5258a0c..84ef257 100644 --- a/examples/hello.ISP.44.js +++ b/examples/hello.ISP.44.js @@ -31,29 +31,29 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.51, y+.67), label: 'IC1\nt44'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.24), rotate: 90, label: 'J1\nISP'}); -let SJ1 = board.add(SJ, {translate: pt(IC1.padX("PA6")-.07, J1.padY("RST")), rotate: 90, label: 'SJ1'}); -let J2 = board.add(USB_mini_B, {translate: pt(IC1.posX-.02, y+height+.08), rotate: 180, label: "\n\nJ2 USB"}); -let R1 = board.add(R_1206, {translate: pt(J2.padX("V")+.09, J2.padY("V")-.1), label: 'R1 1k'}); -let R2 = board.add(R_1206, {translate: pt(R1.padX("2"), R1.posY-.143), rotate: 90, label: 'R2\n499'}); -let SJ2 = board.add(R_1206, {translate: pt(R2.posX-.015, R2.posY-.2), rotate: 90, label: 'SJ2'}); -let D1 = board.add(D_SOD_123, {translate: pt(J2.padX("+"), R2.padY("2")), label: 'D1\n3.3V'}); -let D2 = board.add(D_SOD_123, {translate: pt(D1.padX("A"), D1.posY-.07), label: '\nD2 3.3V'}); -let R3 = board.add(R_1206, {translate: pt(D2.posX+.04, D2.posY-.15), rotate: 90, label: 'R3\n100'}); -let R4 = board.add(R_1206, {translate: pt(D1.padX("C")-.01, R3.posY), rotate: 90, label: 'R4\n100'}); -let R5 = board.add(R_1206, {translate: pt(SJ1.posX-.07, J1.padY("GND")), rotate: 90, label: 'R5\n10k'}); -let XTAL1 = board.add(XTAL_NX5032GA, {translate: pt(IC1.posX-.27, IC1.padY("PB0")-.025), rotate: 90, label: '20\nMHz'}); -let C1 = board.add(C_1206, {translate: pt(R5.posX-.1, R5.posY), rotate: 90, label: 'C1\n1uF'}); -let C2 = board.add(C_1206, {translate: pt(XTAL1.posX-.12, XTAL1.posY+.12), rotate: 90, label: 'C2\n10pF'}); -let C3 = board.add(C_1206, {translate: pt(C2.posX, XTAL1.posY-.12), rotate: 90, label: 'C3\n10pF'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.51, y+.67), id: 'IC1\nt44'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.24), rotate: 90, id: 'J1\nISP'}); +let SJ1 = board.add(SJ, {translate: pt(IC1.padX("PA6")-.07, J1.padY("RST")), rotate: 90, id: 'SJ1'}); +let J2 = board.add(USB_mini_B, {translate: pt(IC1.posX-.02, y+height+.08), rotate: 180, id: "\n\nJ2 USB"}); +let R1 = board.add(R_1206, {translate: pt(J2.padX("V")+.09, J2.padY("V")-.1), id: 'R1 1k'}); +let R2 = board.add(R_1206, {translate: pt(R1.padX("2"), R1.posY-.143), rotate: 90, id: 'R2\n499'}); +let SJ2 = board.add(R_1206, {translate: pt(R2.posX-.015, R2.posY-.2), rotate: 90, id: 'SJ2'}); +let D1 = board.add(D_SOD_123, {translate: pt(J2.padX("+"), R2.padY("2")), id: 'D1\n3.3V'}); +let D2 = board.add(D_SOD_123, {translate: pt(D1.padX("A"), D1.posY-.07), id: '\nD2 3.3V'}); +let R3 = board.add(R_1206, {translate: pt(D2.posX+.04, D2.posY-.15), rotate: 90, id: 'R3\n100'}); +let R4 = board.add(R_1206, {translate: pt(D1.padX("C")-.01, R3.posY), rotate: 90, id: 'R4\n100'}); +let R5 = board.add(R_1206, {translate: pt(SJ1.posX-.07, J1.padY("GND")), rotate: 90, id: 'R5\n10k'}); +let XTAL1 = board.add(XTAL_NX5032GA, {translate: pt(IC1.posX-.27, IC1.padY("PB0")-.025), rotate: 90, id: '20\nMHz'}); +let C1 = board.add(C_1206, {translate: pt(R5.posX-.1, R5.posY), rotate: 90, id: 'C1\n1uF'}); +let C2 = board.add(C_1206, {translate: pt(XTAL1.posX-.12, XTAL1.posY+.12), rotate: 90, id: 'C2\n10pF'}); +let C3 = board.add(C_1206, {translate: pt(C2.posX, XTAL1.posY-.12), rotate: 90, id: 'C3\n10pF'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -212,7 +212,7 @@ board.wire(path([C1.posX, C1.padY("1")-.085], renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -224,5 +224,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.LEDs.t412.js b/examples/hello.LEDs.t412.js index 6f8f9f4..5fc4ed9 100644 --- a/examples/hello.LEDs.t412.js +++ b/examples/hello.LEDs.t412.js @@ -33,29 +33,29 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny412, {translate: pt(x+.44, y+.44), label: 'IC1\nt412'}); -let J1 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J1\nUPDI'}); -let J2 = board.add(header_power, {translate: pt(J1.posX+.28, J1.posY-.04), rotate: 90, label: 'J2\n9V'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(J2.posX, J2.posY+.25), label: 'IC2\n5V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY+.12), label: 'C1 1uF'}); -let T1 = board.add(NMOSFET_SOT23, {translate: pt(IC1.posX-.35, IC1.padY("VCC")+.01), rotate: 90, label: 'T1 N'}); -let R1 = board.add(R_1206, {translate: pt(T1.posX+.12, T1.posY+.03), rotate: 90, label: 'R1\n10k'}); -let D1 = board.add(LED_3014_1100, {translate: pt(T1.posX-.035, T1.posY-.15), rotate: 90, label: 'D1'}); -let D2 = board.add(LED_3014_1100, {translate: pt(D1.posX+.075, D1.posY), rotate: 90, label: 'D2'}); -let D3 = board.add(LED_3014_1100, {translate: pt(D1.posX+.15, D1.posY), rotate: 90, label: 'D3'}); -let D4 = board.add(LED_3014_1100, {translate: pt(D1.posX, D1.posY-.14), rotate: 90, label: 'D4'}); -let D5 = board.add(LED_3014_1100, {translate: pt(D4.posX+.075, D4.posY), rotate: 90, label: 'D5'}); -let D6 = board.add(LED_3014_1100, {translate: pt(D4.posX+.15, D4.posY), rotate: 90, label: 'D6'}); -let D7 = board.add(LED_3014_1100, {translate: pt(D4.posX, D4.posY-.14), rotate: 90, label: 'D7'}); -let D8 = board.add(LED_3014_1100, {translate: pt(D7.posX+.075, D7.posY), rotate: 90, label: 'D8'}); -let D9 = board.add(LED_3014_1100, {translate: pt(D7.posX+.15, D7.posY), rotate: 90, label: 'D9'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny412, {translate: pt(x+.44, y+.44), id: 'IC1\nt412'}); +let J1 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J1\nUPDI'}); +let J2 = board.add(header_power, {translate: pt(J1.posX+.28, J1.posY-.04), rotate: 90, id: 'J2\n9V'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(J2.posX, J2.posY+.25), id: 'IC2\n5V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY+.12), id: 'C1 1uF'}); +let T1 = board.add(NMOSFET_SOT23, {translate: pt(IC1.posX-.35, IC1.padY("VCC")+.01), rotate: 90, id: 'T1 N'}); +let R1 = board.add(R_1206, {translate: pt(T1.posX+.12, T1.posY+.03), rotate: 90, id: 'R1\n10k'}); +let D1 = board.add(LED_3014_1100, {translate: pt(T1.posX-.035, T1.posY-.15), rotate: 90, id: 'D1'}); +let D2 = board.add(LED_3014_1100, {translate: pt(D1.posX+.075, D1.posY), rotate: 90, id: 'D2'}); +let D3 = board.add(LED_3014_1100, {translate: pt(D1.posX+.15, D1.posY), rotate: 90, id: 'D3'}); +let D4 = board.add(LED_3014_1100, {translate: pt(D1.posX, D1.posY-.14), rotate: 90, id: 'D4'}); +let D5 = board.add(LED_3014_1100, {translate: pt(D4.posX+.075, D4.posY), rotate: 90, id: 'D5'}); +let D6 = board.add(LED_3014_1100, {translate: pt(D4.posX+.15, D4.posY), rotate: 90, id: 'D6'}); +let D7 = board.add(LED_3014_1100, {translate: pt(D4.posX, D4.posY-.14), rotate: 90, id: 'D7'}); +let D8 = board.add(LED_3014_1100, {translate: pt(D7.posX+.075, D7.posY), rotate: 90, id: 'D8'}); +let D9 = board.add(LED_3014_1100, {translate: pt(D7.posX+.15, D7.posY), rotate: 90, id: 'D9'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -157,7 +157,7 @@ board.wire(path(D9.pad("C"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -169,5 +169,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.LSM6DS33.t1614.js b/examples/hello.LSM6DS33.t1614.js index b382e87..cda5928 100644 --- a/examples/hello.LSM6DS33.t1614.js +++ b/examples/hello.LSM6DS33.t1614.js @@ -29,18 +29,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny1614, {translate: pt(x+.53, y+.54), label: 'IC1\nt1614'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.07), rotate: 180, label: 'J1\nserial\n5V'}); -let C1 = board.add(C_1206, {translate: pt(J1.posX, J1.padY("GND")-.1), label: 'C1 1uF'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let J3 = board.add(header_LSM6DS33_2736, {translate: pt(x+width-.23, IC1.posY-.25), label: "J3\nLSM6DS33\n2736"}); +let IC1 = board.add(ATtiny1614, {translate: pt(x+.53, y+.54), id: 'IC1\nt1614'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.07), rotate: 180, id: 'J1\nserial\n5V'}); +let C1 = board.add(C_1206, {translate: pt(J1.posX, J1.padY("GND")-.1), id: 'C1 1uF'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let J3 = board.add(header_LSM6DS33_2736, {translate: pt(x+width-.23, IC1.posY-.25), id: "J3\nLSM6DS33\n2736"}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -111,7 +111,7 @@ board.wire(path(J3.pad("SCL"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -123,5 +123,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.MFRC522.t1614.js b/examples/hello.MFRC522.t1614.js index 1835ddb..daaee58 100644 --- a/examples/hello.MFRC522.t1614.js +++ b/examples/hello.MFRC522.t1614.js @@ -31,20 +31,20 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny1614, {translate: pt(x+.63, y+.55), label: 'IC1\nt1614'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY), rotate: 180, label: 'J1\nFTDI'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(J1.posX, J1.padY("GND")-.13), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX+.15, IC2.posY), rotate: 90, label: 'C1\n1uF'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let J3 = board.add(header_MFRC522, {translate: pt(x+width-.23, IC1.posY-.1), label: 'J3\nMFRC522'}); -let R1 = board.add(R_1206, {translate: pt(J3.posX-.14, J3.padY("CIPO")), rotate: 90, label: 'R1\n0'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny1614, {translate: pt(x+.63, y+.55), id: 'IC1\nt1614'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY), rotate: 180, id: 'J1\nFTDI'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(J1.posX, J1.padY("GND")-.13), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX+.15, IC2.posY), rotate: 90, id: 'C1\n1uF'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let J3 = board.add(header_MFRC522, {translate: pt(x+width-.23, IC1.posY-.1), id: 'J3\nMFRC522'}); +let R1 = board.add(R_1206, {translate: pt(J3.posX-.14, J3.padY("CIPO")), rotate: 90, id: 'R1\n0'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -148,7 +148,7 @@ board.wire(path(IC1.pad("PA2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -160,5 +160,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.MinIMU9v5.t1614.js b/examples/hello.MinIMU9v5.t1614.js index cbfa158..a39f803 100644 --- a/examples/hello.MinIMU9v5.t1614.js +++ b/examples/hello.MinIMU9v5.t1614.js @@ -29,18 +29,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny1614, {translate: pt(x+.53, y+.52), label: 'IC1\nt1614'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.07), rotate: 180, label: 'J1\nserial\n5V'}); -let C1 = board.add(C_1206, {translate: pt(J1.posX, J1.padY("GND")-.1), label: 'C1 1uF'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let J3 = board.add(header_IMU_2738, {translate: pt(x+width-.23, y+height/2), label: "J3\nMinIMU9v5"}); +let IC1 = board.add(ATtiny1614, {translate: pt(x+.53, y+.52), id: 'IC1\nt1614'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.07), rotate: 180, id: 'J1\nserial\n5V'}); +let C1 = board.add(C_1206, {translate: pt(J1.posX, J1.padY("GND")-.1), id: 'C1 1uF'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let J3 = board.add(header_IMU_2738, {translate: pt(x+width-.23, y+height/2), id: "J3\nMinIMU9v5"}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -112,7 +112,7 @@ board.wire(path(C1.pad("1"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -124,5 +124,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.RN4871.ftdi.js b/examples/hello.RN4871.ftdi.js index 0a7134f..741a9b9 100644 --- a/examples/hello.RN4871.ftdi.js +++ b/examples/hello.RN4871.ftdi.js @@ -29,18 +29,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+height/2+.01), rotate: 0, label: 'J1 FTDI\n3.3V'}); -let IC1 = board.add(regulator_SOT23, {translate: pt(J1.posX-.18, J1.padY("CTS")), rotate: 90, label: 'IC1\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX-.14, IC1.posY), rotate: 90, label: 'C1\n1uF'}); -let RN = board.add(RN4871, {translate: pt(x, J1.posY), rotate: 90, label: ' RN4871'}); -let R1 = board.add(R_1206, {translate: pt(C1.posX-.15, C1.padY("1")), label: 'R1\n10k'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.22, y+height/2+.01), rotate: 0, id: 'J1 FTDI\n3.3V'}); +let IC1 = board.add(regulator_SOT23, {translate: pt(J1.posX-.18, J1.padY("CTS")), rotate: 90, id: 'IC1\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX-.14, IC1.posY), rotate: 90, id: 'C1\n1uF'}); +let RN = board.add(RN4871, {translate: pt(x, J1.posY), rotate: 90, id: ' RN4871'}); +let R1 = board.add(R_1206, {translate: pt(C1.posX-.15, C1.padY("1")), id: 'R1\n10k'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -103,7 +103,7 @@ board.wire(path(R1.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -115,5 +115,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.SSD1306.45.js b/examples/hello.SSD1306.45.js index 26131c7..b98997d 100644 --- a/examples/hello.SSD1306.45.js +++ b/examples/hello.SSD1306.45.js @@ -29,21 +29,21 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny45_SOIC, {translate: pt(x+.53, y+.26), rotate: -90, label: 'IC1\nt45'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX-.31, IC1.posY-.02), rotate: 0, label: 'J1\nISP'}); -let R1 = board.add(R_1206, {translate: pt(IC1.padX("RST")+.09, IC1.posY), rotate: 90, label: 'R1\n10k'}); -let C1 = board.add(C_1206, {translate: pt(R1.posX+.12, R1.posY), rotate: 90, label: 'C1\n1uF'}); -let J2 = board.add(header_FTDI, {translate: pt(x+width-.23, C1.posY+.05), label: 'J2 FTDI\n5V'}); -let oled = board.add(I2C4x1, {translate: pt(IC1.padX("PB3"), J2.padY("GND")+.05), rotate: 90, label: 'SSD1306'}); -let R2 = board.add(R_1206, {translate: pt(J1.posX+.06, oled.padY("SCL")), rotate: 90, label: 'R2\n10k'}); -let R3 = board.add(R_1206, {translate: pt(J1.posX-.06, oled.padY("SCL")), rotate: 90, label: 'R3\n10k'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny45_SOIC, {translate: pt(x+.53, y+.26), rotate: -90, id: 'IC1\nt45'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX-.31, IC1.posY-.02), rotate: 0, id: 'J1\nISP'}); +let R1 = board.add(R_1206, {translate: pt(IC1.padX("RST")+.09, IC1.posY), rotate: 90, id: 'R1\n10k'}); +let C1 = board.add(C_1206, {translate: pt(R1.posX+.12, R1.posY), rotate: 90, id: 'C1\n1uF'}); +let J2 = board.add(header_FTDI, {translate: pt(x+width-.23, C1.posY+.05), id: 'J2 FTDI\n5V'}); +let oled = board.add(I2C4x1, {translate: pt(IC1.padX("PB3"), J2.padY("GND")+.05), rotate: 90, id: 'SSD1306'}); +let R2 = board.add(R_1206, {translate: pt(J1.posX+.06, oled.padY("SCL")), rotate: 90, id: 'R2\n10k'}); +let R3 = board.add(R_1206, {translate: pt(J1.posX-.06, oled.padY("SCL")), rotate: 90, id: 'R3\n10k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -147,7 +147,7 @@ board.wire(path(oled.pad("GND"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -159,5 +159,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.SWD.10-4.1.js b/examples/hello.SWD.10-4.1.js index b4fc898..861cb88 100644 --- a/examples/hello.SWD.10-4.1.js +++ b/examples/hello.SWD.10-4.1.js @@ -25,15 +25,15 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_SWD_4_1, {translate: pt(x+width/2+.005, y+.1), rotate: 180, label: 'J1 SWD'}); -let J3 = board.add(header_SWD, {translate: pt(J1.posX, y+height-.19), rotate: -90, label: 'J3\ntarget'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(x+width/2+.005, y+.1), rotate: 180, id: 'J1 SWD'}); +let J3 = board.add(header_SWD, {translate: pt(J1.posX, y+height-.19), rotate: -90, id: 'J3\ntarget'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -74,7 +74,7 @@ board.wire(path(J3.pad("RST"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -86,5 +86,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.SWD.10-4.js b/examples/hello.SWD.10-4.js index 73dd86a..ee825ec 100644 --- a/examples/hello.SWD.10-4.js +++ b/examples/hello.SWD.10-4.js @@ -26,15 +26,15 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_SWD_4_05, {translate: pt(x+width/2+.005, y+.07), rotate: 180, label: 'J1 SWD'}); -let J3 = board.add(header_SWD, {translate: pt(J1.posX, y+height-.19), rotate: -90, label: 'J3\ntarget'}); +let J1 = board.add(header_SWD_4_05, {translate: pt(x+width/2+.005, y+.07), rotate: 180, id: 'J1 SWD'}); +let J3 = board.add(header_SWD, {translate: pt(J1.posX, y+height-.19), rotate: -90, id: 'J3\ntarget'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -75,7 +75,7 @@ board.wire(path(J3.pad("RST"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -87,5 +87,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.TLE493D.t412.js b/examples/hello.TLE493D.t412.js index 6a520e2..e0c6249 100644 --- a/examples/hello.TLE493D.t412.js +++ b/examples/hello.TLE493D.t412.js @@ -32,22 +32,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny412, {translate: pt(x+.49, y+.41), label: 'IC1\nt412'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.075), rotate: 180, label: 'J1\nserial'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX+.07, IC1.padY("VCC")+.14), rotate: 90, label: 'C1\n1uF'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.posX-.07, C1.posY), rotate: -90, label: 'IC2\n3.3V'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let IC3 = board.add(TLE493D, {translate: pt(IC1.posX+.26, IC1.posY-.02), label: 'IC3\nTLE493D'}); -let R1 = board.add(R_1206, {translate: pt(IC3.posX, IC3.posY-.18), label: 'R1 1k'}); -let R2 = board.add(R_1206, {translate: pt(R1.posX, R1.posY-.1), label: 'R2 1k'}); -let C2 = board.add(C_1206, {translate: pt(IC3.padX("GND1"), C1.padY("1")), label: 'C2\n0.1uF'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny412, {translate: pt(x+.49, y+.41), id: 'IC1\nt412'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.075), rotate: 180, id: 'J1\nserial'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX+.07, IC1.padY("VCC")+.14), rotate: 90, id: 'C1\n1uF'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.posX-.07, C1.posY), rotate: -90, id: 'IC2\n3.3V'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let IC3 = board.add(TLE493D, {translate: pt(IC1.posX+.26, IC1.posY-.02), id: 'IC3\nTLE493D'}); +let R1 = board.add(R_1206, {translate: pt(IC3.posX, IC3.posY-.18), id: 'R1 1k'}); +let R2 = board.add(R_1206, {translate: pt(R1.posX, R1.posY-.1), id: 'R2 1k'}); +let C2 = board.add(C_1206, {translate: pt(IC3.padX("GND1"), C1.padY("1")), id: 'C2\n0.1uF'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -169,7 +169,7 @@ board.wire(path(C1.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -181,5 +181,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.VEML6040.t412.js b/examples/hello.VEML6040.t412.js index fe17454..dd44d24 100644 --- a/examples/hello.VEML6040.t412.js +++ b/examples/hello.VEML6040.t412.js @@ -32,22 +32,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny412, {translate: pt(x+.6, y+.47), label: 'IC1\nt412'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), label: 'C1 1uF'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.1), rotate: 180, label: 'J1 serial\n5V power\n3.3V logic'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.posX-.23, C1.posY-.02), rotate: -90, label: 'IC2\n3.3V'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let IC3 = board.add(VEML6040, {translate: pt(x+width-.05, J2.posY+.03), rotate: 90, label: 'IC3'}); -let R1 = board.add(R_1206, {translate: pt(IC3.posX-.12, IC3.posY-.15), label: 'R1 0'}); -let R2 = board.add(R_1206, {translate: pt(J2.padX("GND")-.115, J2.posY), rotate: 90, label: 'R2\n4.99k'}); -let R3 = board.add(R_1206, {translate: pt(J2.posX+.15, J2.posY+.03), rotate: 90, label: 'R3\n4.99k'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny412, {translate: pt(x+.6, y+.47), id: 'IC1\nt412'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), id: 'C1 1uF'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.1), rotate: 180, id: 'J1 serial\n5V power\n3.3V logic'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.posX-.23, C1.posY-.02), rotate: -90, id: 'IC2\n3.3V'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let IC3 = board.add(VEML6040, {translate: pt(x+width-.05, J2.posY+.03), rotate: 90, id: 'IC3'}); +let R1 = board.add(R_1206, {translate: pt(IC3.posX-.12, IC3.posY-.15), id: 'R1 0'}); +let R2 = board.add(R_1206, {translate: pt(J2.padX("GND")-.115, J2.posY), rotate: 90, id: 'R2\n4.99k'}); +let R3 = board.add(R_1206, {translate: pt(J2.posX+.15, J2.posY+.03), rotate: 90, id: 'R3\n4.99k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -151,7 +151,7 @@ board.wire(path([R1.posX, R3.padY("1")], renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -163,5 +163,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.VL53L1X.t1614.js b/examples/hello.VL53L1X.t1614.js index e84e9f3..f13a1ad 100644 --- a/examples/hello.VL53L1X.t1614.js +++ b/examples/hello.VL53L1X.t1614.js @@ -29,18 +29,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny1614, {translate: pt(x+.53, y+.54), label: 'IC1\nt1614'}); -let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.07), rotate: 180, label: 'J1\nserial\n5V'}); -let C1 = board.add(C_1206, {translate: pt(J1.posX, J1.padY("GND")-.1), label: 'C1 1uF'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let J3 = board.add(header_VL53L1X_3415, {translate: pt(x+width-.23, IC1.posY-.15), label: "J3\nVL53L1X\n3415"}); +let IC1 = board.add(ATtiny1614, {translate: pt(x+.53, y+.54), id: 'IC1\nt1614'}); +let J1 = board.add(header_FTDI, {translate: pt(x+.23, IC1.posY-.07), rotate: 180, id: 'J1\nserial\n5V'}); +let C1 = board.add(C_1206, {translate: pt(J1.posX, J1.padY("GND")-.1), id: 'C1 1uF'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let J3 = board.add(header_VL53L1X_3415, {translate: pt(x+width-.23, IC1.posY-.15), id: "J3\nVL53L1X\n3415"}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -111,7 +111,7 @@ board.wire(path(J3.pad("SCL"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -123,5 +123,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.button.D11C.js b/examples/hello.button.D11C.js index b724ba5..c300c1f 100644 --- a/examples/hello.button.D11C.js +++ b/examples/hello.button.D11C.js @@ -30,22 +30,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.36, y+.41), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_05, {translate: pt(IC1.posX, IC1.padY("CLK")-.11), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.18, IC1.padY("A08")), rotate: -90, label: 'IC2\n3.3'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX+.025, IC2.posY-.22), rotate: 90, label: 'C1\n1uF'}); -let S1 = board.add(button_6mm, {translate: pt(IC1.posX+.32, IC1.posY-.15), rotate: 90, label: 'S1'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.36, y+.41), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_05, {translate: pt(IC1.posX, IC1.padY("CLK")-.11), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.18, IC1.padY("A08")), rotate: -90, id: 'IC2\n3.3'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX+.025, IC2.posY-.22), rotate: 90, id: 'C1\n1uF'}); +let S1 = board.add(button_6mm, {translate: pt(IC1.posX+.32, IC1.posY-.15), rotate: 90, id: 'S1'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -128,7 +128,7 @@ board.wire(path(IC2.pad("gnd"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -140,5 +140,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.button.t412.js b/examples/hello.button.t412.js index 3184bfc..f498afd 100644 --- a/examples/hello.button.t412.js +++ b/examples/hello.button.t412.js @@ -29,18 +29,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny412, {translate: pt(x+.45, y+.44), label: 'IC1\nt412'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), label: 'C1 1uF'}); -let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.1), label: 'J1\nserial\n5V'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let S1 = board.add(button_6mm, {translate: pt(J2.posX-.27, y+.2), rotate: 0, label: 'S1'}); +let IC1 = board.add(ATtiny412, {translate: pt(x+.45, y+.44), id: 'IC1\nt412'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), id: 'C1 1uF'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.1), id: 'J1\nserial\n5V'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let S1 = board.add(button_6mm, {translate: pt(J2.posX-.27, y+.2), rotate: 0, id: 'S1'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -99,7 +99,7 @@ board.wire(path(S1.pad("L2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -111,5 +111,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ftdi.44.2.js b/examples/hello.ftdi.44.2.js index f106c42..fcfe0ed 100644 --- a/examples/hello.ftdi.44.2.js +++ b/examples/hello.ftdi.44.2.js @@ -32,26 +32,26 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.49, y+.56), label: 'IC1\nt44'}); +let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.49, y+.56), id: 'IC1\nt44'}); let VIC1 = board.add(via(2*rv, 2*rp), {translate: pt(IC1.padX("GND")+.08, IC1.padY("GND")+.02)}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, label: 'J1\nISP'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, id: 'J1\nISP'}); let VJ12 = board.add(via(2*rv, 2*rp), {translate: pt(J1.padX("V")+.075, J1.padY("V"))}); let VJ16 = board.add(via(2*rv, 2*rp), {translate: pt(J1.padX("GND")-.075, J1.padY("GND"))}); -let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, label: 'J2 FTDI'}); +let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, id: 'J2 FTDI'}); let VJ2 = board.add(via(2*rv, 2*rp), {translate: pt(J2.padX("VCC")+.1, J2.padY("VCC"))}); -let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB3")-.2, IC1.padY("PA0")+.003), rotate: -90, label: 'XTAL1\n20 MHz'}); +let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB3")-.2, IC1.padY("PA0")+.003), rotate: -90, id: 'XTAL1\n20 MHz'}); let VXTAL = board.add(via(2*rv, 2*rp), {translate: pt(XTAL1.posX-.12, XTAL1.posY)}); -let R1 = board.add(R_1206, {translate: pt(IC1.padX("VCC"), IC1.padY("VCC")+.1), label: 'R1\n10k'}); +let R1 = board.add(R_1206, {translate: pt(IC1.padX("VCC"), IC1.padY("VCC")+.1), id: 'R1\n10k'}); let VR1 = board.add(via(2*rv, 2*rp), {translate: pt(R1.padX("1")-.08, R1.posY)}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND"), R1.posY), label: 'C1\n1uF'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND"), R1.posY), id: 'C1\n1uF'}); let VC1 = board.add(via(2*rv, 2*rp), {translate: pt(C1.padX("1")-.025, C1.posY-.06)}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -148,7 +148,7 @@ board.wire(path(VR1.pad("via"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -160,5 +160,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ftdi.44.js b/examples/hello.ftdi.44.js index 411bf92..8d3afde 100644 --- a/examples/hello.ftdi.44.js +++ b/examples/hello.ftdi.44.js @@ -32,19 +32,19 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.47, y+.59), label: 'IC1\nt44'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, label: 'J1\nISP'}); -let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, label: 'J2 FTDI'}); -let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB3")-.2, IC1.padY("PA0")+.003), rotate: -90, label: 'XTAL1\n20 MHz'}); -let R1 = board.add(R_1206, {translate: pt(IC1.padX("VCC"), IC1.padY("VCC")+.1), label: 'R1\n10k'}); -let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND"), R1.posY), label: 'C1\n1uF'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.47, y+.59), id: 'IC1\nt44'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, id: 'J1\nISP'}); +let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, id: 'J2 FTDI'}); +let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB3")-.2, IC1.padY("PA0")+.003), rotate: -90, id: 'XTAL1\n20 MHz'}); +let R1 = board.add(R_1206, {translate: pt(IC1.padX("VCC"), IC1.padY("VCC")+.1), id: 'R1\n10k'}); +let C1 = board.add(C_1206, {translate: pt(IC1.padX("GND"), R1.posY), id: 'C1\n1uF'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -134,7 +134,7 @@ board.wire(path(J2.pad("GND"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -146,5 +146,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.ftdi.45.js b/examples/hello.ftdi.45.js index 2c45863..23f842f 100644 --- a/examples/hello.ftdi.45.js +++ b/examples/hello.ftdi.45.js @@ -28,19 +28,19 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny45_SOIC, {translate: pt(x+.53, y+.3), rotate: -90, label: 'IC1\nt45'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX-.31, IC1.posY-.02), rotate: 0, label: 'J1\nISP'}); -let R1 = board.add(R_1206, {translate: pt(IC1.padX("RST")+.09, IC1.posY), rotate: 90, label: 'R1\n10k'}); -let C1 = board.add(C_1206, {translate: pt(R1.posX+.1, R1.posY), rotate: 90, label: 'C1\n1uF'}); -let R2 = board.add(R_1206, {translate: pt((R1.posX+C1.posX)/2, R1.padY("1")-.1), label: 'R2 1k'}); -let J2 = board.add(header_FTDI, {translate: pt(x+width-.23, C1.posY+.05), label: 'J2 FTDI\n5V'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny45_SOIC, {translate: pt(x+.53, y+.3), rotate: -90, id: 'IC1\nt45'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX-.31, IC1.posY-.02), rotate: 0, id: 'J1\nISP'}); +let R1 = board.add(R_1206, {translate: pt(IC1.padX("RST")+.09, IC1.posY), rotate: 90, id: 'R1\n10k'}); +let C1 = board.add(C_1206, {translate: pt(R1.posX+.1, R1.posY), rotate: 90, id: 'C1\n1uF'}); +let R2 = board.add(R_1206, {translate: pt((R1.posX+C1.posX)/2, R1.padY("1")-.1), id: 'R2 1k'}); +let J2 = board.add(header_FTDI, {translate: pt(x+width-.23, C1.posY+.05), id: 'J2 FTDI\n5V'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -119,7 +119,7 @@ board.wire(path(J2.pad("Rx"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -131,5 +131,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.mag.D11C.js b/examples/hello.mag.D11C.js index d7e56f5..33b06a6 100644 --- a/examples/hello.mag.D11C.js +++ b/examples/hello.mag.D11C.js @@ -31,24 +31,24 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.5, y+.41), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_05, {translate: pt(IC1.posX, IC1.padY("CLK")-.11), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.18, IC1.padY("A08")), rotate: -90, label: 'IC2\n3.3'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX-.04, IC2.posY-.15), label: 'C1 1uF'}); -let IC3 = board.add(Hall_SOT23, {translate: pt(IC2.posX-.13, IC2.posY), rotate: -90, label: 'IC3\n1324'}); -let R1 = board.add(R_1206, {translate: pt(C1.posX, C1.posY-.1), label: 'R1 4.99k'}); -let R2 = board.add(R_1206, {translate: pt(R1.posX, R1.posY-.1), label: 'R2 10k'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.5, y+.41), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_05, {translate: pt(IC1.posX, IC1.padY("CLK")-.11), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.18, IC1.padY("A08")), rotate: -90, id: 'IC2\n3.3'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX-.04, IC2.posY-.15), id: 'C1 1uF'}); +let IC3 = board.add(Hall_SOT23, {translate: pt(IC2.posX-.13, IC2.posY), rotate: -90, id: 'IC3\n1324'}); +let R1 = board.add(R_1206, {translate: pt(C1.posX, C1.posY-.1), id: 'R1 4.99k'}); +let R2 = board.add(R_1206, {translate: pt(R1.posX, R1.posY-.1), id: 'R2 10k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -146,7 +146,7 @@ board.wire(path(R2.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -158,5 +158,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.mag.t412.js b/examples/hello.mag.t412.js index 7e95387..d2c51aa 100644 --- a/examples/hello.mag.t412.js +++ b/examples/hello.mag.t412.js @@ -29,18 +29,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny412, {translate: pt(x+.32, y+.44), label: 'IC1\nt412'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), label: 'C1 1uF'}); -let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.1), label: 'J1\nserial\n5V'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let IC2 = board.add(Hall_SOT23, {translate: pt(J2.padX("GND")-.11, J2.posY), rotate: -90, label: "IC2\nA1324"}); +let IC1 = board.add(ATtiny412, {translate: pt(x+.32, y+.44), id: 'IC1\nt412'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), id: 'C1 1uF'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.1), id: 'J1\nserial\n5V'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let IC2 = board.add(Hall_SOT23, {translate: pt(J2.padX("GND")-.11, J2.posY), rotate: -90, id: "IC2\nA1324"}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -105,7 +105,7 @@ board.wire(path(IC2.pad("gnd"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -117,5 +117,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.nRF24L01P.44.js b/examples/hello.nRF24L01P.44.js index 31bfa6a..ddac628 100644 --- a/examples/hello.nRF24L01P.44.js +++ b/examples/hello.nRF24L01P.44.js @@ -31,22 +31,22 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.68, y+.63), label: 'IC1\nt44'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, label: 'J1\nISP'}); -let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, label: 'J2 FTDI\n3.3V'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(J2.posX, J1.posY-.015), rotate: 180, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.12), label: 'C1 1uF'}); -let R1 = board.add(R_1206, {translate: pt(IC1.padX("VCC"), IC1.padY("VCC")+.1), label: 'R1\n10k'}); -let J3 = board.add(header_nRF24L01, {translate: pt(x+.22, IC1.posY+.05), label: 'J3\nnRF24L01'}); -let C2 = board.add(C_1206, {translate: pt(J3.posX, J3.padY("GND")-.1), label: 'C2 0.1uF'}); -let C3 = board.add(C_1206, {translate: pt(J3.posX, C2.posY-.1), label: 'C3 10uF'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.68, y+.63), id: 'IC1\nt44'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, id: 'J1\nISP'}); +let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, id: 'J2 FTDI\n3.3V'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(J2.posX, J1.posY-.015), rotate: 180, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-.12), id: 'C1 1uF'}); +let R1 = board.add(R_1206, {translate: pt(IC1.padX("VCC"), IC1.padY("VCC")+.1), id: 'R1\n10k'}); +let J3 = board.add(header_nRF24L01, {translate: pt(x+.22, IC1.posY+.05), id: 'J3\nnRF24L01'}); +let C2 = board.add(C_1206, {translate: pt(J3.posX, J3.padY("GND")-.1), id: 'C2 0.1uF'}); +let C3 = board.add(C_1206, {translate: pt(J3.posX, C2.posY-.1), id: 'C3 10uF'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -196,7 +196,7 @@ board.wire(path(C3.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -208,5 +208,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.serial-UPDI.3.js b/examples/hello.serial-UPDI.3.js index 0541a68..90518ce 100644 --- a/examples/hello.serial-UPDI.3.js +++ b/examples/hello.serial-UPDI.3.js @@ -27,16 +27,16 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, y+height/2), label: 'J1\nserial'}); -let J2 = board.add(header_UPDI_3_reverse, {translate: pt(x+.23, J1.padY("Rx")), label: 'J2\nUPDI'}); -let R1 = board.add(R_1206, {translate: pt(J2.posX, J1.padY("CTS")-.03), rotate: 90, label: 'R1\n4.99k'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, y+height/2), id: 'J1\nserial'}); +let J2 = board.add(header_UPDI_3_reverse, {translate: pt(x+.23, J1.padY("Rx")), id: 'J2\nUPDI'}); +let R1 = board.add(R_1206, {translate: pt(J2.posX, J1.padY("CTS")-.03), rotate: 90, id: 'R1\n4.99k'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -72,7 +72,7 @@ board.wire(path(J1.pad("Rx"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -84,5 +84,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.serial-UPDI.js b/examples/hello.serial-UPDI.js index c017c1a..a36b6e7 100644 --- a/examples/hello.serial-UPDI.js +++ b/examples/hello.serial-UPDI.js @@ -27,16 +27,16 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, y+height/2), label: 'J1\nFTDI'}); -let J2 = board.add(header_UPDI_reverse, {translate: pt(x+.23, y+height/2), label: 'J2\nUPDI'}); -let R1 = board.add(R_1206, {translate: pt(J2.posX, J1.padY("GND")-.05), label: 'R1 4.99k'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, y+height/2), id: 'J1\nFTDI'}); +let J2 = board.add(header_UPDI_reverse, {translate: pt(x+.23, y+height/2), id: 'J2\nUPDI'}); +let R1 = board.add(R_1206, {translate: pt(J2.posX, J1.padY("GND")-.05), id: 'R1 4.99k'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -65,7 +65,7 @@ board.wire(path(R1.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -77,5 +77,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.servo-D11C.js b/examples/hello.servo-D11C.js index 275e633..39d2094 100644 --- a/examples/hello.servo-D11C.js +++ b/examples/hello.servo-D11C.js @@ -33,24 +33,24 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+width-.68, y+.45), rotate: -90, label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.padX("CLK")-.14, IC1.posY), rotate: -90, label: 'J1\nSWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, y+height/2), rotate: 0, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A15"), IC1.padY("24-")-.18), rotate: 0, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX-.22, IC2.posY), label: 'C1\n1uF'}); -let R1 = board.add(R_1206, {translate: pt(IC1.padX("A04")-.04, IC2.posY), rotate: 90, label: 'R1\n1k'}); -let LED = board.add(LED_1206, {translate: pt(R1.posX+.1, R1.posY), rotate: -90, label: 'LED'}); -let J3 = board.add(header_servo_1H, {translate: pt(x+.23, y+height/2), label: 'J3\nservo'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+width-.68, y+.45), rotate: -90, id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.padX("CLK")-.14, IC1.posY), rotate: -90, id: 'J1\nSWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, y+height/2), rotate: 0, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A15"), IC1.padY("24-")-.18), rotate: 0, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX-.22, IC2.posY), id: 'C1\n1uF'}); +let R1 = board.add(R_1206, {translate: pt(IC1.padX("A04")-.04, IC2.posY), rotate: 90, id: 'R1\n1k'}); +let LED = board.add(LED_1206, {translate: pt(R1.posX+.1, R1.posY), rotate: -90, id: 'LED'}); +let J3 = board.add(header_servo_1H, {translate: pt(x+.23, y+height/2), id: 'J3\nservo'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 0.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 0.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 0.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 0.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -146,7 +146,7 @@ board.wire(path(J2.pad("GND"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -158,5 +158,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.servo.44.1.js b/examples/hello.servo.44.1.js index a21b591..8f0f061 100644 --- a/examples/hello.servo.44.1.js +++ b/examples/hello.servo.44.1.js @@ -31,21 +31,21 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.56, y+.6), label: 'IC1\nt44'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.24), rotate: 90, label: 'J1\nISP'}); -let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB0")-.19, IC1.padY("PB0")), rotate: -90, label: 'XTAL1\n20MHz'}); -let R1 = board.add(R_1206, {translate: pt(XTAL1.posX-.14, XTAL1.posY), rotate: -90, label: 'R1\n10k'}); -let J2 = board.add(header_power, {translate: pt(x+.18, y+height-.1), label: 'J2\npower'}); -let IC2 = board.add(regulator_SOT223_1, {translate: pt(J2.posX+.37, J2.posY-.04), rotate: -90, label: 'IC2\n5V'}); -let C1 = board.add(C_1206, {translate: pt(J2.posX, J2.posY-.14), rotate: 0, label: 'C1\n22uF'}); -let J3 = board.add(header_servo, {translate: pt(J2.posX+.03, J1.posY+.05), label: 'J3\nservo'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.56, y+.6), id: 'IC1\nt44'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.24), rotate: 90, id: 'J1\nISP'}); +let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB0")-.19, IC1.padY("PB0")), rotate: -90, id: 'XTAL1\n20MHz'}); +let R1 = board.add(R_1206, {translate: pt(XTAL1.posX-.14, XTAL1.posY), rotate: -90, id: 'R1\n10k'}); +let J2 = board.add(header_power, {translate: pt(x+.18, y+height-.1), id: 'J2\npower'}); +let IC2 = board.add(regulator_SOT223_1, {translate: pt(J2.posX+.37, J2.posY-.04), rotate: -90, id: 'IC2\n5V'}); +let C1 = board.add(C_1206, {translate: pt(J2.posX, J2.posY-.14), rotate: 0, id: 'C1\n22uF'}); +let J3 = board.add(header_servo, {translate: pt(J2.posX+.03, J1.posY+.05), id: 'J3\nservo'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -157,7 +157,7 @@ board.wire(path(IC1.pad("PA6"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -169,5 +169,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.servo.44.js b/examples/hello.servo.44.js index 63baec6..25d7a65 100644 --- a/examples/hello.servo.44.js +++ b/examples/hello.servo.44.js @@ -31,21 +31,21 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.56, y+.6), label: 'IC1\nt44'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.24), rotate: 90, label: 'J1\nISP'}); -let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB0")-.19, IC1.padY("PB0")), rotate: -90, label: 'XTAL1\n20MHz'}); -let R1 = board.add(R_1206, {translate: pt(XTAL1.posX-.14, XTAL1.posY), rotate: -90, label: 'R1\n10k'}); -let J2 = board.add(header_power, {translate: pt(x+.18, y+height-.14), label: 'J2\npower'}); -let IC2 = board.add(regulator_SOT223, {translate: pt(J2.posX+.37, J2.posY-.07), rotate: 180, label: 'IC2\n5V'}); -let C1 = board.add(C_1206, {translate: pt(J2.posX, J2.posY-.14), rotate: 0, label: 'C1\n10uF'}); -let J3 = board.add(header_servo, {translate: pt(J2.posX+.03, J1.posY+.05), label: 'J3\nservo'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.56, y+.6), id: 'IC1\nt44'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.24), rotate: 90, id: 'J1\nISP'}); +let XTAL1 = board.add(XTAL_EFOBM, {translate: pt(IC1.padX("PB0")-.19, IC1.padY("PB0")), rotate: -90, id: 'XTAL1\n20MHz'}); +let R1 = board.add(R_1206, {translate: pt(XTAL1.posX-.14, XTAL1.posY), rotate: -90, id: 'R1\n10k'}); +let J2 = board.add(header_power, {translate: pt(x+.18, y+height-.14), id: 'J2\npower'}); +let IC2 = board.add(regulator_SOT223, {translate: pt(J2.posX+.37, J2.posY-.07), rotate: 180, id: 'IC2\n5V'}); +let C1 = board.add(C_1206, {translate: pt(J2.posX, J2.posY-.14), rotate: 0, id: 'C1\n10uF'}); +let J3 = board.add(header_servo, {translate: pt(J2.posX+.03, J1.posY+.05), id: 'J3\nservo'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -160,7 +160,7 @@ board.wire(path(IC1.pad("PA6"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -172,5 +172,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.servo.t412.js b/examples/hello.servo.t412.js index 851b193..46f1a27 100644 --- a/examples/hello.servo.t412.js +++ b/examples/hello.servo.t412.js @@ -28,17 +28,17 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny412, {translate: pt(x+.47, y+.43), label: 'IC1\nt412'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), label: 'C1 1uF'}); -let J1 = board.add(header_UPDI_5V, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J1\nUPDI'}); -let J2 = board.add(header_servo, {translate: pt(IC1.posX-.32, J1.posY), rotate: -90, label: 'J2\nservos'}); +let IC1 = board.add(ATtiny412, {translate: pt(x+.47, y+.43), id: 'IC1\nt412'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), id: 'C1 1uF'}); +let J1 = board.add(header_UPDI_5V, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J1\nUPDI'}); +let J2 = board.add(header_servo, {translate: pt(IC1.posX-.32, J1.posY), rotate: -90, id: 'J2\nservos'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -98,7 +98,7 @@ board.wire(path(IC1.pad("PA1"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -110,5 +110,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.speaker.D11C.js b/examples/hello.speaker.D11C.js index 7b4bcc2..96609d8 100644 --- a/examples/hello.speaker.D11C.js +++ b/examples/hello.speaker.D11C.js @@ -33,24 +33,24 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+width-.68, y+.45), rotate: -90, label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.padX("CLK")-.14, IC1.posY), rotate: -90, label: 'J1\nSWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, y+height/2), rotate: 0, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05"), IC1.padY("24-")-.18), rotate: 0, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX-.22, IC2.posY), label: 'C1\n1uF'}); -let J3 = board.add(header_4, {translate: pt(J1.posX-.21, J1.posY), rotate: -90, label: 'J3\nspeaker'}); -let R1 = board.add(R_1206, {translate: pt(C1.posX-.21, C1.posY), label: 'R1\n0'}); -let T1 = board.add(NMOSFET_SOT23, {translate: pt(J3.posX, J3.posY-.3), rotate: 90, label: 'T1\nN'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+width-.68, y+.45), rotate: -90, id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.padX("CLK")-.14, IC1.posY), rotate: -90, id: 'J1\nSWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, y+height/2), rotate: 0, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05"), IC1.padY("24-")-.18), rotate: 0, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX-.22, IC2.posY), id: 'C1\n1uF'}); +let J3 = board.add(header_4, {translate: pt(J1.posX-.21, J1.posY), rotate: -90, id: 'J3\nspeaker'}); +let R1 = board.add(R_1206, {translate: pt(C1.posX-.21, C1.posY), id: 'R1\n0'}); +let T1 = board.add(NMOSFET_SOT23, {translate: pt(J3.posX, J3.posY-.3), rotate: 90, id: 'T1\nN'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 0.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 0.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 0.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 0.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -157,7 +157,7 @@ board.wire(path([T1.padX("S")-.02, y+.03], renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -169,5 +169,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.stepper.bipolar.D11C.js b/examples/hello.stepper.bipolar.D11C.js index e6221d5..6fdec6b 100644 --- a/examples/hello.stepper.bipolar.D11C.js +++ b/examples/hello.stepper.bipolar.D11C.js @@ -34,30 +34,30 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+width-.95, y+.3), rotate: -90, label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.padX("CLK")-.14, IC1.posY), rotate: -90, label: 'J1\nSWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, y+height/2), rotate: 0, label: 'J2\nUSB'}); -let IC2 = board.add(A4953_SOICN, {translate: pt(IC1.posX+.17, IC1.posY+.49), rotate: 90, label: 'IC2\nTB67H451FNG'}); -let IC3 = board.add(regulator_SOT23, {translate: pt(IC1.posX+.37, IC1.posY+.15), rotate: 90, label: 'IC3\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC3.posX-.11, IC3.posY), rotate: 90, label: 'C1\n1uF'}); -let C2 = board.add(C_1206, {translate: pt(IC2.posX+.16, IC2.posY+.06), rotate: 90, label: 'C2\n.1'}); -let C3 = board.add(C_1206, {translate: pt(IC2.posX+.26, IC2.posY+.06), rotate: 90, label: 'C3\n10uF'}); -let IC4 = board.add(A4953_SOICN, {translate: pt(IC2.posX-.42, IC2.posY), rotate: 90, label: 'IC4\nTB67H451FNG'}); -let C4 = board.add(C_1206, {translate: pt(IC4.posX+.16, IC4.posY+.02), rotate: 90, label: '.1'}); -let C5 = board.add(C_1206, {translate: pt(IC4.posX+.26, C4.posY), rotate: 90, label: '10uF'}); -let J3 = board.add(header_4H, {translate: pt(x+.23, y+height/2), rotate: 180, label: 'J3\nstepper'}); -let V1 = board.add(via(2*rv, 2*rp), {translate: pt(C4.posX, C4.padY("2")+.09), label: 'V1'}); -let V2 = board.add(via(2*rv, 2*rp), {translate: pt(C2.posX, C4.padY("2")+.18), label: 'V2'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+width-.95, y+.3), rotate: -90, id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4_1, {translate: pt(IC1.padX("CLK")-.14, IC1.posY), rotate: -90, id: 'J1\nSWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(x+width-.29, y+height/2), rotate: 0, id: 'J2\nUSB'}); +let IC2 = board.add(A4953_SOICN, {translate: pt(IC1.posX+.17, IC1.posY+.49), rotate: 90, id: 'IC2\nTB67H451FNG'}); +let IC3 = board.add(regulator_SOT23, {translate: pt(IC1.posX+.37, IC1.posY+.15), rotate: 90, id: 'IC3\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC3.posX-.11, IC3.posY), rotate: 90, id: 'C1\n1uF'}); +let C2 = board.add(C_1206, {translate: pt(IC2.posX+.16, IC2.posY+.06), rotate: 90, id: 'C2\n.1'}); +let C3 = board.add(C_1206, {translate: pt(IC2.posX+.26, IC2.posY+.06), rotate: 90, id: 'C3\n10uF'}); +let IC4 = board.add(A4953_SOICN, {translate: pt(IC2.posX-.42, IC2.posY), rotate: 90, id: 'IC4\nTB67H451FNG'}); +let C4 = board.add(C_1206, {translate: pt(IC4.posX+.16, IC4.posY+.02), rotate: 90, id: '.1'}); +let C5 = board.add(C_1206, {translate: pt(IC4.posX+.26, C4.posY), rotate: 90, id: '10uF'}); +let J3 = board.add(header_4H, {translate: pt(x+.23, y+height/2), rotate: 180, id: 'J3\nstepper'}); +let V1 = board.add(via(2*rv, 2*rp), {translate: pt(C4.posX, C4.padY("2")+.09), id: 'V1'}); +let V2 = board.add(via(2*rv, 2*rp), {translate: pt(C2.posX, C4.padY("2")+.18), id: 'V2'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 0.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 0.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 0.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 0.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -246,7 +246,7 @@ board.wire(path(V1.pad("via"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -258,5 +258,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.t1614.echo.js b/examples/hello.t1614.echo.js index 5fef9da..0e590f2 100644 --- a/examples/hello.t1614.echo.js +++ b/examples/hello.t1614.echo.js @@ -28,17 +28,17 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny1614, {translate: pt(x+.21, y+.5), label: 'IC1\nt1614'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), label: 'C1 1uF'}); -let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.05), label: 'J1\nFTDI'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2 UPDI'}); +let IC1 = board.add(ATtiny1614, {translate: pt(x+.21, y+.5), id: 'IC1\nt1614'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), id: 'C1 1uF'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.05), id: 'J1\nFTDI'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2 UPDI'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -89,7 +89,7 @@ board.wire(path(IC1.pad("RB3"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -101,5 +101,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.t3216.echo.js b/examples/hello.t3216.echo.js index 179329b..579d9d3 100644 --- a/examples/hello.t3216.echo.js +++ b/examples/hello.t3216.echo.js @@ -28,17 +28,17 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny3216, {translate: pt(x+.3, y+.58), label: 'IC1\nt3216'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.09), label: 'C1 1uF'}); -let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.05), label: 'J1\nFTDI'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2 UPDI'}); +let IC1 = board.add(ATtiny3216, {translate: pt(x+.3, y+.58), id: 'IC1\nt3216'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.09), id: 'C1 1uF'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.05), id: 'J1\nFTDI'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2 UPDI'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -87,7 +87,7 @@ board.wire(path(IC1.pad("TB2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -99,5 +99,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.t412.3.blink.js b/examples/hello.t412.3.blink.js index 2824ee3..2d02b35 100644 --- a/examples/hello.t412.3.blink.js +++ b/examples/hello.t412.3.blink.js @@ -29,18 +29,18 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny412, {translate: pt(x+.18, y+.43), label: 'IC1\nt412'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), label: 'C1 1uF'}); -let J1 = board.add(header_UPDI_3, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J1\nUPDI'}); -let R1 = board.add(R_1206, {translate: pt(IC1.posX+.23, IC1.posY-.01), rotate: 90, label: 'R1\n1k'}); -let LED1 = board.add(LED_1206, {translate: pt(R1.posX, R1.posY-.23), rotate: -90, label: 'LED1'}); +let IC1 = board.add(ATtiny412, {translate: pt(x+.18, y+.43), id: 'IC1\nt412'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), id: 'C1 1uF'}); +let J1 = board.add(header_UPDI_3, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J1\nUPDI'}); +let R1 = board.add(R_1206, {translate: pt(IC1.posX+.23, IC1.posY-.01), rotate: 90, id: 'R1\n1k'}); +let LED1 = board.add(LED_1206, {translate: pt(R1.posX, R1.posY-.23), rotate: -90, id: 'LED1'}); -let interior = geo.path(path([x, y+height], +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -84,7 +84,7 @@ board.wire(path(LED1.pad("A"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -96,5 +96,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.t412.blink.js b/examples/hello.t412.blink.js index 5a969a4..a86cfd8 100644 --- a/examples/hello.t412.blink.js +++ b/examples/hello.t412.blink.js @@ -29,19 +29,19 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny412, {translate: pt(x+.19, y+.36), label: 'IC1\nt412'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), label: 'C1 1uF'}); -let R1 = board.add(R_1206, {translate: pt(IC1.posX, IC1.padY("PA1")-.08), label: 'R1 1k'}); -let LED1 = board.add(LED_1206, {translate: pt(R1.posX, R1.posY-.1), label: 'LED1'}); -let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.05), label: 'J1\nFTDI'}); -let R2 = board.add(R_1206, {translate: pt(J1.posX-.12, J1.padY("Tx")-.05), rotate: 90, label: 'R2\n4.99k'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny412, {translate: pt(x+.19, y+.36), id: 'IC1\nt412'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), id: 'C1 1uF'}); +let R1 = board.add(R_1206, {translate: pt(IC1.posX, IC1.padY("PA1")-.08), id: 'R1 1k'}); +let LED1 = board.add(LED_1206, {translate: pt(R1.posX, R1.posY-.1), id: 'LED1'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.05), id: 'J1\nFTDI'}); +let R2 = board.add(R_1206, {translate: pt(J1.posX-.12, J1.padY("Tx")-.05), rotate: 90, id: 'R2\n4.99k'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -95,7 +95,7 @@ board.wire(path(R2.pad("2"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -107,5 +107,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.txrx.t1624.js b/examples/hello.txrx.t1624.js index 936c157..d6b4624 100644 --- a/examples/hello.txrx.t1624.js +++ b/examples/hello.txrx.t1624.js @@ -30,20 +30,20 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny1614, {translate: pt(x+width-.5, y+.51), label: 'IC1\nt1624'}); -let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), label: 'C1 1uF'}); -let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.1), label: 'J1\nserial'}); -let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, label: 'J2\nUPDI'}); -let J3 = board.add(header_txrx, {translate: pt(x+.13, y+.41), rotate: 90, label: 'J3\nTxRx'}); -let R1 = board.add(R_1206, {translate: pt(J3.posX, J3.posY+.22), label: 'R1 1M'}); -let R2 = board.add(R_1206, {translate: pt(R1.posX, R1.posY+.1), label: 'R2 1M'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny1614, {translate: pt(x+width-.5, y+.51), id: 'IC1\nt1624'}); +let C1 = board.add(C_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.08), id: 'C1 1uF'}); +let J1 = board.add(header_FTDI, {translate: pt(x+width-.23, IC1.posY-.1), id: 'J1\nserial'}); +let J2 = board.add(header_UPDI, {translate: pt(IC1.posX, y+.23), rotate: 90, id: 'J2\nUPDI'}); +let J3 = board.add(header_txrx, {translate: pt(x+.13, y+.41), rotate: 90, id: 'J3\nTxRx'}); +let R1 = board.add(R_1206, {translate: pt(J3.posX, J3.posY+.22), id: 'R1 1M'}); +let R2 = board.add(R_1206, {translate: pt(R1.posX, R1.posY+.1), id: 'R2 1M'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -136,7 +136,7 @@ board.wire(path(C1.pad("1"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -148,5 +148,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.uSD.44.js b/examples/hello.uSD.44.js index 6706bb5..07782f0 100644 --- a/examples/hello.uSD.44.js +++ b/examples/hello.uSD.44.js @@ -31,20 +31,20 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.86, y+.59), label: 'IC1\nt44'}); -let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, label: 'J1\nISP'}); -let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, label: 'J2 FTDI'}); -let R1 = board.add(R_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.1), label: 'R1\n10k'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(J2.posX-.16, J2.padY("CTS")), rotate: 90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX-.12, IC2.posY), rotate: 90, label: 'C1\n1uF'}); -let J3 = board.add(microSD, {translate: pt(IC1.posX-.42, IC1.posY-.1), rotate: -90, label: 'J3\nmicroSD'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(ATtiny44_SOICN, {translate: pt(x+.86, y+.59), id: 'IC1\nt44'}); +let J1 = board.add(header_ISP, {translate: pt(IC1.posX+.05, IC1.padY("PA6")-.22), rotate: 90, id: 'J1\nISP'}); +let J2 = board.add(header_FTDI, {translate: pt(x+width-.22, IC1.posY-.0), rotate: 0, id: 'J2 FTDI'}); +let R1 = board.add(R_1206, {translate: pt(IC1.posX, IC1.padY("VCC")+.1), id: 'R1\n10k'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(J2.posX-.16, J2.padY("CTS")), rotate: 90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX-.12, IC2.posY), rotate: 90, id: 'C1\n1uF'}); +let J3 = board.add(microSD, {translate: pt(IC1.posX-.42, IC1.posY-.1), rotate: -90, id: 'J3\nmicroSD'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -174,7 +174,7 @@ board.wire(path(J3.pad("MISO"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -186,5 +186,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/hello.uSD.D11C.js b/examples/hello.uSD.D11C.js index 09b301a..184c481 100644 --- a/examples/hello.uSD.D11C.js +++ b/examples/hello.uSD.D11C.js @@ -31,24 +31,24 @@ let board = new PCB(); /* -- ADD_COMPONENTS -- */ -let IC1 = board.add(SAMD11C, {translate: pt(x+.95, y+.56), label: 'IC1\nD11C'}); -let J1 = board.add(header_SWD_4, {translate: pt(IC1.posX, IC1.padY("CLK")-.13), label: 'J1 SWD'}); -let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, label: 'J2\nUSB'}); -let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.77, IC1.padY("CLK")-.17), rotate: -90, label: 'IC2\n3.3V'}); -let C1 = board.add(C_1206, {translate: pt(IC2.posX+.04, IC2.posY-.15), rotate: 0, label: 'C1 1uF'}); -let J3 = board.add(microSD, {translate: pt(IC1.posX-.4, IC1.posY-.13), rotate: -90, label: 'J3 uSD'}); -let R1 = board.add(R_1206, {translate: pt(J3.padX("GND")-.11, J3.padY("GND")+.03), rotate: 90, label: 'R1\n0'}); -let R2 = board.add(R_1206, {translate: pt(IC1.padX("VDD")+.1, IC1.padY("VDD")), rotate: 90, label: 'R2\n0'}); - -let interior = geo.path(path([x, y+height], +let IC1 = board.add(SAMD11C, {translate: pt(x+.95, y+.56), id: 'IC1\nD11C'}); +let J1 = board.add(header_SWD_4, {translate: pt(IC1.posX, IC1.padY("CLK")-.13), id: 'J1 SWD'}); +let J2 = board.add(USB_A_plug, {translate: pt(IC1.posX, y+height-.29), rotate: 90, id: 'J2\nUSB'}); +let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A05")-.77, IC1.padY("CLK")-.17), rotate: -90, id: 'IC2\n3.3V'}); +let C1 = board.add(C_1206, {translate: pt(IC2.posX+.04, IC2.posY-.15), rotate: 0, id: 'C1 1uF'}); +let J3 = board.add(microSD, {translate: pt(IC1.posX-.4, IC1.posY-.13), rotate: -90, id: 'J3 uSD'}); +let R1 = board.add(R_1206, {translate: pt(J3.padX("GND")-.11, J3.padY("GND")+.03), rotate: 90, id: 'R1\n0'}); +let R2 = board.add(R_1206, {translate: pt(IC1.padX("VDD")+.1, IC1.padY("VDD")), rotate: 90, id: 'R2\n0'}); + +let outline = geo.path(path([x, y+height], [x+width, y+height], [x+width, y], [x, y])); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); -geo.difference(interior, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY]), 90.00000001, J2.pos)); +geo.difference(outline, geo.rotate(geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY]), 90.00000001, J2.pos)); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -155,7 +155,7 @@ board.wire(path(IC1.pad("A04"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#be7a27cc", "B.Mask": "#ff814bff", @@ -167,5 +167,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/qr-quine.js b/examples/qr-quine.js index 5f681e5..63cf12b 100644 --- a/examples/qr-quine.js +++ b/examples/qr-quine.js @@ -39,7 +39,7 @@ const border = 0.05 // rendering border /* -- DECLARE_PCB -- */ let board = new PCB(); -let interior = geo.translate(geo.rectangle(width, height), [x+width/2, y+height/2]); +let outline = geo.translate(geo.rectangle(width, height), [x+width/2, y+height/2]); /* -- ADD_COMPONENTS -- */ @@ -51,11 +51,11 @@ let C2 = board.add(C_1206, {translate: pt(IC1.padX("A07")-.02, IC1.padY("VAN")-. let IC2 = board.add(regulator_SOT23, {translate: pt(C2.posX-.11, C2.posY), rotate: -90, name: 'IC2\n3.3V'}); board.add(qr_code, { translate: pt(0.8, 1.5), rotate: 0, name: "qr_code" }) -geo.difference(interior, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY])); -geo.difference(interior, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY])); -geo.union(interior, geo.translate(geo.rectangle(0.5, 1.05), pt(0.833, 1.525))); +geo.difference(outline, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, 5.12+J2.posY])); +geo.difference(outline, geo.translate(geo.rectangle(1.05, 9.76), [0.475+J2.posX, -5.12+J2.posY])); +geo.union(outline, geo.translate(geo.rectangle(0.5, 1.05), pt(0.833, 1.525))); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ @@ -153,7 +153,7 @@ board.wire(path(IC2.pad("gnd"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#ff8c00cc", "drill": "#ff3300e5", @@ -164,5 +164,5 @@ renderPCB({ x: [x-border - 0.43, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/scf-qr-spline.js b/examples/scf-qr-spline.js index bf104c9..fc4ca6b 100644 --- a/examples/scf-qr-spline.js +++ b/examples/scf-qr-spline.js @@ -76,10 +76,10 @@ let J2 = board.add(USB_A_plug, {translate: pt(-0.05916114, 0.01358479), rotate: let IC2 = board.add(regulator_SOT23, {translate: pt(IC1.padX("A04")+.15, IC1.padY("A08")-.005), rotate: 90, name: 'IC2\n3.3V'}); let C1 = board.add(C_1206, {translate: pt(IC2.posX, IC2.posY-0.2), rotate: 90, name: 'C1\n1uF'}); -let interior = geo.translate(geo.rectangle(0.48, 0.58), [J2.posX, J2.posY]); +let outline = geo.translate(geo.rectangle(0.48, 0.58), [J2.posX, J2.posY]); -let interior2 = path([-0.2, -0.04], +let outline2 = path([-0.2, -0.04], ["bezier", [-3.7, -0.10], [0.42, 0.17], [-4.89, -4.05], @@ -89,8 +89,8 @@ let interior2 = path([-0.2, -0.04], [0.0, -0.04]], [0.2, -0.04]); -board.addShape("interior", interior); -board.addShape("interior", interior2); +board.addShape("outline", outline); +board.addShape("outline", outline2); /* -- ADD_WIRES -- */ board.wire(path(J1.pad("CLK"), @@ -192,7 +192,7 @@ board.wire(path(J2.pad("5V"), renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#ff8c00cc", "drill": "#ff3300e5", @@ -203,5 +203,5 @@ renderPCB({ x: [x-border, x+width+border], y: [y-border, y+height+border] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/test_footprint.js b/examples/test_footprint.js index 58877d8..9ad6d5a 100644 --- a/examples/test_footprint.js +++ b/examples/test_footprint.js @@ -40,7 +40,7 @@ test_comp1 = board.add(test_footprint, {translate: pt(0.35, 0.65), name: "COMP1" renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#ff8c00cc", "drill": "#ff3300e5", @@ -51,5 +51,5 @@ renderPCB({ x: [0, 1], y: [0, 1] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/examples/test_wires.js b/examples/test_wires.js index 905248e..6f5c440 100644 --- a/examples/test_wires.js +++ b/examples/test_wires.js @@ -86,7 +86,7 @@ board.wire(path( renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#ff8c00cc", //"padLabels": "#ffff99e5", @@ -96,5 +96,5 @@ renderPCB({ x: [0, 1], y: [0, 1] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }) diff --git a/geogram/fillet.js b/geogram/fillet.js index 96d0768..c628701 100644 --- a/geogram/fillet.js +++ b/geogram/fillet.js @@ -1,106 +1,137 @@ -const overlap = (p1, p2) => length(p1, p2) < 0.000001; -const length = ([x1, y1], [x2, y2]) => Math.sqrt((x2-x1)**2 + (y2-y1)**2); -const magDiff = (p0, p1) => Math.sqrt( - (p1[0] - p0[0])**2 + - (p1[1] - p0[1])**2 -) -const normDiff = (p0, p1) => { - const m = magDiff(p0, p1); +export function fillet(shape, index, radius) { - return [ (p1[0] - p0[0])/m, (p1[1] - p0[1])/m ]; -} + if (typeof index === "number") index = [index]; -const norm = vec => { - const mag = Math.sqrt(vec[0]**2 + vec[1]**2); + let cornerIndex = 0; - return [ vec[0]/mag, vec[1]/mag ]; -} + let final = []; -const slerp = (t, p0, p1, angle) => { - const factor1 = Math.sin(angle*(1-t))/Math.sin(angle); - const factor2 = Math.sin(angle*t)/Math.sin(angle); - return [p0[0]*factor1 + p1[0]*factor2, p0[1]*factor1 + p1[1]*factor2] -} + for (const path of shape) { -export function fillet(shape, index, radius) { + final.push([]); + + for (let i = 1; i < path.length - 1; i++) { + + let prevPt = path[i - 1]; + let pt = path[i]; + let nextPt = path[i + 1]; + + if (i === 1) final.at(-1).push(prevPt); + + if (!index.includes(cornerIndex)) { + final.at(-1).push(pt); + if (i === path.length - 2) final.at(-1).push(nextPt); + + cornerIndex++; + + continue; + } - let [ _, radius, pt ] = cmd; + cornerIndex++; - if (radius < 0) radius = 0.00000001; + if (radius < 0) radius = 0.00000001; + if (overlap(pt, prevPt) || overlap(pt, nextPt)) continue; - if (prevPt && nextPt) return; - if (overlap(pt, prevPt) || overlap(pt, nextPt)) return; + const prevNorm = normDiff(pt, prevPt); + const nextNorm = normDiff(pt, nextPt); - const prevNorm = normDiff(pt, prevPt); - const nextNorm = normDiff(pt, nextPt); + const angle = Math.acos( + (prevNorm[0] * nextNorm[0]) + + (prevNorm[1] * nextNorm[1]) + ) - const angle = Math.acos( - (prevNorm[0] * nextNorm[0]) + - (prevNorm[1] * nextNorm[1]) - ) + let dist = radius/Math.tan(angle/2); - let dist = radius/Math.tan(angle/2); + const maxStartDist = length(prevPt, pt); + const maxEndDist = length(nextPt, pt); - const maxStartDist = length(prevPt, pt); - const maxEndDist = length(nextPt, pt); + dist = Math.min(maxStartDist, maxEndDist, dist); + radius = Math.min(dist*Math.tan(angle/2), radius); - dist = Math.min(maxStartDist, maxEndDist, dist); - radius = Math.min(dist*Math.tan(angle/2), radius); + const start = [ + pt[0] + prevNorm[0]*dist, + pt[1] + prevNorm[1]*dist + ] - const start = [ - pt[0] + prevNorm[0]*dist, - pt[1] + prevNorm[1]*dist - ] + const end = [ + pt[0] + nextNorm[0]*dist, + pt[1] + nextNorm[1]*dist, + ] - const end = [ - pt[0] + nextNorm[0]*dist, - pt[1] + nextNorm[1]*dist, - ] + const newPts = []; - const newPts = []; - // newPts.push(start); + const midNorm = norm([ + (prevNorm[0] + nextNorm[0]), + (prevNorm[1] + nextNorm[1]) + ]); - const midNorm = norm([ - (prevNorm[0] + nextNorm[0]), - (prevNorm[1] + nextNorm[1]) - ]); + const midDist = Math.sqrt(dist**2 + radius**2); - const midDist = Math.sqrt(dist**2 + radius**2); + const midPt = [ + pt[0] + midNorm[0]*midDist, + pt[1] + midNorm[1]*midDist + ]; - const midPt = [ - pt[0] + midNorm[0]*midDist, - pt[1] + midNorm[1]*midDist - ]; + const aStart = Math.atan2( + start[0] - midPt[0], + start[1] - midPt[1], + ) - const aStart = Math.atan2( - start[0] - midPt[0], - start[1] - midPt[1], - ) + const arcAngle = Math.PI - angle; - const arcAngle = Math.PI - angle; + const startMid = [ + start[0] - midPt[0], + start[1] - midPt[1] + ] - const startMid = [ - start[0] - midPt[0], - start[1] - midPt[1] - ] + const endMid = [ + end[0] - midPt[0], + end[1] - midPt[1] + ] - const endMid = [ - end[0] - midPt[0], - end[1] - midPt[1] - ] + for (let i = 1/20; i < 1; i += 1/20) { + const [ x, y ] = slerp(i, startMid, endMid, arcAngle) - for (let i = 1/20; i < 1; i += 1/20) { - const [ x, y ] = slerp(i, startMid, endMid, arcAngle) + let pt = [ + midPt[0] + x, + midPt[1] + y + ] - let pt = [ - midPt[0] + x, - midPt[1] + y - ] + newPts.push(pt); + } - newPts.push(pt); + final.at(-1).push(...newPts); + + if (i === path.length - 2) final.at(-1).push(nextPt); + } } + while (shape.length) shape.pop(); + final.forEach(el => shape.push(el)); + + return shape; +} - // newPts.push(end); - pts.push(...newPts); +const overlap = (p1, p2) => length(p1, p2) < 0.000001; +const length = ([x1, y1], [x2, y2]) => Math.sqrt((x2-x1)**2 + (y2-y1)**2); +const magDiff = (p0, p1) => Math.sqrt( + (p1[0] - p0[0])**2 + + (p1[1] - p0[1])**2 +) +const normDiff = (p0, p1) => { + const m = magDiff(p0, p1); + + return [ (p1[0] - p0[0])/m, (p1[1] - p0[1])/m ]; +} + +const norm = vec => { + const mag = Math.sqrt(vec[0]**2 + vec[1]**2); + + return [ vec[0]/mag, vec[1]/mag ]; +} + +const slerp = (t, p0, p1, angle) => { + const factor1 = Math.sin(angle*(1-t))/Math.sin(angle); + const factor2 = Math.sin(angle*t)/Math.sin(angle); + return [p0[0]*factor1 + p1[0]*factor2, p0[1]*factor1 + p1[1]*factor2] } diff --git a/geogram/index.js b/geogram/index.js index 4ce49b0..5056b71 100644 --- a/geogram/index.js +++ b/geogram/index.js @@ -13,6 +13,8 @@ import { extrema } from "./extrema.js"; import { turnForward } from "./turnForward.js"; import { path } from "./path.js"; import { path as path2 } from "./path2.js"; +import { fillet } from "./fillet.js"; + const overlap = (p0, p1) => 0.00000001 > Math.abs(p0[0] - p1[0]) + Math.abs(p0[1] - p1[1]); const isClosed = shape => { @@ -217,8 +219,8 @@ export { reverse, thicken, copyPaste, - offset, - offset2, + offset, // TODO: how do these differ? one has issues flattening + offset2, // TODO: how do these differ? one has issues flattening outline, expand, intersect, @@ -240,5 +242,8 @@ export { path, path2, boolean, - convertPtType + convertPtType, + transform, + copy, + fillet } diff --git a/geogram/roundCorners.js b/geogram/roundCorners.js index 844a4b3..6533e26 100644 --- a/geogram/roundCorners.js +++ b/geogram/roundCorners.js @@ -1,4 +1,4 @@ -export function roundCorners(shape) { +export function roundCorners(shape, cornerIndexs, radius) { -} \ No newline at end of file +} \ No newline at end of file diff --git a/geogram/transform.js b/geogram/transform.js index dc0af53..3283d1c 100644 --- a/geogram/transform.js +++ b/geogram/transform.js @@ -2,13 +2,20 @@ const mapPtFromRule = rule => ([ x, y ]) => { const [ a, b, c, d, tx, ty ] = getMatrixRule(rule); - return { - x: x * a + y * c + tx, - y: x * b + y * d + ty - }; + return [ + x * a + y * c + tx, + x * b + y * d + ty + ]; } function getMatrixRule({ dx, dy, sx, sy, rotate, skew }) { + dx ??= 0 + dy ??= 0 + sx ??= 1 + sy ??= 1 + rotate ??= 0 + skew ??= 0 + rotate = rotate/180*Math.PI; return getMatrix(dx, dy, sx, sy, rotate, skew); } @@ -60,7 +67,6 @@ function getMatrix(dx, dy, sx, sy, angle, skewness) { export function transform(shape, transformations) { const fn = mapPtFromRule(transformations); shape.forEach((pl, i) => { - console.log(pl.map(fn)); shape[i] = pl.map(fn); }) diff --git a/js/astAnalysis.js b/js/astAnalysis.js index 8906fe1..d9ee433 100644 --- a/js/astAnalysis.js +++ b/js/astAnalysis.js @@ -1,5 +1,3 @@ -// import * as esprima from 'esprima'; - const FUNCTIONS_STATIC_INFO = [ "pt", "path", diff --git a/js/checkConnectivity.js b/js/checkConnectivity.js index c48ff97..8fb5cae 100644 --- a/js/checkConnectivity.js +++ b/js/checkConnectivity.js @@ -32,7 +32,7 @@ export function checkConnectivity(pcb) { } }) - // compare islands to board.netList + // compare islands to board.netlist console.log(islands); } diff --git a/js/components/footprint-editor/footprint-editor-v0.js b/js/components/footprint-editor/footprint-editor-v0.js new file mode 100644 index 0000000..b1d22a4 --- /dev/null +++ b/js/components/footprint-editor/footprint-editor-v0.js @@ -0,0 +1,966 @@ +import { createListener } from "../../events.js"; +import { html, render, svg } from "lit-html"; +import * as icons from "./icons.js"; +import { copy, pathD, getPathData, extrema, transform } from "../../../geogram/index.js"; +import { testFootprint } from "./testFootprint.js"; + +class FootprintEditor extends HTMLElement { + static get observedAttributes() { + return ["footprint"]; + } + + attributeChangedCallback(name, oldValue, newValue) { + if (name === "footprint") { + this.footprint = newValue; + this.render(); + } + } + + set footprint(newVal) { + this._footprint = JSON.parse(newVal); + + for (const pad in this.footprint) { + const data = this.footprint[pad]; + this.transformations[pad] = { + _path: pathD([], data.shape), + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotate: 0 + } + } + + } + + get footprint() { + return this._footprint; + } + + constructor() { + super(); + + this.initialized = false; + this._footprint = this.getAttribute("footprint") ?? ""; + this.selectedPad = null; + + this.transformations = {}; + this.selectedGeometry = new Set(); + + this.render(); + + this.panZoomFns = addPanZoom( + this.querySelector("svg"), + ({ scale, pointX, pointY }) => { + const els = this.querySelectorAll("[data-circle-handle]"); + + for (const el of els) { + el.setAttribute("r", 6 / scale); + } + + const fixedScales = this.querySelectorAll("[data-fixed-scale]"); + for (const el of fixedScales) { + el.style.transformOrigin = `${0}px ${0}px`; + el.style.transform = `translate(${pointX}px, ${pointY}px)`; + } + + // this.render(); + const transformHandle = this.querySelector("#transform-handle"); + if (transformHandle) { + const centerX = Number(transformHandle.dataset.centerX); + const centerY = Number(transformHandle.dataset.centerY); + transformHandle.style=`transform: + translate( + ${centerX*scale + pointX}px, + ${centerY*scale + pointY}px + )`; + } + + } + ); + + addPtDragging(this, this.panZoomFns); + + const listener = createListener(this); + + listener("click", "[data-trigger-click-layer]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + const newLayersStr = prompt( + "Please input new layers", + this.footprint[padname].layers.join(" "), + ); + + // check that layers are a list and strings + + if (newLayersStr === null) return; + + let newLayers = newLayersStr.split(" "); + this.footprint[padname].layers = newLayers; + + this.render(); + }); + + listener("click", "[data-trigger-click-padName]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + const newName = prompt( + "Please input a new pad name", + e.target.innerText, + ); + + if (newName === null) return; + if (Object.keys(this.footprint).includes(newName)) return; + + const invalidCharsRegex = /[^a-zA-Z_$\d]|(?<=^[^a-zA-Z_$])[\d]/g; + const invalid = newName.match(invalidCharsRegex) !== null; + if (invalid) return; + + const temp = this.footprint[padname]; + this.footprint[newName] = temp; + + const tempTrans = this.transformations[padname]; + this.transformations[newName] = tempTrans; + + delete this.footprint[padname]; + delete this.transformations[padname]; + + this.render(); + }); + + listener("click", "[data-trigger-click-close]", (e) => { + this.classList.add("hidden"); + }); + + listener("click", "[data-trigger-click-delete]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + delete this.footprint[padname]; + delete this.transformations[padname]; + + this.selectedGeometry.delete(padname); + + this.render(); + }); + + // let startX = 0; + // let startY = 0; + // listener("mousedown", "", e => { + // startX = e.clientX; + // startY = e.clientY; + // }) + + // listener("mouseup", ":not([data-trigger-click-geometry])", (e) => { + // const dx = e.clientX - startX; + // const dy = e.clientY - startY; + // if (dx > 2 || dy > 2) return; + // if (e.shiftKey) return + // this.selectedGeometry.clear(); + // this.render(); + // }); + + window.addEventListener("keydown", e => { + const { code } = e; + if (code === "Escape") { + this.selectedGeometry.clear(); + this.render(); + } + }) + + listener("mousedown", "[data-trigger-click-geometry]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + this.selectedPad = padname; + if (e.shiftKey && this.selectedGeometry.has(padname)) { + this.selectedGeometry.delete(padname); + } else if (e.shiftKey && !this.selectedGeometry.has(padname)) { + this.selectedGeometry.add(padname); + } else { + this.selectedGeometry.clear(); + this.selectedGeometry.add(padname); + } + + this.render(); + }); + + listener("mousedown", "[data-trigger-click-pad]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + this.selectedPad = padname; + + this.render(); + }); + + listener("mousedown", "[data-trigger-add-pad]", (e) => { + let maxIndex = 0; + for (const [ padName, data ] of Object.entries(this.footprint)) { + maxIndex = Math.max(maxIndex, data.index ?? 0); + } + + maxIndex++; + + const padName = `_${maxIndex}`; + this.footprint[padName] = { + index: maxIndex, + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0, 0.05], + layers: ["F.Cu"] + } + + this.transformations[padName] = { + _path: pathD([], this.footprint[padName].shape), + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotate: 45 + } + + this.selectedPad = padName; + + this.render(); + + this.panZoomFns.applyTransformation(); + + }); + } + + connectedCallback() { + this.setAttribute("footprint", testFootprint); + + this.initialized = true; + + this.panZoomFns.setScaleXY({ + x: [-0.2, 0.2], + y: [-0.2, 0.2], + }); + + if (this.hasAttribute("footprint")) { + + } + } + + id = null; + + render() { + + let xMin = Infinity; + let xMax = -Infinity; + let yMin = Infinity; + let yMax = -Infinity; + + Array.from(this.selectedGeometry).forEach(pad => { + const data = this.footprint[pad]; + const geo = this.transformations[pad]; + const path = copy(geo._path); + + transform(path, { + dx: data.pos[0] + geo.translateX, + dy: data.pos[1] + geo.translateY, + sx: geo.scaleX, + sy: geo.scaleY, + rotate: geo.rotate + }) + + const e = extrema(path); + + xMin = Math.min(xMin, e.xMin); + xMax = Math.max(xMax, e.xMax); + yMin = Math.min(yMin, e.yMin); + yMax = Math.max(yMax, e.yMax); + }) + + const centerX = (xMax+xMin)/2; + const centerY = (yMax+yMin)/2; + + const transformHandle = () => { + + if (this.selectedGeometry.size === 0) return ""; + if (this.panZoomFns === null) return; + + return svg` + + + + + + + + + + + + + + + + + + + + + + + + + ` + } + + render(html` +
+
+
+ ${Object + .entries(this.footprint) + .sort((a, b) => a[1]?.index - b[1]?.index) + .map(x => footprintMenuItem(x, this.selectedPad, this.transformations[x[0]]))} +
+
+ add pad +
+
+
+ + + ${Object.entries(this.footprint).map(x => drawFootprint(x, this.transformations[x[0]], this))} + ${this.selectedGeometry.size > 0 ? svg`` : ""} + + + ${transformHandle()} + + ${transformPanel(this)} +
+
+ close +
+
+ `, this); + + + + const scrollToEl = this.querySelector("[data-selected-pad]"); + if (scrollToEl) { + scrollToEl.scrollIntoView(); + if (this.id) clearTimeout(this.id); + this.id = setTimeout(() => { + this.selectedPad = null; + this.render(); + }, 1000); + } + + // if (!this.panZoomFns) return; + + // const selectedGeoPaths = Array.from(this.querySelectorAll("[data-selected-geo]")); + + // if (selectedGeoPaths.length === 0) return; + + // const bb = getCombinedBoundingBox(selectedGeoPaths); + + // // const {x, y} = this.panZoomFns.svgPoint({ x: bb.x, y: bb.y }); + // // const width = bb.width/this.panZoomFns.scale(); + // // const height = bb.height/this.panZoomFns.scale(); + + // // const normed = normalizeDimensions({ + // // x, + // // y, + // // width, + // // height + // // }); + + // const normed = normalizeDimensions(bb); + } +} + +function affineTransform(el) { + + if (el.selectedGeometry.size !== 1) return "" + + const padName = [...el.selectedGeometry].at(0); + + const transformation = el.transformations[padName]; + + const { translateX, translateY, scaleX, scaleY, rotate } = transformation; + + const affineValueChange = (e, key) => { + // validate number + const n = Number(e.target.value); + + if (!isNaN(n)) { + transformation[key] = n; + el.render(); + } else { + e.target.value = transformation[key]; + } + } + + return html` +
+
+ tx: + affineValueChange(e, "translateX")} .value=${translateX}/> +
+
+ ty: + affineValueChange(e, "translateY")} .value=${translateY}/> +
+
+
+
+ sx: + affineValueChange(e, "scaleX")} .value=${scaleX}/> +
+
+ sy: + affineValueChange(e, "scaleY")} .value=${scaleY}/> +
+
+
+ rt: + affineValueChange(e, "rotate")} .value=${rotate}/> +
+ `; +} + +function footprintMenuItem([padName, data], selectedPad, transformation) { + return html` +
+
+
+ pad: + + ${padName} + +
+
x
+
+
+ +
pos: [ ${data.pos.map(x => x.toFixed(2)).join(", ")} ]
+ +
+ shape: + + "${data.shape}" + +
+ + layers: + + ${data.layers.join(", ")} + + +
drill: ${data.drill ?? "none"}
+
+ ${data.drill ? html`
diameter: ${data.drill.diameter}
`: ""} + ${data.drill ? html`
startLayer: ${data.drill.start}
`: ""} + ${data.drill ? html`
endLayer: ${data.drill.end}
`: ""} + ${data.drill ? html`
plated: ${data.drill.plated}
` : ""} +
+ +
maskOffset: ${data.maskOffset ?? "0"}
+
index: ${data.index ?? "none"}
+
+
+ ` +} + +function drawFootprint([padName, data], transformation, el) { + return svg` + + + + + `; +} + +function transformPanel(el) { + return html` +
+
+ ${el.selectedGeometry.size} + selected + { + el.selectedGeometry.clear(); + el.render(); + }} class="float-right hover:cursor-pointer hover:text-red-500">clear +
+
+ + ${icons.flipHorz} + + + + ${icons.flipVert} + + + + ${icons.rotate90cw} + + + + ${icons.rotate90ccw} + + +
+
+ + ${icons.leftAlign} + + + + ${icons.centerAlignHorz} + + + + ${icons.rightAlign} + + + + ${icons.distributeHorz} + + +
+
+ + ${icons.topAlign} + + + + ${icons.centerAlignVert} + + + + ${icons.bottomAlign} + + + + ${icons.distributeVert} + + +
+
+ ${affineTransform(el)} +
+
+ ` +} + +// this.dispatchEvent(new CustomEvent('colorChange', { detail: +// { +// value: hex +// } +// })); + +customElements.define("footprint-editor", FootprintEditor); + +function addPanZoom(parentEl, onApplyTransformation = () => {}) { + const listen = createListener(parentEl); + + let mousedown = false; + + let scale = 1; + let pointX = 0; + let pointY = 0; + let start = { x: 0, y: 0 }; + + function svgPoint({ x, y }) { + let newX = (x - pointX) / scale; + let newY = (y - pointY) / scale; + + return { x: newX, y: newY }; + } + + function applyTransformation() { + const els = parentEl.querySelectorAll("[data-transform-group]"); + + if (els.length === 0) return; + + for (const el of els) { + el.style.transformOrigin = `${0}px ${0}px`; + el.style.transform = `translate(${pointX}px, ${pointY}px) scale(${scale})`; + } + + onApplyTransformation({ scale, pointX, pointY }); + } + + listen("mousedown", "", (e) => { + if (e.shiftKey) return; + if (e.target.closest("[data-no-transform]")) return; + + mousedown = true; + + start = { x: e.offsetX - pointX, y: e.offsetY - pointY }; + + if (e.detail === 2) { + console.log( + e.offsetX, + e.offsetY, + svgPoint({ x: e.offsetX, y: e.offsetY }), + ); + } + }); + + listen("mousemove", "", (e) => { + if (!mousedown) return; + + pointX = e.offsetX - start.x; + pointY = e.offsetY - start.y; + + applyTransformation(); + }); + + listen("mouseup", "", (evt) => { + mousedown = false; + }); + + listen("wheel", "", (e) => { + let xs = (e.offsetX - pointX) / scale; + let ys = (e.offsetY - pointY) / scale; + + const ZOOM_SCALE = 1.05; + if (Math.sign(e.deltaY) < 0) scale *= ZOOM_SCALE; + else scale /= ZOOM_SCALE; + + pointX = e.offsetX - xs * scale; + pointY = e.offsetY - ys * scale; + + applyTransformation(); + + e.preventDefault(); + }); + + listen("mouseleave", "", (e) => { + mousedown = false; + }); + + function setScaleXY(limits) { + const svg = parentEl; + const bb = svg.getBoundingClientRect(); + const xr = limits.x[1] - limits.x[0]; + const yr = limits.y[1] - limits.y[0]; + const xScalingFactor = bb.width / xr; + const yScalingFactor = bb.height / yr; + + const scalingFactor = Math.min(xScalingFactor, yScalingFactor) * 0.9; + + scale = scalingFactor; + + const center = { + x: ((limits.x[0] + limits.x[1]) / 2) * scalingFactor - bb.width / 2, + y: + ((limits.y[0] + limits.y[1]) / 2) * scalingFactor - + bb.height / 2, + }; + + pointX = -center.x; + pointY = -center.y; + + applyTransformation(); + } + + function corners() { + const { left, right, bottom, top, width, height } = + parentEl.getBoundingClientRect(); + // need rt, lt, rb, lb + const rt = svgPoint({ x: width, y: height }); + // rt.y = -rt.y + const lt = svgPoint({ x: 0, y: height }); + // lt.y = -lt.y + const rb = svgPoint({ x: width, y: 0 }); + // rb.y = -rb.y + const lb = svgPoint({ x: 0, y: 0 }); + // lb.y = -lb.y + + return { rt, lt, rb, lb }; + } + + return { + scale: () => scale, + x: () => pointX, + y: () => pointY, + corners, + svgPoint, + setScaleXY, + applyTransformation + }; +} + +function addPtDragging(el, panZoomFns) { + const listen = createListener(el); + + let pad = null; + let padEl = null; + + listen("mousedown", "[data-trigger-click-pad]", e => { + padEl = e.target.closest("[data-parent-pad]"); + const { padname } = padEl.dataset; + + pad = e.target.closest("footprint-editor").footprint[padname]; + }); + + listen("mousemove", "", e => { + if (pad === null) return; + + const {x, y} = panZoomFns.svgPoint({ x: e.offsetX, y: e.offsetY }); + + pad.pos[0] = Math.round(x*100)/100; + pad.pos[1] = Math.round(y*100)/100; + + el.selectedPad = padEl.dataset.padname; + + el.render(); + }) + + listen("mouseup", "", e => { + if (pad === null) return; + + padEl = null; + pad = null; + }) + +} + +function addPathEditing(el, panZoomFns) { + const listen = createListener(el); + + let pad = null; + let padEl = null; + + listen("mousedown", "", e => { + + }); + + listen("mousemove", "", e => { + + }) + + listen("mouseup", "", e => { + + }) + +} + +// function scrollToCenter(element) { +// const parent = element.parentNode; + + +// const diffX = (element.getBoundingClientRect().left - parent.getBoundingClientRect().left) + parent.scrollLeft; +// const diffY = (element.getBoundingClientRect().top - parent.getBoundingClientRect().top) + parent.scrollTop; + +// const centerX = diffX - (parent.clientWidth / 2) + (element.clientWidth / 2); +// const centerY = diffY - (parent.clientHeight / 2) + (element.clientHeight / 2); + + + +// parent.scrollTo({ +// top: centerY, +// left: centerX, +// }); + +// parent.scrollTo({ +// top: centerY, +// left: centerX, +// }); + +// } + +// function parseMatrix(matrixString) { +// const matrixValues = matrixString.split('(')[1].split(')')[0].split(','); +// return matrixValues.map(Number); +// } + +// function revertScaleKeepTranslation(element, style) { +// const currentTransform = style.getPropertyValue('transform'); + +// if (currentTransform === 'none') { +// return; +// } + +// const matrix = parseMatrix(currentTransform); + +// const [a, c, b, d, tx, ty] = matrix; + +// const revertScaleX = 2; +// const revertScaleY = 2; + +// element.style.transform = `matrix(${revertScaleX}, ${c}, ${b}, ${revertScaleY}, ${1}, ${1})`; +// } + +function getCombinedBoundingBox(paths) { + if (paths.length === 0) { + return null; // or handle it as per your requirement + } + + // Get the SVG element (assuming all paths belong to the same SVG) + const svg = paths[0].ownerSVGElement; + + // If there's no parent SVG, we can't calculate the bounding box + if (!svg) { + throw new Error('SVG parent element not found'); + } + + // Initialize the variables to hold the extremes + let minX, minY, maxX, maxY; + + for (const path of paths) { + // Get the bounding client rect in viewport coordinate space + let rect = path.getBoundingClientRect(); + + // Convert the viewport coordinates to SVG coordinates + let topLeft = svg.createSVGPoint(); + topLeft.x = rect.left; + topLeft.y = rect.top; + topLeft = topLeft.matrixTransform(svg.getScreenCTM().inverse()); + + let bottomRight = svg.createSVGPoint(); + bottomRight.x = rect.right; + bottomRight.y = rect.bottom; + bottomRight = bottomRight.matrixTransform(svg.getScreenCTM().inverse()); + + // Initialize the variables on the first iteration + if (minX === undefined || minY === undefined || maxX === undefined || maxY === undefined) { + minX = topLeft.x; + minY = topLeft.y; + maxX = bottomRight.x; + maxY = bottomRight.y; + } else { + // Compare the points with the current extremes and update them if necessary + minX = Math.min(minX, topLeft.x); + minY = Math.min(minY, topLeft.y); + maxX = Math.max(maxX, bottomRight.x); + maxY = Math.max(maxY, bottomRight.y); + } + } + + // Create the bounding box in SVG coordinate space + return { + x: minX, + y: minY, + width: maxX - minX, + height: maxY - minY + }; +} + +function normalizeDimensions({ x, y, width, height }) { + // Check if width is negative + if (width < 0) { + // If width is negative, shift the x position and make width positive + x = x + width; // width is negative, so this operation is effectively a subtraction + width = -width; // make width positive + } + + // Check if height is negative + if (height < 0) { + // If height is negative, shift the y position and make height positive + y = y + height; // height is negative, so this operation is effectively a subtraction + height = -height; // make height positive + } + + // Return the updated dimensions + return { x, y, width, height }; +} + + +function createRectElement(normed) { + // Create a namespace-aware element + const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + + // Set attributes on the element + rect.setAttributeNS(null, "x", normed.x); + rect.setAttributeNS(null, "y", normed.y); + rect.setAttributeNS(null, "width", normed.width); + rect.setAttributeNS(null, "height", normed.height); + rect.setAttributeNS(null, "id", "bounding-box"); + rect.setAttributeNS(null, "fill", "none"); + rect.setAttributeNS(null, "stroke", "0.01"); + + return rect; +} + + + + + + + + + diff --git a/js/components/footprint-editor/footprint-editor.js b/js/components/footprint-editor/footprint-editor.js new file mode 100644 index 0000000..184cdc0 --- /dev/null +++ b/js/components/footprint-editor/footprint-editor.js @@ -0,0 +1,1106 @@ +import { createListener } from "../../events.js"; +import { html, render, svg } from "lit-html"; +import * as icons from "./icons.js"; +import { copy, pathD, getPathData, extrema, transform } from "../../../geogram/index.js"; +import { testFootprint } from "./testFootprint.js"; + +class FootprintEditor extends HTMLElement { + static get observedAttributes() { + return ["footprint"]; + } + + attributeChangedCallback(name, oldValue, newValue) { + if (name === "footprint") { + this.footprint = newValue; + this.render(); + this.style.display = "none"; + } + } + + set footprint(newVal) { + this._footprint = JSON.parse(newVal); + + for (const pad in this.footprint) { + const data = this.footprint[pad]; + this.transformations[pad] = { + _path: pathD([], data.shape), + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotate: 0 + } + } + + } + + get footprint() { + return this._footprint; + } + + constructor() { + super(); + + this.initialized = false; + this._footprint = this.getAttribute("footprint") ?? ""; + this.selectedPad = null; + + this.transformations = {}; + this.selectedGeometry = new Set(); + + this.render(); + + this.panZoomFns = addPanZoom( + this.querySelector("svg"), + ({ scale, pointX, pointY }) => { + const els = this.querySelectorAll("[data-circle-handle]"); + + for (const el of els) { + el.setAttribute("r", 6 / scale); + } + + const fixedScales = this.querySelectorAll("[data-fixed-scale]"); + for (const el of fixedScales) { + el.style.transform = `scale(${1/scale})`; + } + + } + ); + + addPtDragging(this, this.panZoomFns); + addTranslate(this); + + const listener = createListener(this); + + listener("click", "[data-trigger-click-layer]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + const newLayersStr = prompt( + "Please input new layers", + this.footprint[padname].layers.join(" "), + ); + + // check that layers are a list and strings + + if (newLayersStr === null) return; + + let newLayers = newLayersStr.split(" "); + this.footprint[padname].layers = newLayers; + + this.render(); + }); + + listener("click", "[data-trigger-click-padName]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + const newName = prompt( + "Please input a new pad name", + e.target.innerText, + ); + + if (newName === null) return; + if (Object.keys(this.footprint).includes(newName)) return; + + const invalidCharsRegex = /[^a-zA-Z_$\d]|(?<=^[^a-zA-Z_$])[\d]/g; + const invalid = newName.match(invalidCharsRegex) !== null; + if (invalid) return; + + const temp = this.footprint[padname]; + this.footprint[newName] = temp; + + const tempTrans = this.transformations[padname]; + this.transformations[newName] = tempTrans; + + delete this.footprint[padname]; + delete this.transformations[padname]; + + this.render(); + }); + + listener("click", "[data-trigger-click-close]", (e) => { + this.classList.add("hidden"); + }); + + listener("click", "[data-trigger-click-delete]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + delete this.footprint[padname]; + delete this.transformations[padname]; + + this.selectedGeometry.delete(padname); + + this.render(); + }); + + // let startX = 0; + // let startY = 0; + // listener("mousedown", "", e => { + // startX = e.clientX; + // startY = e.clientY; + // }) + + // listener("mouseup", ":not([data-trigger-click-geometry])", (e) => { + // const dx = e.clientX - startX; + // const dy = e.clientY - startY; + // if (dx > 2 || dy > 2) return; + // if (e.shiftKey) return + // this.selectedGeometry.clear(); + // this.render(); + // }); + + window.addEventListener("keydown", e => { + const { code } = e; + if (code === "Escape") { + this.selectedGeometry.clear(); + this.render(); + } + }) + + listener("mousedown", "[data-trigger-click-geometry]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + this.selectedPad = padname; + if (e.shiftKey && this.selectedGeometry.has(padname)) { + this.selectedGeometry.delete(padname); + } else if (e.shiftKey && !this.selectedGeometry.has(padname)) { + this.selectedGeometry.add(padname); + } else { + this.selectedGeometry.clear(); + this.selectedGeometry.add(padname); + } + + this.render(); + }); + + listener("mousedown", "[data-trigger-click-pad]", (e) => { + const pad = e.target.closest("[data-parent-pad]"); + const { padname } = pad.dataset; + + this.selectedPad = padname; + + this.render(); + }); + + listener("mousedown", "[data-trigger-add-pad]", (e) => { + let maxIndex = 0; + for (const [ padName, data ] of Object.entries(this.footprint)) { + maxIndex = Math.max(maxIndex, data.index ?? 0); + } + + maxIndex++; + + const padName = `_${maxIndex}`; + this.footprint[padName] = { + index: maxIndex, + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0, 0.05], + layers: ["F.Cu"] + } + + this.transformations[padName] = { + _path: pathD([], this.footprint[padName].shape), + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotate: 45 + } + + this.selectedPad = padName; + + this.render(); + + this.panZoomFns.applyTransformation(); + + }); + } + + connectedCallback() { + this.setAttribute("footprint", testFootprint); + + this.initialized = true; + + this.panZoomFns.setScaleXY({ + x: [-0.2, 0.2], + y: [-0.2, 0.2], + }); + + if (this.hasAttribute("footprint")) { + + } + } + + id = null; + + render() { + + let xMin = Infinity; + let xMax = -Infinity; + let yMin = Infinity; + let yMax = -Infinity; + + Array.from(this.selectedGeometry).forEach(pad => { + const data = this.footprint[pad]; + const geo = this.transformations[pad]; + const path = copy(geo._path); + + transform(path, { + dx: data.pos[0] + geo.translateX, + dy: data.pos[1] + geo.translateY, + sx: geo.scaleX, + sy: geo.scaleY, + rotate: geo.rotate + }) + + const e = extrema(path); + + xMin = Math.min(xMin, e.xMin); + xMax = Math.max(xMax, e.xMax); + yMin = Math.min(yMin, e.yMin); + yMax = Math.max(yMax, e.yMax); + }) + + const centerX = (xMax+xMin)/2; + const centerY = (yMax+yMin)/2; + + const transformHandle = () => { + + if (this.selectedGeometry.size === 0) return ""; + if (this.panZoomFns === null) return; + + return svg` + + + + + + + + + + + + + + + + + + + + + + + + + + + ` + } + + render(html` +
+
+
+ ${Object + .entries(this.footprint) + .sort((a, b) => a[1]?.index - b[1]?.index) + .map(x => footprintMenuItem(x, this.selectedPad, this.transformations[x[0]]))} +
+
+ add pad +
+
+
+ + + ${Object.entries(this.footprint).map(x => drawFootprint(x, this.transformations[x[0]], this))} + ${this.selectedGeometry.size > 0 ? svg`` : ""} + ${transformHandle()} + + + + ${transformPanel(this)} +
+
+ close +
+
+ `, this); + + + + const scrollToEl = this.querySelector("[data-selected-pad]"); + if (scrollToEl) { + scrollToEl.scrollIntoView(); + if (this.id) clearTimeout(this.id); + this.id = setTimeout(() => { + this.selectedPad = null; + this.render(); + }, 1000); + } + + // if (!this.panZoomFns) return; + + // const selectedGeoPaths = Array.from(this.querySelectorAll("[data-selected-geo]")); + + // if (selectedGeoPaths.length === 0) return; + + // const bb = getCombinedBoundingBox(selectedGeoPaths); + + // // const {x, y} = this.panZoomFns.svgPoint({ x: bb.x, y: bb.y }); + // // const width = bb.width/this.panZoomFns.scale(); + // // const height = bb.height/this.panZoomFns.scale(); + + // // const normed = normalizeDimensions({ + // // x, + // // y, + // // width, + // // height + // // }); + + // const normed = normalizeDimensions(bb); + } +} + +function affineTransform(el) { + + if (el.selectedGeometry.size !== 1) return "" + + const padName = [...el.selectedGeometry].at(0); + + const transformation = el.transformations[padName]; + + const { translateX, translateY, scaleX, scaleY, rotate } = transformation; + + const affineValueChange = (e, key) => { + // validate number + const n = Number(e.target.value); + + if (!isNaN(n)) { + transformation[key] = n; + el.render(); + } else { + e.target.value = transformation[key]; + } + } + + return html` +
+
+ tx: + affineValueChange(e, "translateX")} .value=${translateX}/> +
+
+ ty: + affineValueChange(e, "translateY")} .value=${translateY}/> +
+
+
+
+ sx: + affineValueChange(e, "scaleX")} .value=${scaleX}/> +
+
+ sy: + affineValueChange(e, "scaleY")} .value=${scaleY}/> +
+
+
+ rt: + affineValueChange(e, "rotate")} .value=${rotate}/> +
+ `; +} + +function footprintMenuItem([padName, data], selectedPad, transformation) { + return html` +
+
+
+ pad: + + ${padName} + +
+
x
+
+
+ +
pos: [ ${data.pos.map(x => x.toFixed(2)).join(", ")} ]
+ +
+ shape: + + "${data.shape}" + +
+ + layers: + + ${data.layers.join(", ")} + + +
drill: ${data.drill ?? "none"}
+
+ ${data.drill ? html`
diameter: ${data.drill.diameter}
`: ""} + ${data.drill ? html`
startLayer: ${data.drill.start}
`: ""} + ${data.drill ? html`
endLayer: ${data.drill.end}
`: ""} + ${data.drill ? html`
plated: ${data.drill.plated}
` : ""} +
+ +
maskOffset: ${data.maskOffset ?? "0"}
+
index: ${data.index ?? "none"}
+
+
+ ` +} + +function drawFootprint([padName, data], transformation, el) { + return svg` + + + + + `; +} + +function transformPanel(el) { + return html` +
+
+ ${el.selectedGeometry.size} + selected + { + el.selectedGeometry.clear(); + el.render(); + }} class="float-right hover:cursor-pointer hover:text-red-500">clear +
+
+ + ${icons.flipHorz} + + + + ${icons.flipVert} + + + + ${icons.rotate90cw} + + + + ${icons.rotate90ccw} + + +
+
+ + ${icons.leftAlign} + + + + ${icons.centerAlignHorz} + + + + ${icons.rightAlign} + + + + ${icons.distributeHorz} + + +
+
+ + ${icons.topAlign} + + + + ${icons.centerAlignVert} + + + + ${icons.bottomAlign} + + + + ${icons.distributeVert} + + +
+
+ ${affineTransform(el)} +
+
+ ` +} + +// this.dispatchEvent(new CustomEvent('colorChange', { detail: +// { +// value: hex +// } +// })); + +customElements.define("footprint-editor", FootprintEditor); + +function addPanZoom(parentEl, onApplyTransformation = () => {}) { + const listen = createListener(parentEl); + + let mousedown = false; + + let scale = 1; + let pointX = 0; + let pointY = 0; + let start = { x: 0, y: 0 }; + + function svgPoint({ x, y }) { + let newX = (x - pointX) / scale; + let newY = (y - pointY) / scale; + + return { x: newX, y: newY }; + } + + function applyTransformation() { + const els = parentEl.querySelectorAll("[data-transform-group]"); + + if (els.length === 0) return; + + for (const el of els) { + el.style.transformOrigin = `${0}px ${0}px`; + el.style.transform = `translate(${pointX}px, ${pointY}px) scale(${scale})`; + } + + onApplyTransformation({ scale, pointX, pointY }); + } + + listen("mousedown", "", (e) => { + if (e.shiftKey) return; + if (e.target.closest("[data-no-transform]")) return; + + mousedown = true; + + start = { x: e.offsetX - pointX, y: e.offsetY - pointY }; + + if (e.detail === 2) { + console.log( + e.offsetX, + e.offsetY, + svgPoint({ x: e.offsetX, y: e.offsetY }), + ); + } + }); + + listen("mousemove", "", (e) => { + if (!mousedown) return; + + pointX = e.offsetX - start.x; + pointY = e.offsetY - start.y; + + applyTransformation(); + }); + + listen("mouseup", "", (evt) => { + mousedown = false; + }); + + listen("wheel", "", (e) => { + let xs = (e.offsetX - pointX) / scale; + let ys = (e.offsetY - pointY) / scale; + + const ZOOM_SCALE = 1.05; + if (Math.sign(e.deltaY) < 0) scale *= ZOOM_SCALE; + else scale /= ZOOM_SCALE; + + pointX = e.offsetX - xs * scale; + pointY = e.offsetY - ys * scale; + + applyTransformation(); + + e.preventDefault(); + }); + + listen("mouseleave", "", (e) => { + mousedown = false; + }); + + function setScaleXY(limits) { + const svg = parentEl; + const bb = svg.getBoundingClientRect(); + const xr = limits.x[1] - limits.x[0]; + const yr = limits.y[1] - limits.y[0]; + const xScalingFactor = bb.width / xr; + const yScalingFactor = bb.height / yr; + + const scalingFactor = Math.min(xScalingFactor, yScalingFactor) * 0.9; + + scale = scalingFactor; + + const center = { + x: ((limits.x[0] + limits.x[1]) / 2) * scalingFactor - bb.width / 2, + y: + ((limits.y[0] + limits.y[1]) / 2) * scalingFactor - + bb.height / 2, + }; + + pointX = -center.x; + pointY = -center.y; + + applyTransformation(); + } + + function corners() { + const { left, right, bottom, top, width, height } = + parentEl.getBoundingClientRect(); + // need rt, lt, rb, lb + const rt = svgPoint({ x: width, y: height }); + // rt.y = -rt.y + const lt = svgPoint({ x: 0, y: height }); + // lt.y = -lt.y + const rb = svgPoint({ x: width, y: 0 }); + // rb.y = -rb.y + const lb = svgPoint({ x: 0, y: 0 }); + // lb.y = -lb.y + + return { rt, lt, rb, lb }; + } + + return { + scale: () => scale, + x: () => pointX, + y: () => pointY, + corners, + svgPoint, + setScaleXY, + applyTransformation + }; +} + +function addPtDragging(el, panZoomFns) { + const listen = createListener(el); + + let pad = null; + let padEl = null; + + listen("mousedown", "[data-trigger-click-pad]", e => { + padEl = e.target.closest("[data-parent-pad]"); + const { padname } = padEl.dataset; + + pad = e.target.closest("footprint-editor").footprint[padname]; + }); + + listen("mousemove", "", e => { + if (pad === null) return; + + const {x, y} = panZoomFns.svgPoint({ x: e.offsetX, y: e.offsetY }); + + pad.pos[0] = Math.round(x*100)/100; + pad.pos[1] = Math.round(y*100)/100; + + el.selectedPad = padEl.dataset.padname; + + el.render(); + }) + + listen("mouseup", "", e => { + if (pad === null) return; + + padEl = null; + pad = null; + }) + +} + +// function addPathEditing(el, panZoomFns) { +// const listen = createListener(el); + +// let pad = null; +// let padEl = null; + +// listen("mousedown", "", e => { + +// }); + +// listen("mousemove", "", e => { + +// }) + +// listen("mouseup", "", e => { + +// }) + +// } + +function addTranslate(el) { + const listen = createListener(el); + + let down = false; + let moveX = false; + let moveY = false; + + listen("mousedown", "[data-translate-xy]", e => { + down = true; + moveX = true; + moveY = true; + }) + + listen("mousedown", "[data-translate-x]", e => { + down = true; + moveX = true; + }) + + listen("mousedown", "[data-translate-y]", e => { + down = true; + moveY = true; + }) + + listen("mousemove", "", e => { + if (!down) return; + + const scale = el.panZoomFns.scale(); + + + const dx = e.movementX/scale; + const dy = -e.movementY/scale; + + Array.from(el.selectedGeometry).forEach(padname => { + const transform = el.transformations[padname]; + + if (moveX) transform.translateX += dx; + if (moveY) transform.translateY += dy; + }) + + el.render(); + }) + + listen("mouseup", "", e => { + down = false; + moveX = false; + moveY = false; + }) +} + +function addScale(el) { + const listen = createListener(el); + + let down = false; + let moveX = false; + let moveY = false; + + listen("mousedown", "[data-scale-xy]", e => { + down = true; + moveX = true; + moveY = true; + }) + + listen("mousedown", "[data-scale-x]", e => { + down = true; + moveX = true; + }) + + listen("mousedown", "[data-scale-y]", e => { + down = true; + moveY = true; + }) + + listen("mousemove", "", e => { + if (!down) return; + + const scale = el.panZoomFns.scale(); + + + const dx = e.movementX/scale; + const dy = -e.movementY/scale; + + // Array.from(el.selectedGeometry).forEach(padname => { + // const transform = el.transformations[padname]; + + // if (moveX) transform.translateX += dx; + // if (moveY) transform.translateY += dy; + // }) + + el.render(); + }) + + listen("mouseup", "", e => { + down = false; + moveX = false; + moveY = false; + }) +} + +function addRotate(el) { + const listen = createListener(el); + + let down = false; + let moveX = false; + let moveY = false; + + listen("mousedown", "[data-rotate]", e => { + down = true; + moveX = true; + moveY = true; + }) + + listen("mousemove", "", e => { + if (!down) return; + + const scale = el.panZoomFns.scale(); + + + const dx = e.movementX/scale; + const dy = -e.movementY/scale; + + Array.from(el.selectedGeometry).forEach(padname => { + const transform = el.transformations[padname]; + + // if (moveX) transform.translateX += dx; + // if (moveY) transform.translateY += dy; + }) + + el.render(); + }) + + listen("mouseup", "", e => { + down = false; + moveX = false; + moveY = false; + }) +} + +// function scrollToCenter(element) { +// const parent = element.parentNode; + + +// const diffX = (element.getBoundingClientRect().left - parent.getBoundingClientRect().left) + parent.scrollLeft; +// const diffY = (element.getBoundingClientRect().top - parent.getBoundingClientRect().top) + parent.scrollTop; + +// const centerX = diffX - (parent.clientWidth / 2) + (element.clientWidth / 2); +// const centerY = diffY - (parent.clientHeight / 2) + (element.clientHeight / 2); + + + +// parent.scrollTo({ +// top: centerY, +// left: centerX, +// }); + +// parent.scrollTo({ +// top: centerY, +// left: centerX, +// }); + +// } + +// function parseMatrix(matrixString) { +// const matrixValues = matrixString.split('(')[1].split(')')[0].split(','); +// return matrixValues.map(Number); +// } + +// function revertScaleKeepTranslation(element, style) { +// const currentTransform = style.getPropertyValue('transform'); + +// if (currentTransform === 'none') { +// return; +// } + +// const matrix = parseMatrix(currentTransform); + +// const [a, c, b, d, tx, ty] = matrix; + +// const revertScaleX = 2; +// const revertScaleY = 2; + +// element.style.transform = `matrix(${revertScaleX}, ${c}, ${b}, ${revertScaleY}, ${1}, ${1})`; +// } + +function getCombinedBoundingBox(paths) { + if (paths.length === 0) { + return null; // or handle it as per your requirement + } + + // Get the SVG element (assuming all paths belong to the same SVG) + const svg = paths[0].ownerSVGElement; + + // If there's no parent SVG, we can't calculate the bounding box + if (!svg) { + throw new Error('SVG parent element not found'); + } + + // Initialize the variables to hold the extremes + let minX, minY, maxX, maxY; + + for (const path of paths) { + // Get the bounding client rect in viewport coordinate space + let rect = path.getBoundingClientRect(); + + // Convert the viewport coordinates to SVG coordinates + let topLeft = svg.createSVGPoint(); + topLeft.x = rect.left; + topLeft.y = rect.top; + topLeft = topLeft.matrixTransform(svg.getScreenCTM().inverse()); + + let bottomRight = svg.createSVGPoint(); + bottomRight.x = rect.right; + bottomRight.y = rect.bottom; + bottomRight = bottomRight.matrixTransform(svg.getScreenCTM().inverse()); + + // Initialize the variables on the first iteration + if (minX === undefined || minY === undefined || maxX === undefined || maxY === undefined) { + minX = topLeft.x; + minY = topLeft.y; + maxX = bottomRight.x; + maxY = bottomRight.y; + } else { + // Compare the points with the current extremes and update them if necessary + minX = Math.min(minX, topLeft.x); + minY = Math.min(minY, topLeft.y); + maxX = Math.max(maxX, bottomRight.x); + maxY = Math.max(maxY, bottomRight.y); + } + } + + // Create the bounding box in SVG coordinate space + return { + x: minX, + y: minY, + width: maxX - minX, + height: maxY - minY + }; +} + +function normalizeDimensions({ x, y, width, height }) { + // Check if width is negative + if (width < 0) { + // If width is negative, shift the x position and make width positive + x = x + width; // width is negative, so this operation is effectively a subtraction + width = -width; // make width positive + } + + // Check if height is negative + if (height < 0) { + // If height is negative, shift the y position and make height positive + y = y + height; // height is negative, so this operation is effectively a subtraction + height = -height; // make height positive + } + + // Return the updated dimensions + return { x, y, width, height }; +} + + +function createRectElement(normed) { + // Create a namespace-aware element + const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + + // Set attributes on the element + rect.setAttributeNS(null, "x", normed.x); + rect.setAttributeNS(null, "y", normed.y); + rect.setAttributeNS(null, "width", normed.width); + rect.setAttributeNS(null, "height", normed.height); + rect.setAttributeNS(null, "id", "bounding-box"); + rect.setAttributeNS(null, "fill", "none"); + rect.setAttributeNS(null, "stroke", "0.01"); + + return rect; +} + + +// to do +/* +- round dragged values to grid +- add button functionality +- delete multiple at once +- selection box +- drill editting +- drag arrows on input boxes +- show dimensions +- lock aspect ratio +- path editing? +- multiple pos point editing +*/ + + + + + + + + diff --git a/js/components/footprint-editor/icons.js b/js/components/footprint-editor/icons.js new file mode 100644 index 0000000..894b028 --- /dev/null +++ b/js/components/footprint-editor/icons.js @@ -0,0 +1,105 @@ +import { svg } from "lit-html"; + +export const leftAlign = svg` + + + + +` + +export const centerAlignHorz = svg` + + + + +` + +export const rightAlign = svg` + + + + +` + +export const distributeHorz = svg` + + + + +` + +export const topAlign = svg` + + + + +` + +export const centerAlignVert = svg` + + + + +` + +export const bottomAlign = svg` + + + + +` + +export const distributeVert = svg` + + + + +` + +export const flipHorz = svg` + + + + +` + +export const flipVert = svg` + + + + +` + +export const rotate90cw = svg` + + + +` + +export const rotate90ccw = svg` + + + + +` + +export const transformHandle = (x, y) => svg` + + + + + + + + + + + + + + + + + + +` \ No newline at end of file diff --git a/js/components/footprint-editor/testFootprint.js b/js/components/footprint-editor/testFootprint.js new file mode 100644 index 0000000..fd94648 --- /dev/null +++ b/js/components/footprint-editor/testFootprint.js @@ -0,0 +1,86 @@ +export const testFootprint = JSON.stringify({ + A05: { + shape: "M 0.03,0.015L -0.03,0.015L -0.0305,0.015L -0.031,0.015L -0.0321,0.0149L -0.0331,0.0147L -0.0336,0.0146L -0.0347,0.0142L -0.0356,0.0139L -0.0361,0.0137L -0.0366,0.0135L -0.0371,0.0132L -0.0375,0.013L -0.038,0.0127L -0.0384,0.0125L -0.0392,0.0118L -0.0396,0.0115L -0.0401,0.0112L -0.0412,0.0101L -0.0415,0.0096L -0.0418,0.0092L -0.0425,0.0084L -0.0427,0.008L -0.043,0.0075L -0.0432,0.0071L -0.0435,0.0066L -0.0437,0.0061L -0.0439,0.0056L -0.0442,0.0047L -0.0446,0.0036L -0.0447,0.0031L -0.0449,0.0021L -0.045,0.001L -0.045,-0.001L -0.0449,-0.0021L -0.0447,-0.0031L -0.0446,-0.0036L -0.0442,-0.0047L -0.0439,-0.0056L -0.0437,-0.0061L -0.0435,-0.0066L -0.0432,-0.0071L -0.043,-0.0075L -0.0427,-0.008L -0.0425,-0.0084L -0.0418,-0.0092L -0.0415,-0.0096L -0.0412,-0.0101L -0.0401,-0.0112L -0.0396,-0.0115L -0.0392,-0.0118L -0.0384,-0.0125L -0.038,-0.0127L -0.0375,-0.013L -0.0371,-0.0132L -0.0366,-0.0135L -0.0361,-0.0137L -0.0356,-0.0139L -0.0347,-0.0142L -0.0336,-0.0146L -0.0331,-0.0147L -0.0321,-0.0149L -0.031,-0.015L 0.03,-0.015L 0.03,0.015", + pos: [-0.11, 0.15], + layers: ["F.Cu"], + index: 1, + }, + A08: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [-0.11, 0.1], + layers: ["F.Cu"], + index: 2, + }, + A09: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [-0.11, 0.05], + layers: ["F.Cu"], + index: 3, + }, + A14: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [-0.11, 0], + layers: ["F.Cu"], + index: 4, + }, + A15: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [-0.11, -0.05], + layers: ["F.Cu"], + index: 5, + }, + RST: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [-0.11, -0.1], + layers: ["F.Cu"], + index: 6, + }, + CLK: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [-0.11, -0.15], + layers: ["F.Cu"], + index: 7, + }, + DIO: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0.11, -0.15], + layers: ["F.Cu"], + index: 8, + }, + "24-": { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0.11, -0.1], + layers: ["F.Cu"], + index: 9, + }, + "25+": { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0.11, -0.05], + layers: ["F.Cu"], + index: 10, + }, + GND: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0.11, 0], + layers: ["F.Cu"], + index: 11, + }, + VDD: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0.11, 0.05], + layers: ["F.Cu"], + index: 12, + }, + A02: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0.11, 0.1], + layers: ["F.Cu"], + index: 13, + }, + A04: { + shape: "M -0.03,0.015L 0.03,0.015L 0.03,-0.015L -0.03,-0.015L -0.03,0.015", + pos: [0.11, 0.15], + layers: ["F.Cu"], + index: 14, + }, +}); \ No newline at end of file diff --git a/js/defaultText.js b/js/defaultText.js index 0eafed9..4771416 100644 --- a/js/defaultText.js +++ b/js/defaultText.js @@ -21,14 +21,14 @@ const height = 1; let board = new PCB(); -let interior = path( +let outline = path( pt(-0.5, 0.5), pt(0.5, 0.5), pt(0.5, -0.5), pt(-0.5, -0.5), ); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_COMPONENTS -- */ @@ -64,7 +64,7 @@ const yMax = Math.max(limit0[1], limit1[1]); renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#ff8c00cc", "B.Mask": "#00000000", @@ -76,7 +76,7 @@ renderPCB({ x: [xMin, xMax], y: [yMin, yMax] }, - mm_per_unit: 25.4 + mmPerUnit: 25.4 }); ` @@ -97,17 +97,17 @@ const width = 1; const height = 1; /* -- ADD_COMPONENTS -- */ -const ic = board.add(SAMD11C, { translate: pt(-0.2, 0.050), rotate: 0, label: "SAMD11C" }) +const ic = board.add(SAMD11C, { translate: pt(-0.2, 0.050), rotate: 0, id: "SAMD11C" }) /* -- BOARD_SIZE_SHAPE -- */ -const interior = path( +const outline = path( [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5], [-0.5, -0.5], ); -board.addShape("interior", interior); +board.addShape("outline", outline); /* -- ADD_WIRES -- */ board.wire(path(), 0.015); @@ -123,7 +123,7 @@ const yMax = Math.max(limit0[1], limit1[1]); renderPCB({ pcb: board, layerColors: { - "interior": "#002d00ff", + "outline": "#002d00ff", "B.Cu": "#ff4c007f", "F.Cu": "#ff8c00cc", "B.Mask": "#00000000", @@ -136,7 +136,7 @@ renderPCB({ y: [yMin, yMax] }, background: "#00000000", - mm_per_unit: 25.4 + mmPerUnit: 25.4 }); -` +`.replaceAll("\t", " ") diff --git a/js/dispatch.js b/js/dispatch.js index 114a716..2bbf1af 100644 --- a/js/dispatch.js +++ b/js/dispatch.js @@ -10,8 +10,10 @@ import { defaultText, basicSetup } from "./defaultText.js"; import { ensureSyntaxTree } from "@codemirror/language"; import { logError } from "./logError.js"; import * as esprima from 'esprima'; + import { makeRandStr } from "./makeRandStr.js"; + const getProgramString = () => global_state.codemirror.view.state.doc.toString(); const r = () => { @@ -70,6 +72,9 @@ const ACTIONS = { return entry.key.name === "value" }); + // console.log(value, x.snippet); + + const valueRangeFrom = value.value.range[0] + x.from; const valueRangeTo = value.value.range[1] + x.from; diff --git a/js/events.js b/js/events.js index efab2a0..77d93f0 100644 --- a/js/events.js +++ b/js/events.js @@ -7,9 +7,12 @@ import { addNumberDragging } from "./events/addNumberDragging.js"; import { addImportDrag } from "./events/addImportDrag.js"; import { addPathManipulation } from "./events/addPathManipulation.js"; import { addPathSelection } from "./events/addPathSelection.js"; +import { addPathAddPoint } from "./events/addPathAddPoint.js"; import { addLayerReordering } from "./events/addLayerReordering.js"; import { clearSelectedPath } from "./clearSelectedPath.js"; import { dispatch } from "./dispatch.js"; +import { saveFile } from "./saveFile.js"; + function pauseEvent(e) { if(e.stopPropagation) e.stopPropagation(); @@ -24,7 +27,7 @@ window.pauseEvent = pauseEvent; const trigger = e => e.composedPath()[0]; const matchesTrigger = (e, selectorString) => trigger(e).matches(selectorString); // create on listener -const createListener = (target) => (eventName, selectorString, event) => { // focus doesn't work with this, focus doesn't bubble, need focusin +export const createListener = (target) => (eventName, selectorString, event) => { // focus doesn't work with this, focus doesn't bubble, need focusin target.addEventListener(eventName, (e) => { e.trigger = trigger(e); // Do I need this? e.target seems to work in many (all?) cases if (selectorString === "" || matchesTrigger(e, selectorString)) event(e); @@ -40,6 +43,7 @@ export function addEvents(state) { addSelectBox(state, listenSVG); addPtDragging(state, listenSVG); + addPathAddPoint(state, listenSVG); addPathManipulation(state, listenSVG); const body = document.querySelector("body"); @@ -52,6 +56,7 @@ export function addEvents(state) { addLayerReordering(state, listenBody); window.addEventListener("keydown", (e) => { + const code = event.code; @@ -66,8 +71,19 @@ export function addEvents(state) { if (code === "Enter" && event.shiftKey) { event.preventDefault(); dispatch("RUN"); - } else if (code === "KeyT" && event.shiftKey) { // test something - + } else if ( + (event.ctrlKey || event.metaKey) && + (event.key === 's' || event.key === 'S') + ) { + const code = state.codemirror.view.state.doc.toString(); + const { fileHandle, view } = state; + if (fileHandle === null) { + saveFile(code) + } else { + saveFile(code, { fileHandle }) + } + + e.preventDefault(); } else if (code === "Escape") { // test something clearSelectedPath(); } diff --git a/js/events/addImportDrag.js b/js/events/addImportDrag.js index 0f1c7c6..ff6f3e6 100644 --- a/js/events/addImportDrag.js +++ b/js/events/addImportDrag.js @@ -64,7 +64,7 @@ export function addImportDrag(state, listener) { const name = state.previewFootprint[0].name; const uniqueName = `${name}_${makeRandStr(3)}`; - const text = `const ${uniqueName} = board.add(${name}, { translate: pt(${pos.x}, ${pos.y}), rotate: 0, label: "${uniqueName}" })\n` + const text = `const ${uniqueName} = board.add(${name}, { translate: pt(${pos.x}, ${pos.y}), rotate: 0, id: "${uniqueName}" })\n` state.codemirror.view.dispatch({ changes: {from: start, insert: text} diff --git a/js/events/addPathAddPoint.js b/js/events/addPathAddPoint.js new file mode 100644 index 0000000..ace6ca9 --- /dev/null +++ b/js/events/addPathAddPoint.js @@ -0,0 +1,17 @@ + + +export function addPathAddPoint(state, svgListener) { + + + svgListener("mousedown", ".trigger-selected-path", e => { + console.log(e.target); + + // e.preventDefault(); + // e.stopPropagation(); + // pauseEvent(e) + }) + + svgListener("mousemove", ".trigger-selected-path", e => { + console.log(e.target); + }) +} \ No newline at end of file diff --git a/js/events/addPathManipulation.js b/js/events/addPathManipulation.js index 3e9b0a8..ab15b60 100644 --- a/js/events/addPathManipulation.js +++ b/js/events/addPathManipulation.js @@ -291,8 +291,8 @@ function addPointAdding(state, svgListener) { // this causes problems if (state.heldKeys.size > 0) return; - - if (e.target.classList.contains("selectable-path")) return; + + if (e.target.matches(".selectable-path, .trigger-selected-path")) return; if (state.selectedPathIndex < 0 || state.selectedPath === null) return; isPt = e.composedPath().some(el => el.classList?.contains("draggable-pt")) diff --git a/js/events/download.js b/js/events/download.js index 6ae3f44..388a864 100644 --- a/js/events/download.js +++ b/js/events/download.js @@ -2,7 +2,6 @@ import { changeDpiDataUrl } from "./changeDPI.js"; import { offset2 } from "../../geogram/index.js"; import JSZip from "jszip"; import { saveAs } from "file-saver"; -import { MM_PER_INCH } from "../constants.js"; import { global_state as STATE } from "../global_state.js"; export function downloadSVG(state) { @@ -76,12 +75,13 @@ export function downloadText(filename, text, version = true) { export function downloadPNG(state, dpi = 1000) { const src = makeSVG(state); - var units = MM_PER_INCH; const w = (state.limits.x[1] - state.limits.x[0])*state.mm_per_unit; const h = (state.limits.y[1] - state.limits.y[0])*state.mm_per_unit; - var width = dpi*w/units; - var height = dpi*h/units; + + const MM_PER_INCH = 25.4; + var width = dpi*w/MM_PER_INCH; + var height = dpi*h/MM_PER_INCH; var img = new Image() img.width = width; diff --git a/js/events/downloadGerber.js b/js/events/downloadGerber.js index ad8af0d..30b1934 100644 --- a/js/events/downloadGerber.js +++ b/js/events/downloadGerber.js @@ -1,6 +1,6 @@ import JSZip from "jszip"; import { saveAs } from "file-saver"; -import { MM_PER_INCH } from "../constants.js"; +import { global_state } from "../global_state.js"; // Some things TODO here: // - Simplify file naming @@ -9,8 +9,8 @@ import { MM_PER_INCH } from "../constants.js"; // - Revisit drills // This should be a global function -export function inchesToMM(inches){ - return inches * MM_PER_INCH; +export function unitsToMm(inches){ + return inches * global_state.mm_per_unit; } export const GerberDrillFormat = Object.freeze({ @@ -333,7 +333,7 @@ export class GerberBuilder { layer.map( el => { if (el.type !== "wire") return; - const wireThickness = inchesToMM(el.thickness).toFixed(3); + const wireThickness = unitsToMm(el.thickness).toFixed(3); // Add aperture only if it does not exist yet if (!this.#wireThicknesses.includes(wireThickness)) { @@ -353,8 +353,8 @@ export class GerberBuilder { this.#body += "D" + el.gerberAperture.toString() + "*\n"; el.shape.flat().forEach((pt, i) => { - const x = this.constructor.format( inchesToMM(pt[0]) ); - const y = this.constructor.format( inchesToMM(pt[1]) ); + const x = this.constructor.format( unitsToMm(pt[0]) ); + const y = this.constructor.format( unitsToMm(pt[1]) ); this.#body += "X" + x + "Y" + y + "D0" + (i === 0 ? 2 : 1) + "*\n"; }); }); @@ -473,12 +473,12 @@ export class GerberBuilder { // Define rect apertures rectApertures.forEach((a) => { - this.#body += "%ADD" + a.id.toString() + "R," + inchesToMM(a.width).toFixed(3) + "X" + inchesToMM(a.height).toFixed(3) + "*%\n"; + this.#body += "%ADD" + a.id.toString() + "R," + unitsToMm(a.width).toFixed(3) + "X" + unitsToMm(a.height).toFixed(3) + "*%\n"; }); // Define circ apertures circApertures.forEach((a) => { - this.#body += "%ADD" + a.id.toString() + "C," + inchesToMM(a.radius * 2).toFixed(3) + "*%\n"; + this.#body += "%ADD" + a.id.toString() + "C," + unitsToMm(a.radius * 2).toFixed(3) + "*%\n"; }); // Draw rect pads using rect apertures @@ -488,7 +488,7 @@ export class GerberBuilder { this.#body += "D" + p.id.toString() + "*\n"; // Flash current rectangle aperture at location X, Y - this.#body += "X" + this.constructor.format(inchesToMM(p.x)) + "Y" + this.constructor.format(inchesToMM(p.y)) + "D03*\n"; + this.#body += "X" + this.constructor.format(unitsToMm(p.x)) + "Y" + this.constructor.format(unitsToMm(p.y)) + "D03*\n"; }); // Draw circ pads using circ apertures @@ -498,7 +498,7 @@ export class GerberBuilder { this.#body += "D" + p.id.toString() + "*\n"; // Flash current rectangle aperture at location X, Y - this.#body += "X" + this.constructor.format(inchesToMM(p.x)) + "Y" + this.constructor.format(inchesToMM(p.y)) + "D03*\n"; + this.#body += "X" + this.constructor.format(unitsToMm(p.x)) + "Y" + this.constructor.format(unitsToMm(p.y)) + "D03*\n"; }); // Select the aperture for drawing polygon pads @@ -515,8 +515,8 @@ export class GerberBuilder { // Loop through points p.forEach((pt, i) => { - const x = this.constructor.format( inchesToMM(pt[0]) ); - const y = this.constructor.format( inchesToMM(pt[1]) ); + const x = this.constructor.format( unitsToMm(pt[0]) ); + const y = this.constructor.format( unitsToMm(pt[1]) ); this.#body += "X" + x + "Y" + y + "D0" + (i === 0 ? 2 : 1) + "*\n"; }); @@ -534,8 +534,8 @@ export class GerberBuilder { if (el.type === "wire") return; el.flat().forEach((pt, i) => { - const x = this.constructor.format( inchesToMM(pt[0]) ); - const y = this.constructor.format( inchesToMM(pt[1]) ); + const x = this.constructor.format( unitsToMm(pt[0]) ); + const y = this.constructor.format( unitsToMm(pt[1]) ); this.#body += "X" + x + "Y" + y + "D0" + (i === 0 ? 2 : 1) + "*\n"; }); }); @@ -564,8 +564,8 @@ export class GerberBuilder { this.#body += "G36*\n"; el.flat().forEach((pt, i) => { - const x = this.constructor.format( inchesToMM(pt[0]) ); - const y = this.constructor.format( inchesToMM(pt[1]) ); + const x = this.constructor.format( unitsToMm(pt[0]) ); + const y = this.constructor.format( unitsToMm(pt[1]) ); this.#body += "X" + x + "Y" + y + "D0" + (i === 0 ? 2 : 1) + "*\n"; }); @@ -578,7 +578,7 @@ export class GerberBuilder { if (el.type !== "text") return; const text = el.value; - const textSize = inchesToMM(el.size); + const textSize = unitsToMm(el.size); const textPosition = el.translate; const textRotation = el.rotation; const textFont = "Courier"; // Let's see what we use in SvgPcb currently @@ -612,15 +612,15 @@ export class GerberBuilder { layer.map( el => { el.forEach((path, i) => { path.forEach((pt, i) => { - const x = this.constructor.format( inchesToMM(pt[0]) ); - const y = this.constructor.format( inchesToMM(pt[1]) ); + const x = this.constructor.format( unitsToMm(pt[0]) ); + const y = this.constructor.format( unitsToMm(pt[1]) ); this.#body += "X" + x + "Y" + y + "D0" + (i === 0 ? 2 : 1) + "*\n"; }); // Add a copy of first point to close the shape if needed. if (path[0][0] !== path[path.length-1][0] || path[0][1] !== path[path.length-1][1]) { - const x = this.constructor.format( inchesToMM(path[0][0]) ); - const y = this.constructor.format( inchesToMM(path[0][1]) ); + const x = this.constructor.format( unitsToMm(path[0][0]) ); + const y = this.constructor.format( unitsToMm(path[0][1]) ); this.#body += "X" + x + "Y" + y + "D01*\n"; } }); @@ -639,10 +639,10 @@ export class GerberBuilder { let diameter = x.diameter; let c = []; - c[0] = inchesToMM(center[0]); - c[1] = inchesToMM(center[1]); + c[0] = unitsToMm(center[0]); + c[1] = unitsToMm(center[1]); center = c; - diameter = inchesToMM(x.diameter); + diameter = unitsToMm(x.diameter); return { center, @@ -745,10 +745,10 @@ class ExcellonBuilder { const metric = this.#state.downloadGerberOptions.excellonMetric; let c = []; - c[0] = metric ? inchesToMM(center[0]) : center[0]; - c[1] = metric ? inchesToMM(center[1]) : center[1]; + c[0] = metric ? unitsToMm(center[0]) : center[0]; + c[1] = metric ? unitsToMm(center[1]) : center[1]; center = c; - diameter = metric? inchesToMM(x.diameter) : x.diameter; + diameter = metric? unitsToMm(x.diameter) : x.diameter; return { center, diff --git a/js/events/downloadKiCad.js b/js/events/downloadKiCad.js index 8f58581..02eccd0 100644 --- a/js/events/downloadKiCad.js +++ b/js/events/downloadKiCad.js @@ -1,7 +1,8 @@ import JSZip from "jszip"; import { saveAs } from "file-saver"; -import { APP_NAME, MM_PER_INCH } from "../constants.js"; +import { APP_NAME } from "../constants.js"; import { pathD } from "../../geogram/index.js"; +import { global_state } from "../global_state.js"; // KiCad Board File Format reference // https://dev-docs.kicad.org/en/file-formats/sexpr-pcb/ @@ -24,8 +25,8 @@ export const KICAD_PCB_VERSION = '20221018'; // Maybe this could be set to make export const PAD_TO_MASK_CLEARANCE = 0; // This should be a global function -export function inchesToMM(inches){ - return inches * MM_PER_INCH; +export function unitsToMm(inches){ + return inches * global_state.mm_per_unit; } // Simple enum (kind of) @@ -118,8 +119,8 @@ export class KiCadBoardFileBuilder { const points = pathD([], svgString)[0] .map(pt => { const point = { - x: inchesToMM(pt[0]), - y: inchesToMM(pt[1]) + x: unitsToMm(pt[0]), + y: unitsToMm(pt[1]) } return point; }); @@ -152,17 +153,17 @@ export class KiCadBoardFileBuilder { }); wires.forEach((wire) => { - const width = inchesToMM(wire.thickness).toFixed(3); + const width = unitsToMm(wire.thickness).toFixed(3); const layer = layerName; const net = 0; const shape = wire.shape; shape.forEach((polyline) => { for (let i = 0; i < polyline.length - 1; i++) { - const startX = inchesToMM(polyline[i][0]).toFixed(3); - const startY = (inchesToMM(-polyline[i][1]) + PAPER_SIZE_HEIGTH).toFixed(3); - const endX = inchesToMM(polyline[i+1][0]).toFixed(3); - const endY = (inchesToMM(-polyline[i+1][1]) + PAPER_SIZE_HEIGTH).toFixed(3); + const startX = unitsToMm(polyline[i][0]).toFixed(3); + const startY = (unitsToMm(-polyline[i][1]) + PAPER_SIZE_HEIGTH).toFixed(3); + const endX = unitsToMm(polyline[i+1][0]).toFixed(3); + const endY = (unitsToMm(-polyline[i+1][1]) + PAPER_SIZE_HEIGTH).toFixed(3); const tstamp = crypto.randomUUID(); this.#body += `(segment (start ${startX} ${startY}) (end ${endX} ${endY}) (width ${width}) (layer "${layer}") (net ${net}) (tstamp ${tstamp}))\n`; } @@ -189,11 +190,11 @@ export class KiCadBoardFileBuilder { const components = Object.values(compData).map((val) => { const component = { id: val.id, - reference: val.label ?? "", - footprint: val.label ?? "", + reference: val.id, + footprint: val.id, position: { - x: inchesToMM(val._pos[0]).toFixed(3), - y: (inchesToMM(-val._pos[1]) + PAPER_SIZE_HEIGTH).toFixed(3) + x: unitsToMm(val._pos[0]).toFixed(3), + y: (unitsToMm(-val._pos[1]) + PAPER_SIZE_HEIGTH).toFixed(3) }, rotation: val.rotation, layer: Object.values(val.footprint)[0].layers[0], @@ -202,8 +203,8 @@ export class KiCadBoardFileBuilder { number: val.index, name: key, position: { - x: inchesToMM(val.pos[0]).toFixed(3), - y: inchesToMM(-val.pos[1]).toFixed(3) + x: unitsToMm(val.pos[0]).toFixed(3), + y: unitsToMm(-val.pos[1]).toFixed(3) }, shape: this.#svgToPoints(val.shape), layers: val.layers, @@ -267,11 +268,11 @@ export class KiCadBoardFileBuilder { const vias = Object.values(viaData).map((comp) => { const via = { position: { - x: inchesToMM(comp._pos[0]).toFixed(3), - y: (inchesToMM(-comp._pos[1]) + PAPER_SIZE_HEIGTH).toFixed(3) + x: unitsToMm(comp._pos[0]).toFixed(3), + y: (unitsToMm(-comp._pos[1]) + PAPER_SIZE_HEIGTH).toFixed(3) }, size: this.#getSizeFromPoints(this.#svgToPoints(comp.footprint.via.shape)).w.toFixed(3), - drill: inchesToMM(comp.footprint.via.drill.diameter).toFixed(3), + drill: unitsToMm(comp.footprint.via.drill.diameter).toFixed(3), tstamp: comp.id }; return via; @@ -296,12 +297,12 @@ export class KiCadBoardFileBuilder { const ptStart = shape[i]; const ptEnd = shape[i+1]; const lineStart = { - x: inchesToMM(ptStart[0]).toFixed(3), - y: (inchesToMM(-ptStart[1]) + PAPER_SIZE_HEIGTH).toFixed(3) + x: unitsToMm(ptStart[0]).toFixed(3), + y: (unitsToMm(-ptStart[1]) + PAPER_SIZE_HEIGTH).toFixed(3) } const lineEnd = { - x: inchesToMM(ptEnd[0]).toFixed(3), - y: (inchesToMM(-ptEnd[1]) + PAPER_SIZE_HEIGTH).toFixed(3) + x: unitsToMm(ptEnd[0]).toFixed(3), + y: (unitsToMm(-ptEnd[1]) + PAPER_SIZE_HEIGTH).toFixed(3) } const lineTstamp = crypto.randomUUID(); diff --git a/js/formatCode.js b/js/formatCode.js new file mode 100644 index 0000000..9ec4ebb --- /dev/null +++ b/js/formatCode.js @@ -0,0 +1,15 @@ +import js_beautify from 'js-beautify' + + +export function formatCode(code) { + try { + const options = { + indent_size: 2, + "brace_style": "collapse,preserve-inline", + } + return js_beautify(code, options) + } catch (error) { + console.log(error) + return code // return the original code if there's an error + } +} \ No newline at end of file diff --git a/js/global_state.js b/js/global_state.js index 99877d2..6c4def9 100644 --- a/js/global_state.js +++ b/js/global_state.js @@ -1,15 +1,18 @@ -import { MM_PER_INCH } from "./constants"; import { KiCadPadPrimitiveShape, KiCadPadShapeType } from "./events/downloadKiCad"; import { GerberDrillFormat } from "./events/downloadGerber"; + export const global_state = { - version: "v0.1.0", + version: "v0.2.0", // need to do tagged release codemirror: undefined, pcb: undefined, heldKeys: new Set(), transforming: false, transformUpdate: () => {}, + fileHandle: null, + needsSaving: false, + selectBox: {}, footprints: {}, @@ -23,7 +26,7 @@ export const global_state = { x: [0, 1], y: [0, 1] }, - mm_per_unit: MM_PER_INCH, + mm_per_unit: 25.4, background: "#00000000", // -- grid -- diff --git a/js/init.js b/js/init.js index 9e05602..2c8e5a4 100644 --- a/js/init.js +++ b/js/init.js @@ -7,6 +7,8 @@ import { defaultText, basicSetup } from "./defaultText.js"; import { logError } from "./logError.js"; import { downloadText } from "./events/download.js"; +// add window event listener + export function init() { dispatch("HARD_RENDER"); const search = window.location.search; @@ -86,17 +88,16 @@ function exportNet() { console.log("Assign board.add(...) to variable or pass id in object parameters.") } - - components[x.refDes] = { pads: x.padShapes, pos: x._pos, padPositions: x.pads }; + components[x.id] = { pads: x.padShapes, pos: x._pos, padPositions: x.pads }; }); - const obj = { components, netList: pcb.netList }; + const obj = { components, netlist: pcb.netlist }; const string = JSON.stringify(obj); console.log(obj); - downloadText("netList.json", string, false); + downloadText("netlist.json", string, false); } diff --git a/js/ki_cad_parser.js b/js/ki_cad_parser.js index f4d47e1..bb4a7f9 100644 --- a/js/ki_cad_parser.js +++ b/js/ki_cad_parser.js @@ -1,7 +1,35 @@ -import { MM_PER_INCH } from "./constants.js"; import { sParse } from "./s-expression-parser.js"; -import { rectangle, circle } from "/geogram/index.js"; +const rectangle = (w, h) => { + const p0 = [ -w/2, h/2 ]; + const p1 = [ w/2, h/2 ]; + const p2 = [ w/2, -h/2 ]; + const p3 = [ -w/2, -h/2 ]; + + return [ + [ p0, p1, p2, p3, p0 ] + ] +} + +const circle = r => { + const n = 360/2; + const pts = []; + + const getX = (theta, r) => r*Math.cos(theta); + const getY = (theta, r) => r*Math.sin(theta); + + for ( let i = 0; i < n; i++) { + const theta = Math.PI*2/n*i; + const x = getX(theta, r); + const y = getY(theta, r); + pts.push( [ x, y ] ); + } + + const [ x, y ] = pts[0]; + pts.push([ x, y ]); + + return [ pts ]; +} // parser should take units @@ -22,7 +50,7 @@ const getNamedArray = (line, name) => { export function kicadToObj(data) { let r = sParse(data); - let scale = 1/MM_PER_INCH; + let scale = 1/25.4; const padsToAdd = {}; for (const line of r) { diff --git a/js/makeFootprintGeometry.js b/js/makeFootprintGeometry.js index 19484a6..a8dfe75 100644 --- a/js/makeFootprintGeometry.js +++ b/js/makeFootprintGeometry.js @@ -3,12 +3,16 @@ import { pathD, translate, scale, outline, width, height, getPoint } from "../ge export function makeFootprintGeometry(footprintObj) { const t = []; + console.log(footprintObj) + for (const padName in footprintObj) { // if (padName === "metadata") continue; // TODO const pad = footprintObj[padName]; - if (!pad.layers.includes("F.Cu")) continue; + + // TODO: this could cause bugs when missing + if (!["F.Cu", "B.Cu"].some(layer => pad.layers.includes(layer))) continue; let offset = [pad.pos[0], pad.pos[1]]; @@ -20,8 +24,12 @@ export function makeFootprintGeometry(footprintObj) { // const [ dx, dy ] = pad.pos; t.push(...translate(pathD([], pad.shape), offset)); + } + if (t.length === 0) return []; + + const w = width(t); const h = height(t); diff --git a/js/makeRandStr.js b/js/makeRandStr.js index dd6ab35..094bf09 100644 --- a/js/makeRandStr.js +++ b/js/makeRandStr.js @@ -1,8 +1,10 @@ +import { rand } from "./random.js"; + export function makeRandStr(length) { const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let result = ''; for (let i = 0; i < length; i++) { - const randomIndex = Math.floor(Math.random() * charset.length); + const randomIndex = Math.floor(rand() * charset.length); result += charset[randomIndex]; } return result; diff --git a/js/pcb.js b/js/pcb.js index 51bd1c7..795b857 100644 --- a/js/pcb.js +++ b/js/pcb.js @@ -1,5 +1,6 @@ import { makeComponent } from "./pcb_helpers.js"; import { getPathData, expand, scale, outline, union, xor, path, path2, offset, offset2, boolean } from "/geogram/index.js"; +import { makeRandStr } from "./makeRandStr.js" export class PCB { constructor() { @@ -7,22 +8,63 @@ export class PCB { this.components = []; this.ids = []; - this.netList = []; + this.netlist = []; + + // TODO + /* + this.components = {}; + this.netlist = []; + this.shapes = []; + this.wires = []; + + this._cache = { + holes: [], + processedFootprints: {}, // geometry is transformed, path string is polylines, flipped stuff is flipped + footprintShapes: {}, + componentLabels: [], + padLabels: [], + componentBoundingBoxes: {}, + }; + */ } + // add or addComponent(footprint, { id = random, translate = [0, 0], rotate = 0, flip = false }) + // wire or addWire(points, thickness, layer = "F.Cu") + // addShape(pl | pl[], layer = "F.Cu") + // setNetlist(netlist) + // getPad("compId", "padId", xy = "xy" | "x" | "y") + // getPos("compId", xy = "xy" | "x" | "y") + // getLayer(layerName, flatten = false) + // getPadLabels() + // getComponentLabels() + add(footprint, ops = {}) { + + const id = ops.id || `_${makeRandStr(8)}`; - const label = ops.label || ""; + const label = ops.id || ""; const options = { + id, translate: ops.translate || [0, 0], rotate: ops.rotate || 0, + flip: ops.flip || false, + padLabelSize: ops.padLabelSize || 0.02, componentLabelSize: ops.componentLabelSize || 0.025, - flip: ops.flip || false, - id: ops.id || crypto.randomUUID(), // check id is unique if provided }; + /* + if (id in this._components) { + throw new Error(`id not unique: ${id}`); + } + */ + + if (this.getComponent(options.id) !== undefined) { + throw new Error(`id not unique: ${ops.id}`); + return; + } + const newComp = makeComponent(footprint, options); for (const layer in newComp.layers) { @@ -49,6 +91,33 @@ export class PCB { return newComp; } + getComponent(id) { + return this.components.find(x => x.id === id); + } + + // getPad(componentId, padName, xy?) + // getPos(xy?), getPosX(), getPosY() + + query(id, padName = "", xy = "") { // layer + const comp = this.getComponent(id); + + if (padName === "") return comp; + + const pad = comp.pad(padName); + + if (xy === "") return pad; + + if (["x", "y"].some(val => val === xy)) { + + } + + if (xy === "x") return pad[0]; + if (xy === "y") return pad[1]; + + throw new Error(`xy param must be "x" or "y"`); + return undefined; + } + addShape(layer, shapeOrText) { if (shapeOrText[0] && (typeof shapeOrText[0][0] === "number")) { shapeOrText = [ shapeOrText ]; @@ -119,18 +188,18 @@ export class PCB { ] } - setNetList(...newNetList) { - newNetList.forEach(group => { - group.forEach(item => { + setNetlist(newNetlist) { + newNetlist.forEach(group => { + group.pads.forEach(item => { const [ comp, pad ] = item; const constructor = comp.constructor.name; if (constructor === "Component") item[0] = comp.id; }) }) - this.netList = newNetList; + this.netlist = newNetlist; - return newNetList; + return newNetlist; } wire(pts, thickness, layer = "F.Cu") { diff --git a/js/pcb_helpers.js b/js/pcb_helpers.js index e51e58b..8cb7d3a 100644 --- a/js/pcb_helpers.js +++ b/js/pcb_helpers.js @@ -45,6 +45,11 @@ class Component { this.padShapes = padShapes; this.id = id; this.flip = flip; + + /* + this.id + this._transformedFootprint + */ } pad(name) { diff --git a/js/random.js b/js/random.js new file mode 100644 index 0000000..3aa8130 --- /dev/null +++ b/js/random.js @@ -0,0 +1,23 @@ +let jsr = 69 + +export function rand() { + const max = 4294967295 + jsr ^= jsr << 17 + jsr ^= jsr >>> 13 + jsr ^= jsr << 5 + return (jsr >>> 0) / max +} + +export function setRandSeed(seed) { + jsr = seed +} + +export function randInRange(min, max) { + return rand() * (max - min) + min +} + +export function randIntInRange(min, max) { + min = Math.ceil(min) + max = Math.floor(max) + return Math.floor(rand() * (max - min + 1) + min) +} \ No newline at end of file diff --git a/js/renderPCB.js b/js/renderPCB.js index b67b7a9..82f96d4 100644 --- a/js/renderPCB.js +++ b/js/renderPCB.js @@ -1,4 +1,3 @@ -import { MM_PER_INCH } from "./constants.js"; import { global_state } from "./global_state.js"; import * as esprima from 'esprima'; @@ -9,13 +8,13 @@ const default_renderPCB_params = { x: [0, 1], y: [0, 1] }, - mm_per_unit: MM_PER_INCH, + mm_per_unit: global_state.mm_per_unit, background: "#00000000" } export const renderPCB = flatten => (...args) => { let [ - [ { pcb, layerColors, limits, mm_per_unit, background } ], + [ { pcb, layerColors, limits, mmPerUnit, background } ], staticInfo ] = args; @@ -23,7 +22,7 @@ export const renderPCB = flatten => (...args) => { if (layerColors === undefined) layerColors = default_renderPCB_params.layerColors; if (limits === undefined) limits = default_renderPCB_params.limits; - if (mm_per_unit === undefined) mm_per_unit = default_renderPCB_params.mm_per_unit; + if (mmPerUnit === undefined) mmPerUnit = default_renderPCB_params.mm_per_unit; if (background === undefined) background = default_renderPCB_params.background; @@ -65,7 +64,7 @@ export const renderPCB = flatten => (...args) => { global_state.shapes = shapes; // TODO ??? what should the shape format be { d: path data string, color: hex or valid svg color, classes: []} global_state.limits = limits; - global_state.mm_per_unit = mm_per_unit; + global_state.mm_per_unit = mmPerUnit; global_state.background = background; // renders the outline not the interior diff --git a/js/renderShape.js b/js/renderShape.js index 01fbf47..f5d566b 100644 --- a/js/renderShape.js +++ b/js/renderShape.js @@ -1,13 +1,13 @@ import { global_state } from "./global_state.js"; import { getPathData } from "../geogram/index.js"; -export function renderShape(shape) { - const d = getPathData(shape.shape); - const stroke = shape.stroke ?? "black"; - const fill = shape.fill ?? "none"; - const strokeWidth = shape.strokeWidth ?? 0.03; - const strokeLinecap = shape.strokeLinecap ?? "round"; - const strokeLinejoin = shape.strokeLinejoin ?? "round"; +export function renderShape(shape, ops = {}) { + const d = getPathData(shape); + const stroke = ops.stroke ?? "black"; + const fill = ops.fill ?? "none"; + const strokeWidth = ops.strokeWidth ?? 0.03; + const strokeLinecap = ops.strokeLinecap ?? "round"; + const strokeLinejoin = ops.strokeLinejoin ?? "round"; global_state.paths.push({ d, stroke, fill, strokeWidth, strokeLinecap, strokeLinejoin }); } \ No newline at end of file diff --git a/js/renderShapes.js b/js/renderShapes.js index dfc19bf..34f3e10 100644 --- a/js/renderShapes.js +++ b/js/renderShapes.js @@ -1,4 +1,3 @@ -import { MM_PER_INCH } from "./constants.js"; import { global_state } from "./global_state.js"; const default_renderShapes_params = { @@ -7,7 +6,7 @@ const default_renderShapes_params = { x: [0, 1], y: [0, 1] }, - mm_per_unit: MM_PER_INCH, + mm_per_unit: global_state.mm_per_unit, } export function renderShapes({ shapes, limits, mm_per_unit }) { diff --git a/js/runWorker.js b/js/runWorker.js new file mode 100644 index 0000000..24a4aaf --- /dev/null +++ b/js/runWorker.js @@ -0,0 +1,124 @@ +import * as esprima from "esprima"; +import { Parser } from "acorn"; + +const boardNameRe = /(const|let|var)([^=]*)=\s*new\s+PCB\s*\(\s*\)/; + +let boardName = string.match(boardNameRe); +boardName = boardName ? boardName[2].trim() : null; + +if (boardName) FUNCTIONS_STATIC_INFO.push(`${boardName}.add`); +if (boardName) FUNCTIONS_STATIC_INFO.push(`${boardName}.wire`); + +const FUNCTIONS_STATIC_INFO = ["pt", "path", "input", "footprint", "renderPCB"]; + +let tree; +console.time("ESPRIMA"); +tree = esprima.parse(string, { range: true, comment: true }).body[0]; +console.timeEnd("ESPRIMA"); + +console.time("ACORN"); +tree = Parser.parse(string); +console.log("acorn", tree); +console.timeEnd("ACORN"); + +Parser.extend(myPlugin); + +function myPlugin(Parser) { + return class extends Parser { + parsePropertyValue(prop, refDestructuringErrors) { + // Check if the property key is 'translate' + if (prop.key.type === "Identifier" && prop.key.name === "translate") { + // Check if the value is an array + if (prop.value.type !== "ArrayExpression") { + throw new SyntaxError("Expected 'translate' to be an array"); + } + } + + return super.parsePropertyValue(prop, refDestructuringErrors); + } + }; +} + +class PCB { + constructor() { + this.components = []; + this.wires = []; + this.netlist = []; // nets? + this.shapes = []; + + this._cache = { + // holes: [], + // processedFootprints: {}, // geometry is transformed, path string is polylines, flipped stuff is flipped + // footprintShapes: {}, + componentLabels: [], + padLabels: [], + layers: {} + // componentBoundingBoxes: {}, + }; + } + + addComponent({ footprint, id, translate, rotate, flip }) {} + + addNet({ name, pads }) { + // merge with existing net of same name + } + + addShape({ shape, layer }) {} + + addWire({ points, thickness, layer }) {} + + getLayer(flatten = false) {} + + getComponent(id) {} + + toJSON() { + + } + + fromJSON() { + + } +} + +class Component { + constructor() { + + this.boundingBox = { xMin: 0, xMax: 0, yMin: 0, yMax: 0 }; + this._cache = { + footprintShapes: [], + }; + } + + pad() {} + + padX() {} + + padY() {} + + pos() {} + + posX() {} + + posY() {} + +} + +function via( + diameterHole, + diameterCopper, + layers = ["F.Cu", "B.Cu"] +) { + return { + via: { + pos: [0, 0], + layers: layers, + shape: getPathData(circle(diameterCopper / 2)), + drill: { + diameter: diameterHole, + start: layers[0], + end: layers[1], + plated: true, + }, + }, + }; +} diff --git a/js/saveFile.js b/js/saveFile.js new file mode 100644 index 0000000..49771e7 --- /dev/null +++ b/js/saveFile.js @@ -0,0 +1,60 @@ +import { global_state } from "./global_state.js"; +import { dispatch } from "./dispatch.js"; + +export async function saveFile(content, { filename, fileHandle } = {}) { + if (!isChrome()) { + alert( + 'To save files to computer must use updated Chrome based browser. Please download files to store them.' + ) + return + } + + try { + // Request a file handle. + fileHandle = + fileHandle ?? + (await window.showSaveFilePicker({ + types: [ + { + description: 'Circuit Design', + accept: { + 'text/js': ['.js'] + } + } + ], + suggestedName: filename ?? 'anon' + })) + + // Create a FileSystemWritableFileStream to write to. + const writableStream = await fileHandle.createWritable() + + // Write the contents of the file. + await writableStream.write(content) + + // Close the file and write the contents to disk. + await writableStream.close() + + // Here, you can only print the file name, not the full path + console.log(`File saved: ${fileHandle.name}`) + + global_state.fileHandle = fileHandle + global_state.needsSaving = false; + + dispatch("RENDER"); + } catch (err) { + console.error('File save failed', err) + } +} + +function isChrome() { + // Please note that the 'window.navigator.userAgent' check can be manipulated by the client and is not 100% reliable + var userAgent = window.navigator.userAgent + var isChrome = /Chrome/.test(userAgent) && /Google Inc/.test(navigator.vendor) + + // Additionally, checking for 'window.chrome' may help in some cases, but this property can also be spoofed + if (isChrome && typeof window.chrome !== 'undefined') { + return true + } else { + return false + } +} \ No newline at end of file diff --git a/js/view.js b/js/view.js index 40aaf32..10eecef 100644 --- a/js/view.js +++ b/js/view.js @@ -15,10 +15,13 @@ import { inputRenderers } from "./views/inputRenderers.js"; import { initCodeMirror } from "./codemirror/codemirror.js"; import { drawDownloadGerberModal } from "./views/drawDownloadGerberModal.js"; import { drawDownloadKiCadModal } from "./views/drawDownloadKiCadModal.js"; +import { formatCode } from "./formatCode.js"; +import { saveFile } from "./saveFile.js"; import { drawSvgToModsModal } from "./views/drawSvgToModsModal.js"; import "./components/netlist-editor.js"; import "./components/wire-editor.js"; import "./components/color-picker.js"; +import "./components/footprint-editor/footprint-editor.js"; export function view(state) { @@ -102,19 +105,29 @@ export function view(state) { ${drawDownloadKiCadModal(state)} ${drawSvgToModsModal(state)} + ` } const menu = state => html`
- + fab-circuit-logo +