kaabalah 6.6.3 → 6.6.4

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.
@@ -1044,15 +1044,14 @@ function labelBoundsCircleOverflow(center, bounds, maxRadius) {
1044
1044
  );
1045
1045
  return farthestCorner - maxRadius;
1046
1046
  }
1047
- function hasLabelBoundsCollision(bounds, placed) {
1048
- return placed.some((other) => labelBoundsOverlap(bounds, other));
1049
- }
1050
- function labelBoundsOverlap(a, b) {
1051
- return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y);
1052
- }
1053
1047
  function formatLabelBounds(bounds) {
1054
1048
  return `${fmt(bounds.x)} ${fmt(bounds.y)} ${fmt(bounds.width)} ${fmt(bounds.height)}`;
1055
1049
  }
1050
+ function projectedLabelWidthAlongTangent(angleRad, bounds) {
1051
+ const tangentX = -Math.sin(angleRad);
1052
+ const tangentY = Math.cos(angleRad);
1053
+ return Math.abs(tangentX) * bounds.width + Math.abs(tangentY) * bounds.height;
1054
+ }
1056
1055
  var POINT_GLYPH_ALIASES = {
1057
1056
  "mean node": "north node",
1058
1057
  "true node": "north node",
@@ -1202,108 +1201,109 @@ function buildPointLayer(params) {
1202
1201
  ) : requestedRadius;
1203
1202
  const isExternalLayer = radius > rings.houses.r2 + scale;
1204
1203
  const tickLength = Math.min(14 * scale, thickness * 0.34);
1205
- const glyphMinSepDeg = glyphFontSize * 0.9 / Math.max(radius, 1) * (180 / Math.PI);
1206
- const collisionThresholdDegrees = clamp(
1207
- layer.collisionThresholdDegrees ?? Math.max(2, Math.min(8, glyphMinSepDeg)),
1208
- 0,
1209
- 30
1210
- );
1211
- const tangentStep = glyphFontSize * (isExternalLayer ? 0.68 : 0.74);
1212
1204
  const collisionPadding = Math.max(2 * scale, 1.5);
1213
1205
  const zodiacKeepOutGap = Math.max(5 * scale, 4);
1214
1206
  const labelMaxRadius = isExternalLayer ? Number.POSITIVE_INFINITY : rings.zodiac.r1 - zodiacKeepOutGap;
1215
1207
  const seeds = getPointSeeds(layer, excludedBodies);
1216
- const clusters = clusterPointSeeds(seeds, collisionThresholdDegrees);
1217
1208
  const color = layer.color ?? palette.planetGlyph;
1218
1209
  const tickColor = layer.tickColor ?? color;
1219
- const placedLabelBounds = [];
1220
- const points = clusters.flatMap((cluster) => {
1221
- const clusterMidpoint = (cluster.length - 1) / 2;
1222
- return cluster.map((seed, index) => {
1223
- const tickAngle = angleOf(seed.longitude);
1224
- const pointGlyphFontSize = seed.kind === "vertex" ? glyphFontSize * 0.82 : glyphFontSize;
1225
- const rawGlyphRadius = radius;
1226
- const glyphRadius = isExternalLayer ? rawGlyphRadius : clamp(
1227
- rawGlyphRadius,
1228
- rings.aspects.r2 + pointGlyphFontSize * 0.65,
1229
- labelMaxRadius - pointGlyphFontSize * 0.5
1230
- );
1231
- const tickLine = isExternalLayer ? lineFromPolar(
1232
- center,
1233
- rings.houses.r2 + 2 * scale,
1234
- Math.max(rings.houses.r2 + 6 * scale, radius - glyphFontSize * 0.44),
1235
- tickAngle
1236
- ) : lineFromPolar(center, ring.r2 - tickLength, ring.r2, tickAngle);
1237
- const leaderStartRadius = isExternalLayer ? Math.max(rings.houses.r2 + 6 * scale, radius - glyphFontSize * 0.44) : radius;
1238
- const leaderStart = polarToXY(center.x, center.y, leaderStartRadius, tickAngle);
1239
- let tangentOffset = cluster.length > 1 ? (index - clusterMidpoint) * tangentStep : 0;
1240
- const nudgeDirection = index - clusterMidpoint >= 0 ? 1 : -1;
1241
- const makePoint = () => {
1242
- const labelAngle = tickAngle + tangentOffset / Math.max(glyphRadius, 1);
1243
- let glyphPosition = polarToXY(center.x, center.y, glyphRadius, labelAngle);
1244
- const labelDisplaced = Math.abs(tangentOffset) > 0.01;
1245
- let point2 = {
1246
- layerId: layer.id,
1247
- key: seed.key,
1248
- name: seed.name,
1249
- kind: seed.kind,
1250
- glyph: seed.glyph,
1251
- glyphKey: seed.glyphKey,
1252
- longitude: normalizeAngle(seed.longitude),
1253
- displayLongitude: normalizeAngle(seed.longitude),
1254
- zodiacPosition: seed.zodiacPosition,
1255
- tickLine,
1256
- labelAngle,
1257
- leaderLine: labelDisplaced ? {
1258
- x1: leaderStart.x,
1259
- y1: leaderStart.y,
1260
- x2: glyphPosition.x,
1261
- y2: glyphPosition.y
1262
- } : void 0,
1263
- glyphPosition,
1264
- glyphFontSize: pointGlyphFontSize,
1265
- retrograde: seed.retrograde,
1266
- color,
1267
- tickColor
1268
- };
1269
- const layout = getPointLabelLayout(point2, scale);
1270
- const constrainedLabel = constrainLabelInsideCircle({
1271
- center,
1272
- position: glyphPosition,
1273
- layout,
1274
- padding: collisionPadding,
1275
- maxRadius: labelMaxRadius
1276
- });
1277
- if (constrainedLabel.moved) {
1278
- glyphPosition = constrainedLabel.position;
1279
- point2 = {
1280
- ...point2,
1281
- glyphPosition,
1282
- leaderLine: {
1283
- x1: leaderStart.x,
1284
- y1: leaderStart.y,
1285
- x2: glyphPosition.x,
1286
- y2: glyphPosition.y
1287
- }
1288
- };
1210
+ const pointIntents = seeds.map((seed) => {
1211
+ const tickAngle = angleOf(seed.longitude);
1212
+ const pointGlyphFontSize = seed.kind === "vertex" ? glyphFontSize * 0.82 : glyphFontSize;
1213
+ const rawGlyphRadius = radius;
1214
+ const glyphRadius = isExternalLayer ? rawGlyphRadius : clamp(
1215
+ rawGlyphRadius,
1216
+ rings.aspects.r2 + pointGlyphFontSize * 0.65,
1217
+ labelMaxRadius - pointGlyphFontSize * 0.5
1218
+ );
1219
+ const tickLine = isExternalLayer ? lineFromPolar(
1220
+ center,
1221
+ rings.houses.r2 + 2 * scale,
1222
+ Math.max(rings.houses.r2 + 6 * scale, radius - glyphFontSize * 0.44),
1223
+ tickAngle
1224
+ ) : lineFromPolar(center, ring.r2 - tickLength, ring.r2, tickAngle);
1225
+ const leaderStartRadius = isExternalLayer ? Math.max(rings.houses.r2 + 6 * scale, radius - glyphFontSize * 0.44) : radius;
1226
+ const leaderStart = polarToXY(center.x, center.y, leaderStartRadius, tickAngle);
1227
+ const idealPosition = polarToXY(center.x, center.y, glyphRadius, tickAngle);
1228
+ const point = makeAstroWheelPoint({
1229
+ layer,
1230
+ seed,
1231
+ tickLine,
1232
+ leaderStart,
1233
+ tickAngle,
1234
+ labelAngle: tickAngle,
1235
+ glyphPosition: idealPosition,
1236
+ glyphFontSize: pointGlyphFontSize,
1237
+ color,
1238
+ tickColor
1239
+ });
1240
+ const layout = getPointLabelLayout(point, scale);
1241
+ const labelBounds = labelBoundsFor(idealPosition, layout, collisionPadding);
1242
+ const labelTangentDemandPx = projectedLabelWidthAlongTangent(tickAngle, labelBounds);
1243
+ const configuredTangentDemandPx = layer.collisionThresholdDegrees ? deg2rad(clamp(layer.collisionThresholdDegrees, 0, 30)) * glyphRadius : 0;
1244
+ const tangentDemandPx = Math.max(labelTangentDemandPx, configuredTangentDemandPx);
1245
+ return {
1246
+ seed,
1247
+ tickAngle,
1248
+ tickLine,
1249
+ leaderStart,
1250
+ glyphRadius,
1251
+ pointGlyphFontSize,
1252
+ tangentDemandPx
1253
+ };
1254
+ });
1255
+ const solvedLabels = solveCircularLabelAngles(
1256
+ pointIntents.map((intent) => ({
1257
+ item: intent,
1258
+ idealAngle: intent.tickAngle,
1259
+ radius: intent.glyphRadius,
1260
+ tangentDemandPx: intent.tangentDemandPx
1261
+ })),
1262
+ collisionPadding
1263
+ );
1264
+ const visualAngleByKey = Object.fromEntries(
1265
+ solvedLabels.map(({ item, visualAngle }) => [item.seed.key, visualAngle])
1266
+ );
1267
+ const points = pointIntents.map((intent) => {
1268
+ const visualAngle = visualAngleByKey[intent.seed.key] ?? intent.tickAngle;
1269
+ let glyphPosition = polarToXY(center.x, center.y, intent.glyphRadius, visualAngle);
1270
+ let point = makeAstroWheelPoint({
1271
+ layer,
1272
+ seed: intent.seed,
1273
+ tickLine: intent.tickLine,
1274
+ leaderStart: intent.leaderStart,
1275
+ tickAngle: intent.tickAngle,
1276
+ labelAngle: visualAngle,
1277
+ glyphPosition,
1278
+ glyphFontSize: intent.pointGlyphFontSize,
1279
+ color,
1280
+ tickColor
1281
+ });
1282
+ const layout = getPointLabelLayout(point, scale);
1283
+ const constrainedLabel = constrainLabelInsideCircle({
1284
+ center,
1285
+ position: glyphPosition,
1286
+ layout,
1287
+ padding: collisionPadding,
1288
+ maxRadius: labelMaxRadius
1289
+ });
1290
+ if (constrainedLabel.moved) {
1291
+ glyphPosition = constrainedLabel.position;
1292
+ point = {
1293
+ ...point,
1294
+ glyphPosition,
1295
+ leaderLine: {
1296
+ x1: intent.leaderStart.x,
1297
+ y1: intent.leaderStart.y,
1298
+ x2: glyphPosition.x,
1299
+ y2: glyphPosition.y
1289
1300
  }
1290
- return {
1291
- ...point2,
1292
- labelBounds: constrainedLabel.bounds
1293
- };
1294
1301
  };
1295
- let point = makePoint();
1296
- let attempts = 0;
1297
- while (point.labelBounds && hasLabelBoundsCollision(point.labelBounds, placedLabelBounds) && attempts < 16) {
1298
- tangentOffset += nudgeDirection * (tangentStep * 0.45 + collisionPadding);
1299
- point = makePoint();
1300
- attempts += 1;
1301
- }
1302
- if (point.labelBounds) {
1303
- placedLabelBounds.push(point.labelBounds);
1304
- }
1305
- return point;
1306
- });
1302
+ }
1303
+ return {
1304
+ ...point,
1305
+ labelBounds: constrainedLabel.bounds
1306
+ };
1307
1307
  });
1308
1308
  return {
1309
1309
  id: layer.id,
@@ -1314,6 +1314,45 @@ function buildPointLayer(params) {
1314
1314
  points
1315
1315
  };
1316
1316
  }
1317
+ function makeAstroWheelPoint(params) {
1318
+ const {
1319
+ layer,
1320
+ seed,
1321
+ tickLine,
1322
+ leaderStart,
1323
+ tickAngle,
1324
+ labelAngle,
1325
+ glyphPosition,
1326
+ glyphFontSize,
1327
+ color,
1328
+ tickColor
1329
+ } = params;
1330
+ const labelDisplaced = circularAngleDistance(labelAngle, tickAngle) > 1e-4;
1331
+ return {
1332
+ layerId: layer.id,
1333
+ key: seed.key,
1334
+ name: seed.name,
1335
+ kind: seed.kind,
1336
+ glyph: seed.glyph,
1337
+ glyphKey: seed.glyphKey,
1338
+ longitude: normalizeAngle(seed.longitude),
1339
+ displayLongitude: normalizeAngle(seed.longitude),
1340
+ zodiacPosition: seed.zodiacPosition,
1341
+ tickLine,
1342
+ labelAngle,
1343
+ leaderLine: labelDisplaced ? {
1344
+ x1: leaderStart.x,
1345
+ y1: leaderStart.y,
1346
+ x2: glyphPosition.x,
1347
+ y2: glyphPosition.y
1348
+ } : void 0,
1349
+ glyphPosition,
1350
+ glyphFontSize,
1351
+ retrograde: seed.retrograde,
1352
+ color,
1353
+ tickColor
1354
+ };
1355
+ }
1317
1356
  function buildAspectLayer(params) {
1318
1357
  const { layer, chart, pointByKey, center, angleOf, rings, palette, excludedBodies } = params;
1319
1358
  const sourceEdges = getSourceAspectEdges(chart, {
@@ -1435,37 +1474,81 @@ function pointSeed(point, layerId) {
1435
1474
  zodiacPosition: point.zodiacPosition
1436
1475
  };
1437
1476
  }
1438
- function clusterPointSeeds(seeds, minSepDeg) {
1439
- if (seeds.length === 0) {
1477
+ function solveCircularLabelAngles(items, paddingPx) {
1478
+ if (items.length === 0) {
1440
1479
  return [];
1441
1480
  }
1442
- const clusters = [];
1443
- let current = [];
1444
- for (const seed of seeds) {
1445
- if (current.length === 0) {
1446
- current.push(seed);
1447
- continue;
1481
+ const normalized = items.map((item) => ({
1482
+ ...item,
1483
+ idealAngle: clampRad(item.idealAngle)
1484
+ })).sort((a, b) => a.idealAngle - b.idealAngle);
1485
+ if (normalized.length === 1) {
1486
+ return [{ ...normalized[0], visualAngle: normalized[0].idealAngle }];
1487
+ }
1488
+ let largestGap = -Infinity;
1489
+ let seamIndex = 0;
1490
+ for (let i = 0; i < normalized.length; i++) {
1491
+ const current = normalized[i];
1492
+ const next = normalized[(i + 1) % normalized.length];
1493
+ const nextAngle = i === normalized.length - 1 ? next.idealAngle + TAU : next.idealAngle;
1494
+ const gap = nextAngle - current.idealAngle;
1495
+ if (gap > largestGap) {
1496
+ largestGap = gap;
1497
+ seamIndex = (i + 1) % normalized.length;
1448
1498
  }
1449
- const previous = current[current.length - 1];
1450
- const delta = clamp360(seed.longitude - previous.longitude);
1451
- if (delta <= minSepDeg) {
1452
- current.push(seed);
1453
- } else {
1454
- clusters.push(current);
1455
- current = [seed];
1499
+ }
1500
+ const linear = [
1501
+ ...normalized.slice(seamIndex),
1502
+ ...normalized.slice(0, seamIndex)
1503
+ ].map((item, index) => {
1504
+ const wrapped = seamIndex > 0 && index >= normalized.length - seamIndex;
1505
+ return {
1506
+ ...item,
1507
+ idealAngle: item.idealAngle + (wrapped ? TAU : 0)
1508
+ };
1509
+ });
1510
+ for (let i = 1; i < linear.length; i++) {
1511
+ while (linear[i].idealAngle <= linear[i - 1].idealAngle) {
1512
+ linear[i] = {
1513
+ ...linear[i],
1514
+ idealAngle: linear[i].idealAngle + TAU
1515
+ };
1456
1516
  }
1457
1517
  }
1458
- clusters.push(current);
1459
- if (clusters.length > 1) {
1460
- const first = clusters[0];
1461
- const last = clusters[clusters.length - 1];
1462
- const wrapDelta = clamp360(first[0].longitude - last[last.length - 1].longitude);
1463
- if (wrapDelta <= minSepDeg) {
1464
- clusters[0] = [...last, ...first];
1465
- clusters.pop();
1518
+ const solved = linear.map((item) => ({
1519
+ ...item,
1520
+ visualAngle: item.idealAngle
1521
+ }));
1522
+ for (let i = 1; i < solved.length; i++) {
1523
+ const previous = solved[i - 1];
1524
+ const current = solved[i];
1525
+ const minGap = labelAngularHalfDemand(previous, paddingPx) + labelAngularHalfDemand(current, paddingPx);
1526
+ if (current.visualAngle < previous.visualAngle + minGap) {
1527
+ current.visualAngle = previous.visualAngle + minGap;
1466
1528
  }
1467
1529
  }
1468
- return clusters;
1530
+ for (let i = solved.length - 2; i >= 0; i--) {
1531
+ const current = solved[i];
1532
+ const next = solved[i + 1];
1533
+ const minGap = labelAngularHalfDemand(current, paddingPx) + labelAngularHalfDemand(next, paddingPx);
1534
+ if (current.visualAngle > next.visualAngle - minGap) {
1535
+ current.visualAngle = next.visualAngle - minGap;
1536
+ }
1537
+ }
1538
+ return solved.map((item) => ({
1539
+ ...item,
1540
+ visualAngle: clampRad(item.visualAngle)
1541
+ }));
1542
+ }
1543
+ function labelAngularHalfDemand(item, paddingPx) {
1544
+ return (item.tangentDemandPx / 2 + paddingPx) / Math.max(item.radius, 1);
1545
+ }
1546
+ function clampRad(value) {
1547
+ return (value % TAU + TAU) % TAU;
1548
+ }
1549
+ function circularAngleDistance(a, b) {
1550
+ const delta = Math.abs(clampRad(a) - clampRad(b));
1551
+ return Math.min(delta, TAU - delta);
1469
1552
  }
1470
1553
  function getSourceAspectEdges(chart, options) {
1471
1554
  if (options.edges) {
@@ -2758,5 +2841,5 @@ exports.getAstroWheelRenderModel = getAstroWheelRenderModel;
2758
2841
  exports.getTreeLayout = getTreeLayout;
2759
2842
  exports.getTreeRenderModel = getTreeRenderModel;
2760
2843
  exports.listAstroGlyphs = listAstroGlyphs;
2761
- //# sourceMappingURL=chunk-ZDISHSMX.js.map
2762
- //# sourceMappingURL=chunk-ZDISHSMX.js.map
2844
+ //# sourceMappingURL=chunk-NRAAMI6I.js.map
2845
+ //# sourceMappingURL=chunk-NRAAMI6I.js.map