@tscircuit/core 0.0.716 → 0.0.717

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 (2) hide show
  1. package/dist/index.js +69 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11974,6 +11974,48 @@ import {
11974
11974
  checkEachPcbPortConnectedToPcbTraces,
11975
11975
  checkEachPcbTraceNonOverlapping
11976
11976
  } from "@tscircuit/checks";
11977
+ var getRoundedRectOutline = (width, height, radius) => {
11978
+ const r = Math.min(radius, width / 2, height / 2);
11979
+ const segments = Math.max(1, Math.ceil(Math.PI / 2 * r));
11980
+ const step = Math.PI / 2 / segments;
11981
+ const w2 = width / 2;
11982
+ const h2 = height / 2;
11983
+ const outline = [];
11984
+ outline.push({ x: -w2 + r, y: -h2 });
11985
+ outline.push({ x: w2 - r, y: -h2 });
11986
+ for (let i = 1; i <= segments; i++) {
11987
+ const theta = -Math.PI / 2 + i * step;
11988
+ outline.push({
11989
+ x: w2 - r + r * Math.cos(theta),
11990
+ y: -h2 + r + r * Math.sin(theta)
11991
+ });
11992
+ }
11993
+ outline.push({ x: w2, y: h2 - r });
11994
+ for (let i = 1; i <= segments; i++) {
11995
+ const theta = 0 + i * step;
11996
+ outline.push({
11997
+ x: w2 - r + r * Math.cos(theta),
11998
+ y: h2 - r + r * Math.sin(theta)
11999
+ });
12000
+ }
12001
+ outline.push({ x: -w2 + r, y: h2 });
12002
+ for (let i = 1; i <= segments; i++) {
12003
+ const theta = Math.PI / 2 + i * step;
12004
+ outline.push({
12005
+ x: -w2 + r + r * Math.cos(theta),
12006
+ y: h2 - r + r * Math.sin(theta)
12007
+ });
12008
+ }
12009
+ outline.push({ x: -w2, y: -h2 + r });
12010
+ for (let i = 1; i <= segments; i++) {
12011
+ const theta = Math.PI + i * step;
12012
+ outline.push({
12013
+ x: -w2 + r + r * Math.cos(theta),
12014
+ y: -h2 + r + r * Math.sin(theta)
12015
+ });
12016
+ }
12017
+ return outline;
12018
+ };
11977
12019
  var Board = class extends Group6 {
11978
12020
  pcb_board_id = null;
11979
12021
  _drcChecksComplete = false;
@@ -12049,11 +12091,26 @@ var Board = class extends Group6 {
12049
12091
  };
12050
12092
  const finalWidth = props.width ?? computedWidth;
12051
12093
  const finalHeight = props.height ?? computedHeight;
12052
- db.pcb_board.update(this.pcb_board_id, {
12094
+ let outline = props.outline;
12095
+ if (!outline && props.borderRadius != null && finalWidth > 0 && finalHeight > 0) {
12096
+ outline = getRoundedRectOutline(
12097
+ finalWidth,
12098
+ finalHeight,
12099
+ props.borderRadius
12100
+ );
12101
+ }
12102
+ const update = {
12053
12103
  width: finalWidth,
12054
12104
  height: finalHeight,
12055
12105
  center
12056
- });
12106
+ };
12107
+ if (outline) {
12108
+ update.outline = outline.map((point) => ({
12109
+ x: point.x + (props.outlineOffsetX ?? 0),
12110
+ y: point.y + (props.outlineOffsetY ?? 0)
12111
+ }));
12112
+ }
12113
+ db.pcb_board.update(this.pcb_board_id, update);
12057
12114
  }
12058
12115
  // Recompute autosize after child components update (e.g., async footprints)
12059
12116
  updatePcbBoardAutoSize() {
@@ -12115,13 +12172,21 @@ var Board = class extends Group6 {
12115
12172
  y: (minY + maxY) / 2 + (props.outlineOffsetY ?? 0)
12116
12173
  };
12117
12174
  }
12175
+ let outline = props.outline;
12176
+ if (!outline && props.borderRadius != null && computedWidth > 0 && computedHeight > 0) {
12177
+ outline = getRoundedRectOutline(
12178
+ computedWidth,
12179
+ computedHeight,
12180
+ props.borderRadius
12181
+ );
12182
+ }
12118
12183
  const pcb_board = db.pcb_board.insert({
12119
12184
  center,
12120
12185
  thickness: this.boardThickness,
12121
12186
  num_layers: this.allLayers.length,
12122
12187
  width: computedWidth,
12123
12188
  height: computedHeight,
12124
- outline: props.outline?.map((point) => ({
12189
+ outline: outline?.map((point) => ({
12125
12190
  x: point.x + (props.outlineOffsetX ?? 0),
12126
12191
  y: point.y + (props.outlineOffsetY ?? 0)
12127
12192
  })),
@@ -14711,7 +14776,7 @@ import { identity as identity6 } from "transformation-matrix";
14711
14776
  var package_default = {
14712
14777
  name: "@tscircuit/core",
14713
14778
  type: "module",
14714
- version: "0.0.715",
14779
+ version: "0.0.716",
14715
14780
  types: "dist/index.d.ts",
14716
14781
  main: "dist/index.js",
14717
14782
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.716",
4
+ "version": "0.0.717",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",