-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b527adc
commit 13ba88d
Showing
3 changed files
with
4,994 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { PCBVia } from "@tscircuit/soup" | ||
import { applyToPoint } from "transformation-matrix" | ||
|
||
export function createSvgObjectsFromPcbVia(hole: PCBVia, transform: any): any { | ||
const [x, y] = applyToPoint(transform, [hole.x, hole.y]) | ||
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a) | ||
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a) | ||
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a) | ||
const scaledHoleHeight = hole.hole_diameter * Math.abs(transform.a) | ||
|
||
const outerRadius = Math.min(scaledOuterWidth, scaledOuterHeight) / 2 | ||
const innerRadius = Math.min(scaledHoleWidth, scaledHoleHeight) / 2 | ||
return { | ||
name: "g", | ||
type: "element", | ||
children: [ | ||
{ | ||
name: "circle", | ||
type: "element", | ||
attributes: { | ||
class: "pcb-hole-outer", | ||
cx: x.toString(), | ||
cy: y.toString(), | ||
r: outerRadius.toString(), | ||
}, | ||
}, | ||
{ | ||
name: "circle", | ||
type: "element", | ||
attributes: { | ||
class: "pcb-hole-inner", | ||
cx: x.toString(), | ||
cy: y.toString(), | ||
r: innerRadius.toString(), | ||
}, | ||
}, | ||
], | ||
} | ||
} |
Oops, something went wrong.