@tscircuit/core 0.0.18 → 0.0.19
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.
- package/dist/index.js +27 -8
- package/lib/components/base-components/NormalComponent.ts +1 -1
- package/lib/components/base-components/PrimitiveComponent.ts +9 -2
- package/lib/components/primitive-components/SilkscreenPath.ts +14 -1
- package/lib/components/primitive-components/SmtPad.ts +7 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -123,6 +123,7 @@ import {
|
|
|
123
123
|
applyToPoint,
|
|
124
124
|
compose,
|
|
125
125
|
identity,
|
|
126
|
+
rotate,
|
|
126
127
|
translate
|
|
127
128
|
} from "transformation-matrix";
|
|
128
129
|
|
|
@@ -216,7 +217,12 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
216
217
|
* components
|
|
217
218
|
*/
|
|
218
219
|
computePcbPropsTransform() {
|
|
219
|
-
|
|
220
|
+
const { _parsedProps: props } = this;
|
|
221
|
+
const matrix = compose(
|
|
222
|
+
translate(props.pcbX ?? 0, props.pcbY ?? 0),
|
|
223
|
+
rotate((props.pcbRotation ?? 0) * Math.PI / 180)
|
|
224
|
+
);
|
|
225
|
+
return matrix;
|
|
220
226
|
}
|
|
221
227
|
/**
|
|
222
228
|
* Compute a transformation matrix combining all parent transforms for PCB
|
|
@@ -740,6 +746,7 @@ function getPortFromHints(hints) {
|
|
|
740
746
|
|
|
741
747
|
// lib/components/primitive-components/SmtPad.ts
|
|
742
748
|
import { smtPadProps } from "@tscircuit/props";
|
|
749
|
+
import { decomposeTSR } from "transformation-matrix";
|
|
743
750
|
var SmtPad = class extends PrimitiveComponent {
|
|
744
751
|
pcb_smtpad_id = null;
|
|
745
752
|
matchedPort = null;
|
|
@@ -769,6 +776,8 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
769
776
|
const { _parsedProps: props } = this;
|
|
770
777
|
if (!props.portHints) return;
|
|
771
778
|
const position = this.getGlobalPcbPosition();
|
|
779
|
+
const decomposedMat = decomposeTSR(this.computePcbGlobalTransform());
|
|
780
|
+
const isRotated90 = Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01;
|
|
772
781
|
let pcb_smtpad = null;
|
|
773
782
|
if (props.shape === "circle") {
|
|
774
783
|
pcb_smtpad = db.pcb_smtpad.insert({
|
|
@@ -788,9 +797,7 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
788
797
|
pcb_port_id: this.matchedPort?.pcb_port_id,
|
|
789
798
|
layer: props.layer ?? "top",
|
|
790
799
|
shape: "rect",
|
|
791
|
-
|
|
792
|
-
width: props.width,
|
|
793
|
-
height: props.height,
|
|
800
|
+
...isRotated90 ? { width: props.height, height: props.width } : { width: props.width, height: props.height },
|
|
794
801
|
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
795
802
|
x: position.x,
|
|
796
803
|
y: position.y
|
|
@@ -804,6 +811,7 @@ var SmtPad = class extends PrimitiveComponent {
|
|
|
804
811
|
|
|
805
812
|
// lib/components/primitive-components/SilkscreenPath.ts
|
|
806
813
|
import { silkscreenPathProps } from "@tscircuit/props";
|
|
814
|
+
import { applyToPoint as applyToPoint3 } from "transformation-matrix";
|
|
807
815
|
var SilkscreenPath = class extends PrimitiveComponent {
|
|
808
816
|
pcb_silkscreen_path_id = null;
|
|
809
817
|
get config() {
|
|
@@ -820,10 +828,21 @@ var SilkscreenPath = class extends PrimitiveComponent {
|
|
|
820
828
|
`Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`
|
|
821
829
|
);
|
|
822
830
|
}
|
|
831
|
+
const transform = this.computePcbGlobalTransform();
|
|
823
832
|
const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({
|
|
824
833
|
pcb_component_id: this.parent?.pcb_component_id,
|
|
825
834
|
layer,
|
|
826
|
-
route: props.route
|
|
835
|
+
route: props.route.map((p) => {
|
|
836
|
+
const transformedPosition = applyToPoint3(transform, {
|
|
837
|
+
x: p.x,
|
|
838
|
+
y: p.y
|
|
839
|
+
});
|
|
840
|
+
return {
|
|
841
|
+
...p,
|
|
842
|
+
x: transformedPosition.x,
|
|
843
|
+
y: transformedPosition.y
|
|
844
|
+
};
|
|
845
|
+
}),
|
|
827
846
|
stroke_width: props.strokeWidth ?? 0.1
|
|
828
847
|
});
|
|
829
848
|
this.pcb_silkscreen_path_id = pcb_silkscreen_path.pcb_silkscreen_path_id;
|
|
@@ -1065,7 +1084,7 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
1065
1084
|
width: 0,
|
|
1066
1085
|
height: 0,
|
|
1067
1086
|
layer: props.layer ?? "top",
|
|
1068
|
-
rotation: props.
|
|
1087
|
+
rotation: props.pcbRotation ?? 0,
|
|
1069
1088
|
source_component_id: this.source_component_id
|
|
1070
1089
|
});
|
|
1071
1090
|
this.pcb_component_id = pcb_component.pcb_component_id;
|
|
@@ -1675,7 +1694,7 @@ searched component ${targetComponent.getString()}, which has ports:${targetCompo
|
|
|
1675
1694
|
|
|
1676
1695
|
// lib/components/primitive-components/TraceHint.ts
|
|
1677
1696
|
import "@tscircuit/props";
|
|
1678
|
-
import { applyToPoint as
|
|
1697
|
+
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
1679
1698
|
var TraceHint = class extends PrimitiveComponent {
|
|
1680
1699
|
matchedPort = null;
|
|
1681
1700
|
doInitialPortMatching() {
|
|
@@ -1709,7 +1728,7 @@ var TraceHint = class extends PrimitiveComponent {
|
|
|
1709
1728
|
const globalTransform = this.computePcbGlobalTransform();
|
|
1710
1729
|
return offsets.map(
|
|
1711
1730
|
(offset) => ({
|
|
1712
|
-
...
|
|
1731
|
+
...applyToPoint4(globalTransform, offset),
|
|
1713
1732
|
via: offset.via,
|
|
1714
1733
|
to_layer: offset.to_layer,
|
|
1715
1734
|
trace_width: offset.trace_width
|
|
@@ -197,7 +197,7 @@ export class NormalComponent<
|
|
|
197
197
|
width: 0,
|
|
198
198
|
height: 0,
|
|
199
199
|
layer: props.layer ?? "top",
|
|
200
|
-
rotation: props.
|
|
200
|
+
rotation: props.pcbRotation ?? 0,
|
|
201
201
|
source_component_id: this.source_component_id!,
|
|
202
202
|
})
|
|
203
203
|
this.pcb_component_id = pcb_component.pcb_component_id
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
applyToPoint,
|
|
11
11
|
compose,
|
|
12
12
|
identity,
|
|
13
|
+
rotate,
|
|
13
14
|
translate,
|
|
14
15
|
type Matrix,
|
|
15
16
|
} from "transformation-matrix"
|
|
@@ -97,8 +98,14 @@ export abstract class PrimitiveComponent<
|
|
|
97
98
|
* components
|
|
98
99
|
*/
|
|
99
100
|
computePcbPropsTransform(): Matrix {
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
const { _parsedProps: props } = this
|
|
102
|
+
|
|
103
|
+
const matrix = compose(
|
|
104
|
+
translate(props.pcbX ?? 0, props.pcbY ?? 0),
|
|
105
|
+
rotate(((props.pcbRotation ?? 0) * Math.PI) / 180),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
return matrix
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { silkscreenPathProps } from "@tscircuit/props"
|
|
2
2
|
import { PrimitiveComponent } from "../base-components/PrimitiveComponent"
|
|
3
|
+
import { applyToPoint } from "transformation-matrix"
|
|
3
4
|
|
|
4
5
|
export class SilkscreenPath extends PrimitiveComponent<
|
|
5
6
|
typeof silkscreenPathProps
|
|
@@ -23,10 +24,22 @@ export class SilkscreenPath extends PrimitiveComponent<
|
|
|
23
24
|
)
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
const transform = this.computePcbGlobalTransform()
|
|
28
|
+
|
|
26
29
|
const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({
|
|
27
30
|
pcb_component_id: this.parent?.pcb_component_id!,
|
|
28
31
|
layer,
|
|
29
|
-
route: props.route
|
|
32
|
+
route: props.route.map((p) => {
|
|
33
|
+
const transformedPosition = applyToPoint(transform, {
|
|
34
|
+
x: p.x,
|
|
35
|
+
y: p.y,
|
|
36
|
+
})
|
|
37
|
+
return {
|
|
38
|
+
...p,
|
|
39
|
+
x: transformedPosition.x,
|
|
40
|
+
y: transformedPosition.y,
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
30
43
|
stroke_width: props.strokeWidth ?? 0.1,
|
|
31
44
|
})
|
|
32
45
|
|
|
@@ -3,6 +3,7 @@ import { smtPadProps } from "@tscircuit/props"
|
|
|
3
3
|
import type { Port } from "./Port"
|
|
4
4
|
import type { RenderPhaseFn } from "../base-components/Renderable"
|
|
5
5
|
import type { PCBSMTPad } from "@tscircuit/soup"
|
|
6
|
+
import { decomposeTSR } from "transformation-matrix"
|
|
6
7
|
|
|
7
8
|
export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
|
|
8
9
|
pcb_smtpad_id: string | null = null
|
|
@@ -40,6 +41,9 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
|
|
|
40
41
|
const { _parsedProps: props } = this
|
|
41
42
|
if (!props.portHints) return
|
|
42
43
|
const position = this.getGlobalPcbPosition()
|
|
44
|
+
const decomposedMat = decomposeTSR(this.computePcbGlobalTransform())
|
|
45
|
+
const isRotated90 =
|
|
46
|
+
Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01
|
|
43
47
|
let pcb_smtpad: PCBSMTPad | null = null
|
|
44
48
|
if (props.shape === "circle") {
|
|
45
49
|
pcb_smtpad = db.pcb_smtpad.insert({
|
|
@@ -63,9 +67,9 @@ export class SmtPad extends PrimitiveComponent<typeof smtPadProps> {
|
|
|
63
67
|
layer: props.layer ?? "top",
|
|
64
68
|
shape: "rect",
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
...(isRotated90
|
|
71
|
+
? { width: props.height, height: props.width }
|
|
72
|
+
: { width: props.width, height: props.height }),
|
|
69
73
|
|
|
70
74
|
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
71
75
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"module": "index.ts",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.19",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typescript": "^5.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tscircuit/infgrid-ijump-astar": "0.0.
|
|
34
|
+
"@tscircuit/infgrid-ijump-astar": "^0.0.6",
|
|
35
35
|
"@tscircuit/props": "^0.0.49",
|
|
36
36
|
"@tscircuit/soup": "^0.0.58",
|
|
37
37
|
"@tscircuit/soup-util": "0.0.18",
|