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