circuit-json-to-lbrn 0.0.20 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/index.js +295 -163
  2. package/lib/element-handlers/addPcbCutout/addCirclePcbCutout.ts +10 -2
  3. package/lib/element-handlers/addPcbCutout/addPolygonPcbCutout.ts +10 -6
  4. package/lib/element-handlers/addPcbCutout/addRectPcbCutout.ts +12 -12
  5. package/lib/element-handlers/addPcbHole/addCirclePcbHole.ts +10 -2
  6. package/lib/element-handlers/addPcbHole/addOvalPcbHole.ts +8 -8
  7. package/lib/element-handlers/addPcbHole/addPillPcbHole.ts +8 -8
  8. package/lib/element-handlers/addPcbHole/addRectPcbHole.ts +10 -10
  9. package/lib/element-handlers/addPcbHole/addRotatedPillPcbHole.ts +8 -8
  10. package/lib/element-handlers/addPcbVia/index.ts +15 -3
  11. package/lib/element-handlers/addPlatedHole/addCirclePlatedHole.ts +15 -3
  12. package/lib/element-handlers/addPlatedHole/addCircularHoleWithRectPad.ts +14 -9
  13. package/lib/element-handlers/addPlatedHole/addHoleWithPolygonPad.ts +17 -7
  14. package/lib/element-handlers/addPlatedHole/addOvalPlatedHole.ts +15 -9
  15. package/lib/element-handlers/addPlatedHole/addPillHoleWithRectPad.ts +14 -14
  16. package/lib/element-handlers/addPlatedHole/addPillPlatedHole.ts +15 -9
  17. package/lib/element-handlers/addPlatedHole/addRotatedPillHoleWithRectPad.ts +19 -19
  18. package/lib/element-handlers/addSmtPad/addCircleSmtPad.ts +10 -2
  19. package/lib/element-handlers/addSmtPad/addPillSmtPad.ts +12 -2
  20. package/lib/element-handlers/addSmtPad/addPolygonSmtPad.ts +5 -1
  21. package/lib/element-handlers/addSmtPad/addRotatedPillSmtPad.ts +10 -10
  22. package/lib/element-handlers/addSmtPad/addRotatedRectSmtPad.ts +10 -10
  23. package/lib/helpers/circleShape.ts +13 -6
  24. package/lib/helpers/ovalShape.ts +17 -8
  25. package/lib/helpers/pathPointUtils.ts +11 -5
  26. package/lib/helpers/pillShape.ts +24 -11
  27. package/lib/helpers/polygonShape.ts +11 -5
  28. package/lib/helpers/roundedRectShape.ts +19 -9
  29. package/package.json +1 -1
@@ -36,7 +36,11 @@ export const addCircleSmtPad = (
36
36
  ctx.netGeoms.get(netId)?.push(polygon)
37
37
  } else {
38
38
  // No net connection - draw directly
39
- const outer = createCirclePath(centerX, centerY, outerRadius)
39
+ const outer = createCirclePath({
40
+ centerX,
41
+ centerY,
42
+ radius: outerRadius,
43
+ })
40
44
  project.children.push(
41
45
  new ShapePath({
42
46
  cutIndex: copperCutSetting.index,
@@ -51,7 +55,11 @@ export const addCircleSmtPad = (
51
55
  // Add soldermask opening if drawing soldermask
52
56
  if (includeSoldermask) {
53
57
  const smRadius = outerRadius + soldermaskMargin
54
- const outer = createCirclePath(centerX, centerY, smRadius)
58
+ const outer = createCirclePath({
59
+ centerX,
60
+ centerY,
61
+ radius: smRadius,
62
+ })
55
63
  project.children.push(
56
64
  new ShapePath({
57
65
  cutIndex: soldermaskCutSetting.index,
@@ -22,7 +22,12 @@ export const addPillSmtPad = (
22
22
  const centerY = smtPad.y + origin.y
23
23
 
24
24
  if (smtPad.width > 0 && smtPad.height > 0) {
25
- const outer = createPillPath(centerX, centerY, smtPad.width, smtPad.height)
25
+ const outer = createPillPath({
26
+ centerX,
27
+ centerY,
28
+ width: smtPad.width,
29
+ height: smtPad.height,
30
+ })
26
31
 
27
32
  // Add to netGeoms for copper (will be merged with traces)
28
33
  if (includeCopper) {
@@ -49,7 +54,12 @@ export const addPillSmtPad = (
49
54
  if (includeSoldermask) {
50
55
  const smWidth = smtPad.width + 2 * soldermaskMargin
51
56
  const smHeight = smtPad.height + 2 * soldermaskMargin
52
- const smOuter = createPillPath(centerX, centerY, smWidth, smHeight)
57
+ const smOuter = createPillPath({
58
+ centerX,
59
+ centerY,
60
+ width: smWidth,
61
+ height: smHeight,
62
+ })
53
63
 
54
64
  project.children.push(
55
65
  new ShapePath({
@@ -22,7 +22,11 @@ export const addPolygonSmtPad = (
22
22
 
23
23
  // Create the polygon pad
24
24
  if (smtPad.points.length >= 3) {
25
- const pad = createPolygonPathFromOutline(smtPad.points, origin.x, origin.y)
25
+ const pad = createPolygonPathFromOutline({
26
+ outline: smtPad.points,
27
+ offsetX: origin.x,
28
+ offsetY: origin.y,
29
+ })
26
30
 
27
31
  // Add to netGeoms for copper (will be merged with traces)
28
32
  if (includeCopper) {
@@ -22,13 +22,13 @@ export const addRotatedPillSmtPad = (
22
22
  const centerY = smtPad.y + origin.y
23
23
 
24
24
  if (smtPad.width > 0 && smtPad.height > 0) {
25
- const outer = createPillPath(
25
+ const outer = createPillPath({
26
26
  centerX,
27
27
  centerY,
28
- smtPad.width,
29
- smtPad.height,
30
- (smtPad.ccw_rotation ?? 0) * (Math.PI / 180),
31
- )
28
+ width: smtPad.width,
29
+ height: smtPad.height,
30
+ rotation: (smtPad.ccw_rotation ?? 0) * (Math.PI / 180),
31
+ })
32
32
 
33
33
  // Add to netGeoms for copper (will be merged with traces)
34
34
  if (includeCopper) {
@@ -55,13 +55,13 @@ export const addRotatedPillSmtPad = (
55
55
  if (includeSoldermask) {
56
56
  const smWidth = smtPad.width + 2 * soldermaskMargin
57
57
  const smHeight = smtPad.height + 2 * soldermaskMargin
58
- const smOuter = createPillPath(
58
+ const smOuter = createPillPath({
59
59
  centerX,
60
60
  centerY,
61
- smWidth,
62
- smHeight,
63
- (smtPad.ccw_rotation ?? 0) * (Math.PI / 180),
64
- )
61
+ width: smWidth,
62
+ height: smHeight,
63
+ rotation: (smtPad.ccw_rotation ?? 0) * (Math.PI / 180),
64
+ })
65
65
 
66
66
  project.children.push(
67
67
  new ShapePath({
@@ -24,15 +24,15 @@ export const addRotatedRectSmtPad = (
24
24
  const borderRadius = smtPad.rect_border_radius ?? 0
25
25
 
26
26
  if (smtPad.width > 0 && smtPad.height > 0) {
27
- const outer = createRoundedRectPath(
27
+ const outer = createRoundedRectPath({
28
28
  centerX,
29
29
  centerY,
30
- smtPad.width,
31
- smtPad.height,
30
+ width: smtPad.width,
31
+ height: smtPad.height,
32
32
  borderRadius,
33
- 4,
33
+ segments: 4,
34
34
  rotation,
35
- )
35
+ })
36
36
 
37
37
  // Add to netGeoms for copper (will be merged with traces)
38
38
  if (includeCopper) {
@@ -59,15 +59,15 @@ export const addRotatedRectSmtPad = (
59
59
  if (includeSoldermask) {
60
60
  const smWidth = smtPad.width + 2 * soldermaskMargin
61
61
  const smHeight = smtPad.height + 2 * soldermaskMargin
62
- const smOuter = createRoundedRectPath(
62
+ const smOuter = createRoundedRectPath({
63
63
  centerX,
64
64
  centerY,
65
- smWidth,
66
- smHeight,
65
+ width: smWidth,
66
+ height: smHeight,
67
67
  borderRadius,
68
- 4,
68
+ segments: 4,
69
69
  rotation,
70
- )
70
+ })
71
71
 
72
72
  project.children.push(
73
73
  new ShapePath({
@@ -12,12 +12,19 @@ export interface CirclePath {
12
12
  prims: Prim[]
13
13
  }
14
14
 
15
- export const createCirclePath = (
16
- centerX: number,
17
- centerY: number,
18
- radius: number,
19
- segments: number = 64,
20
- ): CirclePath => {
15
+ export interface CreateCirclePathParams {
16
+ centerX: number
17
+ centerY: number
18
+ radius: number
19
+ segments?: number
20
+ }
21
+
22
+ export const createCirclePath = ({
23
+ centerX,
24
+ centerY,
25
+ radius,
26
+ segments = 64,
27
+ }: CreateCirclePathParams): CirclePath => {
21
28
  const verts: Point[] = []
22
29
  const prims: Prim[] = []
23
30
 
@@ -12,14 +12,23 @@ export interface OvalPath {
12
12
  prims: Prim[]
13
13
  }
14
14
 
15
- export const createOvalPath = (
16
- centerX: number,
17
- centerY: number,
18
- width: number,
19
- height: number,
20
- rotation: number = 0,
21
- segments: number = 64,
22
- ): OvalPath => {
15
+ export interface CreateOvalPathParams {
16
+ centerX: number
17
+ centerY: number
18
+ width: number
19
+ height: number
20
+ rotation?: number
21
+ segments?: number
22
+ }
23
+
24
+ export const createOvalPath = ({
25
+ centerX,
26
+ centerY,
27
+ width,
28
+ height,
29
+ rotation = 0,
30
+ segments = 64,
31
+ }: CreateOvalPathParams): OvalPath => {
23
32
  const verts: Point[] = []
24
33
  const prims: Prim[] = []
25
34
  const radiusX = width / 2
@@ -13,11 +13,17 @@ export interface PointAdderOptions {
13
13
  translation?: PathPoint
14
14
  }
15
15
 
16
- export const createPointAdder = (
17
- verts: PathPoint[],
18
- prims: PathPrim[],
19
- options: PointAdderOptions = {},
20
- ): ((x: number, y: number) => void) => {
16
+ export interface CreatePointAdderParams {
17
+ verts: PathPoint[]
18
+ prims: PathPrim[]
19
+ options?: PointAdderOptions
20
+ }
21
+
22
+ export const createPointAdder = ({
23
+ verts,
24
+ prims,
25
+ options = {},
26
+ }: CreatePointAdderParams): ((x: number, y: number) => void) => {
21
27
  const { rotation = 0, rotationCenter, translation } = options
22
28
  const cos = Math.cos(rotation)
23
29
  const sin = Math.sin(rotation)
@@ -14,14 +14,23 @@ export interface PillPath {
14
14
  prims: Prim[]
15
15
  }
16
16
 
17
- export const createPillPath = (
18
- centerX: number,
19
- centerY: number,
20
- width: number,
21
- height: number,
22
- rotation: number = 0,
23
- segments: number = 32,
24
- ): PillPath => {
17
+ export interface CreatePillPathParams {
18
+ centerX: number
19
+ centerY: number
20
+ width: number
21
+ height: number
22
+ rotation?: number
23
+ segments?: number
24
+ }
25
+
26
+ export const createPillPath = ({
27
+ centerX,
28
+ centerY,
29
+ width,
30
+ height,
31
+ rotation = 0,
32
+ segments = 32,
33
+ }: CreatePillPathParams): PillPath => {
25
34
  const verts: Point[] = []
26
35
  const prims: Prim[] = []
27
36
  const halfWidth = width / 2
@@ -29,9 +38,13 @@ export const createPillPath = (
29
38
  const radius = Math.min(halfWidth, halfHeight)
30
39
  const isVertical = height > width
31
40
 
32
- const addPoint = createPointAdder(verts, prims, {
33
- rotation,
34
- rotationCenter: { x: centerX, y: centerY },
41
+ const addPoint = createPointAdder({
42
+ verts,
43
+ prims,
44
+ options: {
45
+ rotation,
46
+ rotationCenter: { x: centerX, y: centerY },
47
+ },
35
48
  })
36
49
 
37
50
  if (isVertical) {
@@ -12,11 +12,17 @@ export interface PolygonPath {
12
12
  prims: Prim[]
13
13
  }
14
14
 
15
- export const createPolygonPathFromOutline = (
16
- outline: Array<{ x?: number | null; y?: number | null }>,
17
- offsetX: number,
18
- offsetY: number,
19
- ): PolygonPath => {
15
+ export interface CreatePolygonPathFromOutlineParams {
16
+ outline: Array<{ x?: number | null; y?: number | null }>
17
+ offsetX: number
18
+ offsetY: number
19
+ }
20
+
21
+ export const createPolygonPathFromOutline = ({
22
+ outline,
23
+ offsetX,
24
+ offsetY,
25
+ }: CreatePolygonPathFromOutlineParams): PolygonPath => {
20
26
  const verts: Point[] = []
21
27
 
22
28
  for (const point of outline) {
@@ -12,15 +12,25 @@ export interface RoundedRectPath {
12
12
  prims: Prim[]
13
13
  }
14
14
 
15
- export const createRoundedRectPath = (
16
- centerX: number,
17
- centerY: number,
18
- width: number,
19
- height: number,
20
- borderRadius: number = 0,
21
- segments: number = 4,
22
- rotation: number = 0,
23
- ): RoundedRectPath => {
15
+ export interface CreateRoundedRectPathParams {
16
+ centerX: number
17
+ centerY: number
18
+ width: number
19
+ height: number
20
+ borderRadius?: number
21
+ segments?: number
22
+ rotation?: number
23
+ }
24
+
25
+ export const createRoundedRectPath = ({
26
+ centerX,
27
+ centerY,
28
+ width,
29
+ height,
30
+ borderRadius = 0,
31
+ segments = 4,
32
+ rotation = 0,
33
+ }: CreateRoundedRectPathParams): RoundedRectPath => {
24
34
  const verts: Point[] = []
25
35
  const prims: Prim[] = []
26
36
  const halfWidth = width / 2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-json-to-lbrn",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.20",
4
+ "version": "0.0.21",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "bun run site/index.html",