Skip to content

Commit

Permalink
initial inversion fix
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Aug 22, 2024
1 parent 2891c09 commit 67324a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ docs
*.artifact.*
gerber-output
gerber-output.zip
tmp-debug-logs
tmp-debug-logs
.aider*
27 changes: 10 additions & 17 deletions src/lib/gerber/convert-soup-to-gerber-commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import { getGerberLayerName } from "./getGerberLayerName"
* Converts tscircuit soup to arrays of Gerber commands for each layer
*/
export const convertSoupToGerberCommands = (
soup: AnySoupElement[],
opts: { flip_y_axis?: boolean } = {}
soup: AnySoupElement[]
): LayerToGerberCommandsMap => {
opts.flip_y_axis ??= true
const glayers: LayerToGerberCommandsMap = {
F_Cu: getCommandHeaders({
layer: "top",
Expand Down Expand Up @@ -66,11 +64,6 @@ export const convertSoupToGerberCommands = (
.build()
)

/**
* "maybe flip y axis" to handle y axis negating
*/
const mfy = (y: number) => (opts.flip_y_axis ? -y : y)

for (const layer of ["top", "bottom", "edgecut"] as const) {
for (const element of soup) {
if (element.type === "pcb_trace") {
Expand All @@ -90,8 +83,8 @@ export const convertSoupToGerberCommands = (
trace_width: a.width,
}),
})
.add("move_operation", { x: a.x, y: mfy(a.y) })
.add("plot_operation", { x: b.x, y: mfy(b.y) })
.add("move_operation", { x: a.x, y: a.y })
.add("plot_operation", { x: b.x, y: b.y })
.build()
)
}
Expand All @@ -111,7 +104,7 @@ export const convertSoupToGerberCommands = (
getApertureConfigFromPcbSmtpad(element)
),
})
.add("flash_operation", { x: element.x, y: mfy(element.y) })
.add("flash_operation", { x: element.x, y: element.y })
.build()
)
}
Expand All @@ -136,7 +129,7 @@ export const convertSoupToGerberCommands = (
getApertureConfigFromCirclePcbPlatedHole(element)
),
})
.add("flash_operation", { x: element.x, y: mfy(element.y) })
.add("flash_operation", { x: element.x, y: element.y })
.build()
)
}
Expand All @@ -151,35 +144,35 @@ export const convertSoupToGerberCommands = (
})
.add("move_operation", {
x: center.x - width / 2,
y: mfy(center.y - height / 2),
y: center.y - height / 2,
})
.add("plot_operation", {
x: center.x + width / 2,
y: mfy(center.y - height / 2),
y: center.y - height / 2,
})
// .add("move_operation", {
// x: center.x + width / 2,
// y: center.y - height / 2,
// })
.add("plot_operation", {
x: center.x + width / 2,
y: mfy(center.y + height / 2),
y: center.y + height / 2,
})
// .add("move_operation", {
// x: center.x + width / 2,
// y: center.y + height / 2,
// })
.add("plot_operation", {
x: center.x - width / 2,
y: mfy(center.y + height / 2),
y: center.y + height / 2,
})
// .add("move_operation", {
// x: center.x - width / 2,
// y: center.y + height / 2,
// })
.add("plot_operation", {
x: center.x - width / 2,
y: mfy(center.y - height / 2),
y: center.y - height / 2,
})
.build()
)
Expand Down

0 comments on commit 67324a5

Please sign in to comment.