@tscircuit/pcb-viewer 1.11.255 → 1.11.257

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 CHANGED
@@ -8008,13 +8008,24 @@ var convertElementToPrimitives = (element, allElements) => {
8008
8008
  _source_port
8009
8009
  });
8010
8010
  if (text) {
8011
+ const baseOffset = (font_size ?? 1) * 1.5;
8012
+ const perpX = -unitY;
8013
+ const perpY = unitX;
8014
+ const midpointX = (from.x + to.x) / 2;
8015
+ const midpointY = (from.y + to.y) / 2;
8016
+ let textOffset = baseOffset;
8017
+ if (Math.abs(unitX) > Math.abs(unitY)) {
8018
+ textOffset = midpointY >= 0 ? baseOffset : -baseOffset;
8019
+ } else {
8020
+ textOffset = midpointX >= 0 ? -baseOffset : baseOffset;
8021
+ }
8011
8022
  primitives.push({
8012
8023
  _pcb_drawing_object_id: getNewPcbDrawingObjectId(
8013
8024
  "pcb_fabrication_note_dimension"
8014
8025
  ),
8015
8026
  pcb_drawing_type: "text",
8016
- x: (from.x + to.x) / 2,
8017
- y: (from.y + to.y) / 2,
8027
+ x: (from.x + to.x) / 2 + perpX * textOffset,
8028
+ y: (from.y + to.y) / 2 + perpY * textOffset,
8018
8029
  layer,
8019
8030
  align: "center",
8020
8031
  text,
@@ -8259,11 +8270,22 @@ var convertElementToPrimitives = (element, allElements) => {
8259
8270
  _element: element
8260
8271
  });
8261
8272
  if (text) {
8273
+ const baseOffset = font_size * 1.5;
8274
+ const perpX = -unitY;
8275
+ const perpY = unitX;
8276
+ const midpointX = (from.x + to.x) / 2;
8277
+ const midpointY = (from.y + to.y) / 2;
8278
+ let textOffset = baseOffset;
8279
+ if (Math.abs(unitX) > Math.abs(unitY)) {
8280
+ textOffset = midpointY >= 0 ? baseOffset : -baseOffset;
8281
+ } else {
8282
+ textOffset = midpointX >= 0 ? -baseOffset : baseOffset;
8283
+ }
8262
8284
  primitives.push({
8263
8285
  _pcb_drawing_object_id: getNewPcbDrawingObjectId("pcb_note_dimension"),
8264
8286
  pcb_drawing_type: "text",
8265
- x: (from.x + to.x) / 2,
8266
- y: (from.y + to.y) / 2,
8287
+ x: (from.x + to.x) / 2 + perpX * textOffset,
8288
+ y: (from.y + to.y) / 2 + perpY * textOffset,
8267
8289
  layer: "notes",
8268
8290
  align: "center",
8269
8291
  text,
@@ -12420,7 +12442,7 @@ import { css as css3 } from "@emotion/css";
12420
12442
  // package.json
12421
12443
  var package_default = {
12422
12444
  name: "@tscircuit/pcb-viewer",
12423
- version: "1.11.254",
12445
+ version: "1.11.256",
12424
12446
  main: "dist/index.js",
12425
12447
  type: "module",
12426
12448
  repository: "tscircuit/pcb-viewer",
@@ -12472,8 +12494,8 @@ var package_default = {
12472
12494
  "@emotion/css": "^11.11.2",
12473
12495
  "@tscircuit/alphabet": "^0.0.3",
12474
12496
  "@vitejs/plugin-react": "^5.0.2",
12475
- "circuit-json": "^0.0.302",
12476
- "circuit-to-svg": "^0.0.240",
12497
+ "circuit-json": "^0.0.307",
12498
+ "circuit-to-svg": "^0.0.265",
12477
12499
  color: "^4.2.3",
12478
12500
  "react-supergrid": "^1.0.10",
12479
12501
  "react-toastify": "^10.0.5",