From 9ebe2bcbb25bcb3f98251fa5209636275e91dfbd Mon Sep 17 00:00:00 2001 From: Rushabh Patil Date: Sun, 12 Apr 2026 02:13:48 +0530 Subject: [PATCH 1/4] Add ccw rotation to pcb note text --- README.md | 1 + docs/PCB_COMPONENT_OVERVIEW.md | 1 + src/pcb/pcb_note_text.ts | 2 ++ tests/pcb_note_components.test.ts | 10 ++++++++++ 4 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 88a75917..5adeea76 100644 --- a/README.md +++ b/README.md @@ -1652,6 +1652,7 @@ interface PcbNoteText { font: "tscircuit2024" font_size: Length text?: string + ccw_rotation?: number anchor_position: Point anchor_alignment: | "center" diff --git a/docs/PCB_COMPONENT_OVERVIEW.md b/docs/PCB_COMPONENT_OVERVIEW.md index 5060abf8..fc98f82c 100644 --- a/docs/PCB_COMPONENT_OVERVIEW.md +++ b/docs/PCB_COMPONENT_OVERVIEW.md @@ -371,6 +371,7 @@ export interface PcbNoteText { font: "tscircuit2024" font_size: Length text?: string + ccw_rotation?: number anchor_position: Point anchor_alignment: | "center" diff --git a/src/pcb/pcb_note_text.ts b/src/pcb/pcb_note_text.ts index fef15f5f..f41a0763 100644 --- a/src/pcb/pcb_note_text.ts +++ b/src/pcb/pcb_note_text.ts @@ -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: z.number().optional(), anchor_position: point.default({ x: 0, y: 0 }), anchor_alignment: z .enum(["center", "top_left", "top_right", "bottom_left", "bottom_right"]) @@ -40,6 +41,7 @@ export interface PcbNoteText { font: "tscircuit2024" font_size: Length text?: string + ccw_rotation?: number anchor_position: Point anchor_alignment: | "center" diff --git a/tests/pcb_note_components.test.ts b/tests/pcb_note_components.test.ts index b61e627a..43f0fcf5 100644 --- a/tests/pcb_note_components.test.ts +++ b/tests/pcb_note_components.test.ts @@ -93,3 +93,13 @@ 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) +}) From a6f2ddc82e52a0fdbd07cc929bb38434a3021411 Mon Sep 17 00:00:00 2001 From: Rushabh Patil Date: Sun, 12 Apr 2026 02:21:28 +0530 Subject: [PATCH 2/4] Use shared rotation schema for pcb note text --- src/pcb/pcb_note_text.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pcb/pcb_note_text.ts b/src/pcb/pcb_note_text.ts index f41a0763..94a0c2af 100644 --- a/src/pcb/pcb_note_text.ts +++ b/src/pcb/pcb_note_text.ts @@ -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 @@ -15,7 +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: z.number().optional(), + ccw_rotation: rotation.optional(), anchor_position: point.default({ x: 0, y: 0 }), anchor_alignment: z .enum(["center", "top_left", "top_right", "bottom_left", "bottom_right"]) @@ -41,7 +41,7 @@ export interface PcbNoteText { font: "tscircuit2024" font_size: Length text?: string - ccw_rotation?: number + ccw_rotation?: Rotation anchor_position: Point anchor_alignment: | "center" From e932b200d83384411afce5ac0ae51ff68d11e877 Mon Sep 17 00:00:00 2001 From: Rushabh Patil Date: Sun, 12 Apr 2026 02:23:45 +0530 Subject: [PATCH 3/4] Add unit-suffixed pcb note rotation test --- tests/pcb_note_components.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/pcb_note_components.test.ts b/tests/pcb_note_components.test.ts index 43f0fcf5..e7fec0d4 100644 --- a/tests/pcb_note_components.test.ts +++ b/tests/pcb_note_components.test.ts @@ -103,3 +103,13 @@ test("pcb note text allows optional ccw rotation", () => { expect(note.ccw_rotation).toBe(45) }) + +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) +}) From a4eca9bc8284b2f0c3c3ce31419b1dc00f9a4f65 Mon Sep 17 00:00:00 2001 From: Rushabh Patil Date: Sun, 12 Apr 2026 02:36:36 +0530 Subject: [PATCH 4/4] Fix pcb note rotation docs type --- README.md | 2 +- docs/PCB_COMPONENT_OVERVIEW.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5adeea76..29afa111 100644 --- a/README.md +++ b/README.md @@ -1652,7 +1652,7 @@ interface PcbNoteText { font: "tscircuit2024" font_size: Length text?: string - ccw_rotation?: number + ccw_rotation?: Rotation anchor_position: Point anchor_alignment: | "center" diff --git a/docs/PCB_COMPONENT_OVERVIEW.md b/docs/PCB_COMPONENT_OVERVIEW.md index fc98f82c..6f02d0d6 100644 --- a/docs/PCB_COMPONENT_OVERVIEW.md +++ b/docs/PCB_COMPONENT_OVERVIEW.md @@ -371,7 +371,7 @@ export interface PcbNoteText { font: "tscircuit2024" font_size: Length text?: string - ccw_rotation?: number + ccw_rotation?: Rotation anchor_position: Point anchor_alignment: | "center"