@tscircuit/core 0.0.695 → 0.0.697
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 +80 -21
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6387,11 +6387,69 @@ var shouldCheckPortForMissingTrace = (component, port) => {
|
|
|
6387
6387
|
return true;
|
|
6388
6388
|
};
|
|
6389
6389
|
|
|
6390
|
-
// lib/components/base-components/NormalComponent/
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6390
|
+
// lib/components/base-components/NormalComponent/utils/getPcbTextBounds.ts
|
|
6391
|
+
function getPcbTextBounds(text) {
|
|
6392
|
+
const fontSize = text.font_size;
|
|
6393
|
+
const textWidth = text.text.length * fontSize * 0.6;
|
|
6394
|
+
const textHeight = fontSize;
|
|
6395
|
+
const anchorAlignment = text.anchor_alignment || "center";
|
|
6396
|
+
let centerX = text.anchor_position.x;
|
|
6397
|
+
let centerY = text.anchor_position.y;
|
|
6398
|
+
switch (anchorAlignment) {
|
|
6399
|
+
case "top_left":
|
|
6400
|
+
centerX = text.anchor_position.x + textWidth / 2;
|
|
6401
|
+
centerY = text.anchor_position.y + textHeight / 2;
|
|
6402
|
+
break;
|
|
6403
|
+
case "top_center":
|
|
6404
|
+
centerX = text.anchor_position.x;
|
|
6405
|
+
centerY = text.anchor_position.y + textHeight / 2;
|
|
6406
|
+
break;
|
|
6407
|
+
case "top_right":
|
|
6408
|
+
centerX = text.anchor_position.x - textWidth / 2;
|
|
6409
|
+
centerY = text.anchor_position.y + textHeight / 2;
|
|
6410
|
+
break;
|
|
6411
|
+
case "center_left":
|
|
6412
|
+
centerX = text.anchor_position.x + textWidth / 2;
|
|
6413
|
+
centerY = text.anchor_position.y;
|
|
6414
|
+
break;
|
|
6415
|
+
case "center":
|
|
6416
|
+
centerX = text.anchor_position.x;
|
|
6417
|
+
centerY = text.anchor_position.y;
|
|
6418
|
+
break;
|
|
6419
|
+
case "center_right":
|
|
6420
|
+
centerX = text.anchor_position.x - textWidth / 2;
|
|
6421
|
+
centerY = text.anchor_position.y;
|
|
6422
|
+
break;
|
|
6423
|
+
case "bottom_left":
|
|
6424
|
+
centerX = text.anchor_position.x + textWidth / 2;
|
|
6425
|
+
centerY = text.anchor_position.y - textHeight / 2;
|
|
6426
|
+
break;
|
|
6427
|
+
case "bottom_center":
|
|
6428
|
+
centerX = text.anchor_position.x;
|
|
6429
|
+
centerY = text.anchor_position.y - textHeight / 2;
|
|
6430
|
+
break;
|
|
6431
|
+
case "bottom_right":
|
|
6432
|
+
centerX = text.anchor_position.x - textWidth / 2;
|
|
6433
|
+
centerY = text.anchor_position.y - textHeight / 2;
|
|
6434
|
+
break;
|
|
6435
|
+
default:
|
|
6436
|
+
centerX = text.anchor_position.x;
|
|
6437
|
+
centerY = text.anchor_position.y;
|
|
6438
|
+
break;
|
|
6439
|
+
}
|
|
6440
|
+
return {
|
|
6441
|
+
x: centerX - textWidth / 2,
|
|
6442
|
+
y: centerY - textHeight / 2,
|
|
6443
|
+
width: textWidth,
|
|
6444
|
+
height: textHeight
|
|
6445
|
+
};
|
|
6394
6446
|
}
|
|
6447
|
+
|
|
6448
|
+
// lib/components/base-components/NormalComponent/NormalComponent_doInitialSilkscreenOverlapAdjustment.ts
|
|
6449
|
+
import {
|
|
6450
|
+
getBoundingBox,
|
|
6451
|
+
doBoundsOverlap
|
|
6452
|
+
} from "@tscircuit/math-utils";
|
|
6395
6453
|
function NormalComponent_doInitialSilkscreenOverlapAdjustment(component) {
|
|
6396
6454
|
if (!component._adjustSilkscreenTextAutomatically) {
|
|
6397
6455
|
return;
|
|
@@ -6421,33 +6479,34 @@ function NormalComponent_doInitialSilkscreenOverlapAdjustment(component) {
|
|
|
6421
6479
|
});
|
|
6422
6480
|
for (const silkscreenText of silkscreenTexts) {
|
|
6423
6481
|
const currentPosition = silkscreenText.anchor_position;
|
|
6424
|
-
const
|
|
6425
|
-
const textWidth = silkscreenText.text.length * fontSize * 0.6;
|
|
6426
|
-
const textHeight = fontSize;
|
|
6482
|
+
const textBounds = getPcbTextBounds(silkscreenText);
|
|
6427
6483
|
const textBox = {
|
|
6428
|
-
center:
|
|
6429
|
-
|
|
6430
|
-
|
|
6484
|
+
center: {
|
|
6485
|
+
x: textBounds.x + textBounds.width / 2,
|
|
6486
|
+
y: textBounds.y + textBounds.height / 2
|
|
6487
|
+
},
|
|
6488
|
+
width: textBounds.width,
|
|
6489
|
+
height: textBounds.height
|
|
6431
6490
|
};
|
|
6432
|
-
const
|
|
6433
|
-
const
|
|
6434
|
-
(obstacle) =>
|
|
6491
|
+
const textBoundsBox = getBoundingBox(textBox);
|
|
6492
|
+
const hasOverlap = obstacleBounds.some(
|
|
6493
|
+
(obstacle) => doBoundsOverlap(textBoundsBox, obstacle)
|
|
6435
6494
|
);
|
|
6436
|
-
if (!
|
|
6495
|
+
if (!hasOverlap) {
|
|
6437
6496
|
continue;
|
|
6438
6497
|
}
|
|
6439
6498
|
const flippedX = 2 * componentCenter.x - currentPosition.x;
|
|
6440
6499
|
const flippedY = 2 * componentCenter.y - currentPosition.y;
|
|
6441
6500
|
const flippedTextBox = {
|
|
6442
6501
|
center: { x: flippedX, y: flippedY },
|
|
6443
|
-
width:
|
|
6444
|
-
height:
|
|
6502
|
+
width: textBounds.width,
|
|
6503
|
+
height: textBounds.height
|
|
6445
6504
|
};
|
|
6446
6505
|
const flippedTextBounds = getBoundingBox(flippedTextBox);
|
|
6447
|
-
const
|
|
6448
|
-
(obstacle) =>
|
|
6506
|
+
const flippedHasOverlap = obstacleBounds.some(
|
|
6507
|
+
(obstacle) => doBoundsOverlap(flippedTextBounds, obstacle)
|
|
6449
6508
|
);
|
|
6450
|
-
if (!
|
|
6509
|
+
if (!flippedHasOverlap) {
|
|
6451
6510
|
db.pcb_silkscreen_text.update(silkscreenText.pcb_silkscreen_text_id, {
|
|
6452
6511
|
anchor_position: {
|
|
6453
6512
|
x: flippedX,
|
|
@@ -14237,7 +14296,7 @@ import { identity as identity6 } from "transformation-matrix";
|
|
|
14237
14296
|
var package_default = {
|
|
14238
14297
|
name: "@tscircuit/core",
|
|
14239
14298
|
type: "module",
|
|
14240
|
-
version: "0.0.
|
|
14299
|
+
version: "0.0.696",
|
|
14241
14300
|
types: "dist/index.d.ts",
|
|
14242
14301
|
main: "dist/index.js",
|
|
14243
14302
|
module: "dist/index.js",
|
|
@@ -14279,7 +14338,7 @@ var package_default = {
|
|
|
14279
14338
|
"@tscircuit/props": "0.0.298",
|
|
14280
14339
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
14281
14340
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
14282
|
-
"@tscircuit/schematic-trace-solver": "^0.0.
|
|
14341
|
+
"@tscircuit/schematic-trace-solver": "^0.0.34",
|
|
14283
14342
|
"@tscircuit/simple-3d-svg": "^0.0.38",
|
|
14284
14343
|
"@types/bun": "^1.2.16",
|
|
14285
14344
|
"@types/debug": "^4.1.12",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.697",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@tscircuit/props": "0.0.298",
|
|
44
44
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
45
45
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
46
|
-
"@tscircuit/schematic-trace-solver": "^0.0.
|
|
46
|
+
"@tscircuit/schematic-trace-solver": "^0.0.34",
|
|
47
47
|
"@tscircuit/simple-3d-svg": "^0.0.38",
|
|
48
48
|
"@types/bun": "^1.2.16",
|
|
49
49
|
"@types/debug": "^4.1.12",
|