Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ interface PcbNoteText {
font: "tscircuit2024"
font_size: Length
text?: string
ccw_rotation?: Rotation
anchor_position: Point
anchor_alignment:
| "center"
Expand Down
1 change: 1 addition & 0 deletions docs/PCB_COMPONENT_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export interface PcbNoteText {
font: "tscircuit2024"
font_size: Length
text?: string
ccw_rotation?: Rotation
anchor_position: Point
anchor_alignment:
| "center"
Expand Down
4 changes: 3 additions & 1 deletion src/pcb/pcb_note_text.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod"
import { point, type Point, getZodPrefixedIdWithDefault } from "src/common"
import { visible_layer, type VisibleLayer } from "src/pcb/properties/layer_ref"
import { distance, type Length } from "src/units"
import { distance, rotation, type Length, type Rotation } from "src/units"
import { expectTypesMatch } from "src/utils/expect-types-match"

export const pcb_note_text = z
Expand All @@ -15,6 +15,7 @@ export const pcb_note_text = z
font: z.literal("tscircuit2024").default("tscircuit2024"),
font_size: distance.default("1mm"),
text: z.string().optional(),
ccw_rotation: rotation.optional(),
anchor_position: point.default({ x: 0, y: 0 }),
Comment thread
rushabhcodes marked this conversation as resolved.
anchor_alignment: z
.enum(["center", "top_left", "top_right", "bottom_left", "bottom_right"])
Expand All @@ -40,6 +41,7 @@ export interface PcbNoteText {
font: "tscircuit2024"
font_size: Length
text?: string
ccw_rotation?: Rotation
anchor_position: Point
anchor_alignment:
| "center"
Expand Down
20 changes: 20 additions & 0 deletions tests/pcb_note_components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,23 @@ test("pcb note text allows optional name and text", () => {
expect(note.name).toBe("Callout")
expect(note.text).toBeUndefined()
})

test("pcb note text allows optional ccw rotation", () => {
const note = pcb_note_text.parse({
type: "pcb_note_text",
text: "Rotate me",
ccw_rotation: 45,
})

expect(note.ccw_rotation).toBe(45)
})
Comment thread
rushabhcodes marked this conversation as resolved.

test("pcb note text allows unit-suffixed ccw rotation", () => {
const note = pcb_note_text.parse({
type: "pcb_note_text",
text: "Rotate me too",
ccw_rotation: "0.5rad",
})

expect(note.ccw_rotation).toBeCloseTo((0.5 * 180) / Math.PI)
})
Loading