Files
sorsfonalak/services/frontend/src/components/ZodiacWheel.tsx
T

128 lines
3.8 KiB
TypeScript
Raw Normal View History

2026-11-17 05:51:30 +00:00
// Decorative chart wheel for the login page (pure SVG, sample sky from the design canvas).
2026-11-17 05:51:30 +00:00
const SIGNS = ["♈", "♉", "♊", "♋", "♌", "♍", "♎", "♏", "♐", "♑", "♒", "♓"];
const ASC = 182.73;
const PLANETS: [string, number][] = [
["☉", 53.61],
["☽", 204.02],
["☿", 46.72],
["♀", 62.71],
["♂", 334.49],
["♃", 311.71],
["♄", 80.06],
["♅", 199.7],
["♆", 246.42],
["♇", 181.88],
];
// angle, orb, colour, dash (conjunctions are not drawn)
const ASPECTS: [number, number, string, string | undefined][] = [
[0, 7, "", undefined],
[60, 5, "#7fb0ff", "1.2 1"],
[90, 6, "#f08a4b", undefined],
[120, 6, "#7fb0ff", undefined],
[180, 7, "#f08a4b", "1.8 1"],
];
const VS = "︎"; // text presentation, not emoji
2026-11-17 05:51:30 +00:00
const norm = (a: number) => ((a % 360) + 360) % 360;
function point(lon: number, r: number) {
const t = ((180 + lon - ASC) * Math.PI) / 180;
return { x: 50 + r * Math.cos(t), y: 50 - r * Math.sin(t) };
}
2026-11-17 05:51:30 +00:00
/** Glyph positions pushed at least 12° apart. */
function spread(): { g: string; lon: number; at: number }[] {
const out = PLANETS.map(([g, lon]) => ({ g, lon, at: lon })).sort((a, b) => a.at - b.at);
for (let it = 0; it < 14; it++) {
for (let k = 0; k < out.length; k++) {
const a = out[k];
const b = out[(k + 1) % out.length];
const gap = norm(b.at - a.at);
if (gap < 12) {
a.at -= (12 - gap) / 2;
b.at += (12 - gap) / 2;
}
}
}
return out;
}
function aspectLines() {
const lines: { a: number; b: number; color: string; dash?: string }[] = [];
PLANETS.forEach(([, a], i) =>
PLANETS.slice(i + 1).forEach(([, b]) => {
let d = Math.abs(norm(a) - norm(b));
if (d > 180) d = 360 - d;
2026-11-17 05:51:30 +00:00
const hit = ASPECTS.find(([angle, orb]) => Math.abs(d - angle) <= orb);
if (hit && hit[0] > 0) lines.push({ a, b, color: hit[2], dash: hit[3] });
}),
);
2026-11-17 05:51:30 +00:00
return lines;
}
export function ZodiacWheel({ className }: { className?: string }) {
return (
<svg className={className} viewBox="0 0 100 100" aria-hidden="true">
2026-11-17 05:51:30 +00:00
<circle cx="50" cy="50" r="49.6" fill="none" stroke="#2c3654" strokeWidth="0.35" />
<circle cx="50" cy="50" r="36" fill="none" stroke="#2c3654" strokeWidth="0.25" />
<circle cx="50" cy="50" r="16" fill="#0f1426" stroke="#263049" strokeWidth="0.25" />
{SIGNS.map((g, i) => {
const p = point(i * 30 + 15, 43);
return (
<text
key={g}
x={p.x}
y={p.y}
textAnchor="middle"
dominantBaseline="central"
2026-11-17 05:51:30 +00:00
fontSize="6.5"
fill={i % 3 === 0 ? "#d9b46a" : "#5a6790"}
style={{ fontFamily: "var(--font-symbols)" }}
>
2026-11-17 05:51:30 +00:00
{g + VS}
</text>
);
})}
2026-11-17 05:51:30 +00:00
{aspectLines().map(({ a, b, color, dash }) => {
const p = point(a, 16);
const q = point(b, 16);
return (
<line
key={`${a}-${b}`}
x1={p.x}
y1={p.y}
x2={q.x}
y2={q.y}
2026-11-17 05:51:30 +00:00
stroke={color}
strokeWidth="0.32"
strokeDasharray={dash}
opacity="0.85"
/>
);
})}
2026-11-17 05:51:30 +00:00
{spread().map(({ g, lon, at }) => {
const t1 = point(lon, 16);
const t2 = point(lon, 19.5);
const p = point(at, 26.5);
return (
<g key={g}>
<line x1={t1.x} y1={t1.y} x2={t2.x} y2={t2.y} stroke="#ece6d8" strokeWidth="0.35" opacity="0.9" />
<text
x={p.x}
y={p.y}
textAnchor="middle"
dominantBaseline="central"
fontSize="5"
fill="#ece6d8"
style={{ fontFamily: "var(--font-symbols)" }}
>
{g + VS}
</text>
</g>
);
})}
</svg>
);
}