File size: 1,496 Bytes
e2fffc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
"""Generate README / Space thumbnail preview for Hopf visualizer."""

from __future__ import annotations

import sys
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "src"))

from kingdom.core.hopf import sample_fiber_family

OUT = ROOT / "app" / "assets" / "hopf_preview.png"
COLORS = ("#1a8fe3", "#00c9b7", "#4cc9f0", "#48bfe3", "#64dfdf", "#c9a227")


def main() -> None:
    fibers = sample_fiber_family(n_fibers=10, n_points=140)
    fig, ax = plt.subplots(figsize=(10, 6), facecolor="#0a1628")
    ax.set_facecolor("#0a1628")

    for i, fiber in enumerate(fibers):
        ax.plot(
            fiber["px"],
            fiber["py"],
            color=COLORS[i % len(COLORS)],
            linewidth=2.2,
            alpha=0.9,
        )

    ax.set_title(
        "Kingdom Come — Hopf Fibration (stereographic xy)",
        color="#e8f4ff",
        fontsize=14,
        pad=12,
    )
    ax.set_xlabel("x", color="#8ecae6")
    ax.set_ylabel("y", color="#8ecae6")
    ax.tick_params(colors="#8ecae6")
    for spine in ax.spines.values():
        spine.set_color("#1e3a5f")
    ax.set_aspect("equal")
    ax.grid(True, color="#1e3a5f", alpha=0.35)

    OUT.parent.mkdir(parents=True, exist_ok=True)
    fig.savefig(OUT, dpi=150, bbox_inches="tight", facecolor=fig.get_facecolor())
    plt.close(fig)
    print(f"Wrote {OUT}")


if __name__ == "__main__":
    main()