Skip to content

Instantly share code, notes, and snippets.

@honnet
Last active March 15, 2022 19:00
Show Gist options
  • Save honnet/b411a1dbd15822b05d94e6c59652bcac to your computer and use it in GitHub Desktop.
Save honnet/b411a1dbd15822b05d94e6c59652bcac to your computer and use it in GitHub Desktop.
Testing curvy PCB shapes
// visualization tool: https://leomcelroy.com/svg-pcb/
// source: https://gist.github.com/honnet/b411a1dbd15822b05d94e6c59652bcac
/* -- DECLARE_COMPONENTS -- */
const test_footprint = {
"VCC": {
"shape": "M -0.05 0.025L 0.05 0.025L 0.05 -0.025L -0.05 -0.025L -0.05 0.025",
"pos":[-0.1,0.05],
"layers":["F.Cu"]
},
"GND": {
"shape": "M -0.05 0.025L 0.05 0.025L 0.05 -0.025L -0.05 -0.025L -0.05 0.025",
"pos":[0.1,0.05],
"layers":["F.Cu"]
},
"D+": {
"shape": "M -0.05 0.025L 0.05 0.025L 0.05 -0.025L -0.05 -0.025L -0.05 0.025",
"pos":[-0.1,-0.05],
"layers":["F.Cu"]
},
"D-": {
"shape": "M -0.05 0.025L 0.05 0.025L 0.05 -0.025L -0.05 -0.025L -0.05 0.025",
"pos":[0.1,-0.05],
"layers":["F.Cu"]
}
}
/* -- DECLARE_PCB -- */
let board = new PCB();
/* -- ADD_COMPONENTS -- */
test_comp1 = board.add(test_footprint, {translate: [0.2, 0.125], name: "COMP1"})
test_comp2 = board.add(test_footprint, {translate: [0.2, 1.075], name: "COMP2"})
// define a shape using turtles
let interior = new Turtle().rectangle(0.4, 0.2)
.turn(90)
.arc( -90, 0.05)
.arc( 180, 0.05)
.arc(-180, 0.05)
.arc( 180, 0.05)
.arc(-180, 0.05)
.arc( 180, 0.05)
.arc(-180, 0.05)
.arc( 180, 0.05)
.arc(-90, 0.05)
.forward(0.15)
.arc(-90, 0.05)
.forward(0.3)
.arc(-90, 0.05)
.forward(0.25)
.arc(-90, 0.05)
.arc( 180, 0.05)
.arc(-180, 0.05)
.arc( 180, 0.05)
.arc(-180, 0.05)
.arc( 180, 0.05)
.arc(-90, 0.05)
.forward(0.1)
.translate([0.2, 0.1]);
board.addShape("interior", interior);
/* -- RENDER_PCB -- */
renderPCB({
pcb: board,
layerColors: {
"interior": "#002d00ff",
"F.Cu": "#ff8c00cc",
"componentLabels": "#00e5e5e5",
},
limits: {
x: [0, 0.4],
y: [0, 1.]
},
mm_per_unit: 25.4
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment