@johnmorrisdotca/wakusei-planets 0.24.0 → 0.25.0

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.
@@ -52,8 +52,9 @@ float oval(vec3 p, float lon0, float lat0, float rx, float ry, float soft) {
52
52
  float dy = (lat(p) - radians(lat0)) / radians(ry);
53
53
  return 1.0 - smoothstep(1.0 - soft, 1.0, sqrt(dx * dx + dy * dy));
54
54
  }`;
55
- /** The fragment shader of a body: the surface code goes between the prelude and `main`. */
56
- export function bodyFragment(surface, painted, world = false) {
55
+ /** The fragment shader of a body: the surface code goes between the prelude and `main`. `limbTint` is the colour the edge of a glowing body shifts to (default the Sun's orange). */
56
+ export function bodyFragment(surface, painted, world = false, limbTint) {
57
+ const tint = limbTint === undefined ? "vec3(1.0, 0.55, 0.25)" : `vec3(${limbTint.map((v) => v.toFixed(4)).join(", ")})`;
57
58
  return /* glsl */ `
58
59
  precision highp float;
59
60
  uniform vec3 uLight;
@@ -84,7 +85,7 @@ void main() {
84
85
  float mu = ${world ? "clamp(dot(n, normalize(vV)), 0.0, 1.0)" : "clamp(n.z, 0.0, 1.0)"};
85
86
  if (uEmissive > 0.5) {
86
87
  float edge = pow(mu, uLimb);
87
- vec3 c = s.rgb * mix(vec3(1.0, 0.55, 0.25), vec3(1.0), edge) * (0.55 + 0.45 * edge);
88
+ vec3 c = s.rgb * mix(${tint}, vec3(1.0), edge) * (0.55 + 0.45 * edge);
88
89
  gl_FragColor = vec4(c, 1.0);
89
90
  return;
90
91
  }
@@ -235,6 +236,51 @@ void main() {
235
236
  a *= streak * smoothstep(3.0, 1.6, r);
236
237
  gl_FragColor = vec4(uColour * a, a);
237
238
  }`;
239
+ /**
240
+ * The glow round a star that is not the Sun, drawn on a plane behind it: a wide soft bloom, a tight bright inner bloom, a thin glowing edge (the chromosphere), and, on an active star, prominences standing off the edge
241
+ * with an occasional flare. `uStrength` is how bright, `uSpread` how fast the bloom fades, `uRim` the edge, `uProm` how big the prominences are, `uSeed` where they are and `uTime` moves them.
242
+ */
243
+ export const STAR_GLOW_FRAGMENT = /* glsl */ `
244
+ precision highp float;
245
+ varying vec2 vP;
246
+ uniform vec3 uColour;
247
+ uniform float uStrength;
248
+ uniform float uSpread;
249
+ uniform float uRim;
250
+ uniform float uProm;
251
+ uniform float uSeed;
252
+ uniform float uTime;
253
+ float h1(float n) { return fract(sin(n * 127.1 + uSeed * 91.7) * 43758.5453); }
254
+ float n1(float x) { float i = floor(x); float f = fract(x); f = f * f * (3.0 - 2.0 * f); return mix(h1(i), h1(i + 1.0), f); }
255
+ void main() {
256
+ float r = length(vP);
257
+ if (r < 0.98) discard;
258
+ float x = r - 1.0;
259
+ float fade = smoothstep(3.0, 1.6, r);
260
+ float halo = exp(-x * uSpread) * uStrength;
261
+ float tight = exp(-x * 14.0) * uStrength * 0.9;
262
+ float rim = exp(-x * 60.0) * uRim;
263
+ vec3 col = uColour * (halo + tight) + mix(uColour, vec3(1.0), 0.4) * rim;
264
+ float a = halo + tight + rim;
265
+ if (uProm > 0.0) {
266
+ float ang = atan(vP.y, vP.x);
267
+ float site = smoothstep(0.55, 0.85, n1(ang * 2.6 + uSeed * 20.0));
268
+ float drift = 0.75 + 0.25 * sin(uTime * 0.5 + ang * 4.0);
269
+ float height = site * uProm * 0.3 * drift;
270
+ float strands = 0.65 + 0.35 * n1(ang * 70.0 + uTime * 0.3);
271
+ float pr = step(0.0, x) * pow(smoothstep(height, 0.0, x), 1.6) * site * strands * 0.9;
272
+ vec3 pc = mix(vec3(1.0, 0.42, 0.26), uColour, 0.2);
273
+ float a0 = uSeed * 6.2831853 + uTime * 0.02;
274
+ float da = atan(sin(ang - a0), cos(ang - a0));
275
+ float burst = pow(max(0.0, sin(uTime * 0.9 + uSeed * 40.0)), 24.0) * uProm;
276
+ float fl = exp(-da * da * 14.0) * exp(-x * 6.0) * burst * 1.6;
277
+ col += pc * pr + vec3(1.0, 0.92, 0.75) * fl;
278
+ a += pr + fl;
279
+ }
280
+ // additive blending multiplies by alpha, so the root of the light is the alpha and the colour carries the rest: the sum arrives as written
281
+ float s = sqrt(min(a * fade, 1.0));
282
+ gl_FragColor = vec4(col / max(a, 1e-4) * s, s);
283
+ }`;
238
284
  /** A cheap lit ball for a moon seen small beside its planet. */
239
285
  export const BALL_FRAGMENT = /* glsl */ `
240
286
  precision highp float;
@@ -72,6 +72,17 @@ export interface BodyLook {
72
72
  atmosphere?: Atmosphere;
73
73
  /** How much the disc darkens toward the limb, 0 to 1. Default 0. */
74
74
  limb?: number;
75
+ /** For a glowing body: the colour its edge shifts to as it darkens (0 to 1 each). Default the Sun's, orange. */
76
+ limbTint?: readonly [number, number, number];
77
+ /** For a glowing body: its soft corona. The colour (0 to 1 each), how strong it is and how fast it fades (higher is tighter). Default the Sun's glow. */
78
+ glow?: {
79
+ colour: readonly [number, number, number];
80
+ strength: number;
81
+ spread: number; /** How bright the thin glowing edge is. Default 0. */
82
+ rim?: number; /** How big the prominences and flares on the edge are, 0 to 1. Default 0. */
83
+ prominence?: number; /** 0 to 1: where on the edge they are. */
84
+ seed?: number;
85
+ };
75
86
  /** How strongly the height shows as relief, 0 to 2. Default 0.6. */
76
87
  relief?: number;
77
88
  /** How far light wraps round the terminator: 0 is a hard edge (no air), 0.3 a soft one. Default 0.04, or 0.3 with an atmosphere. */
@@ -82,6 +93,7 @@ export interface BodyLook {
82
93
  /** Draw the painted map in the realistic look too: for a body with no honest drawing from numbers (the Earth's continents). */
83
94
  mapped?: boolean;
84
95
  }
96
+ import type { StarLook, StarNumbers } from "../star.ts";
85
97
  /**
86
98
  * Teach the package how to draw a body in three.js. Each body's entry point (`@johnmorrisdotca/wakusei-planets/jupiter`) calls this once as it loads; call it yourself to add or replace a look.
87
99
  *
@@ -111,3 +123,34 @@ export declare function registerLook(look: BodyLook): BodyLook;
111
123
  * ```
112
124
  */
113
125
  export declare const lookOf: (id: BodyId) => BodyLook | undefined;
126
+ /**
127
+ * Teach the package a star by name, so an element can be told `star="Betelgeuse"` and draw it from these numbers. The package holds no catalogue of stars: this is where a page puts the few it draws.
128
+ * The name is matched without regard to case. Registering a name again replaces it.
129
+ *
130
+ * @param name - What the star is called in the `star` attribute.
131
+ * @param numbers - The star's numbers.
132
+ * @returns The star, ready to draw.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * import { registerStarLook, starLookOf } from "@johnmorrisdotca/wakusei-planets/look";
137
+ *
138
+ * registerStarLook("Proxima Centauri", { temperatureK: 3042, radiusSun: 0.154, luminosityClass: "V", rotationDays: 83 });
139
+ * console.log(starLookOf("proxima centauri")?.colour);
140
+ * ```
141
+ */
142
+ export declare function registerStarLook(name: string, numbers: StarNumbers): StarLook;
143
+ /**
144
+ * The star registered under a name, or `undefined`.
145
+ *
146
+ * @param name - The name given to `registerStarLook`, in any case.
147
+ * @returns The star, or `undefined` when none is registered by that name.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * import { starLookOf } from "@johnmorrisdotca/wakusei-planets/look";
152
+ *
153
+ * console.log(starLookOf("Vega") === undefined);
154
+ * ```
155
+ */
156
+ export declare const starLookOf: (name: string) => StarLook | undefined;
@@ -1,4 +1,5 @@
1
- import { looks, waiting } from "./store.js";
1
+ import { starLook } from "../star.js";
2
+ import { looks, stars, waiting } from "./store.js";
2
3
  /**
3
4
  * Teach the package how to draw a body in three.js. Each body's entry point (`@johnmorrisdotca/wakusei-planets/jupiter`) calls this once as it loads; call it yourself to add or replace a look.
4
5
  *
@@ -33,3 +34,40 @@ export function registerLook(look) {
33
34
  * ```
34
35
  */
35
36
  export const lookOf = (id) => looks.get(id);
37
+ /**
38
+ * Teach the package a star by name, so an element can be told `star="Betelgeuse"` and draw it from these numbers. The package holds no catalogue of stars: this is where a page puts the few it draws.
39
+ * The name is matched without regard to case. Registering a name again replaces it.
40
+ *
41
+ * @param name - What the star is called in the `star` attribute.
42
+ * @param numbers - The star's numbers.
43
+ * @returns The star, ready to draw.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { registerStarLook, starLookOf } from "@johnmorrisdotca/wakusei-planets/look";
48
+ *
49
+ * registerStarLook("Proxima Centauri", { temperatureK: 3042, radiusSun: 0.154, luminosityClass: "V", rotationDays: 83 });
50
+ * console.log(starLookOf("proxima centauri")?.colour);
51
+ * ```
52
+ */
53
+ export function registerStarLook(name, numbers) {
54
+ const made = starLook({ name, ...numbers });
55
+ stars.set(name.trim().toLowerCase(), made);
56
+ for (const wake of waiting)
57
+ wake();
58
+ return made;
59
+ }
60
+ /**
61
+ * The star registered under a name, or `undefined`.
62
+ *
63
+ * @param name - The name given to `registerStarLook`, in any case.
64
+ * @returns The star, or `undefined` when none is registered by that name.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { starLookOf } from "@johnmorrisdotca/wakusei-planets/look";
69
+ *
70
+ * console.log(starLookOf("Vega") === undefined);
71
+ * ```
72
+ */
73
+ export const starLookOf = (name) => stars.get(name.trim().toLowerCase());
@@ -1,4 +1,5 @@
1
1
  import type { BodyId } from "../facts.ts";
2
+ import type { StarLook } from "../star.ts";
2
3
  import type { BodyLook } from "./look.ts";
3
4
  /** A body whose line look another package's element draws (the Earth, by chikyu-earth) instead of this one: the element asks it for what to show. The shaded and painted looks are always this package's. */
4
5
  export interface Delegate {
@@ -9,5 +10,7 @@ export interface Delegate {
9
10
  }): Promise<HTMLElement | null>;
10
11
  }
11
12
  export declare const looks: Map<BodyId, BodyLook>, waiting: Set<() => void>, delegates: Map<BodyId, Delegate>;
13
+ /** Stars registered by name. A copy of the package from before stars had no table, so one is added to it. */
14
+ export declare const stars: Map<string, StarLook>;
12
15
  /** Call `wake` whenever a look is registered; returns a function that stops it. */
13
16
  export declare function onRegister(wake: () => void): () => void;
@@ -1,6 +1,8 @@
1
1
  const KEY = Symbol.for("johnmorrisdotca.wakusei-planets.looks");
2
- const store = (globalThis[KEY] ??= { looks: new Map(), waiting: new Set(), delegates: new Map() });
2
+ const store = (globalThis[KEY] ??= { looks: new Map(), stars: new Map(), waiting: new Set(), delegates: new Map() });
3
3
  export const { looks, waiting, delegates } = store;
4
+ /** Stars registered by name. A copy of the package from before stars had no table, so one is added to it. */
5
+ export const stars = (store.stars ??= new Map());
4
6
  /** Call `wake` whenever a look is registered; returns a function that stops it. */
5
7
  export function onRegister(wake) {
6
8
  waiting.add(wake);
@@ -9,7 +9,7 @@ import type * as THREE from "three";
9
9
  * console.log(TEXTURE_BASE);
10
10
  * ```
11
11
  */
12
- export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.24.0/dist/textures/";
12
+ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.25.0/dist/textures/";
13
13
  /**
14
14
  * Where the sharpest surface pictures are: the files of this exact version in the repository, on jsDelivr's GitHub address. The npm package holds only the two smaller widths, so a page that
15
15
  * never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
@@ -21,7 +21,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
21
21
  * console.log(TEXTURE_FAR_BASE);
22
22
  * ```
23
23
  */
24
- export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.24.0/textures/";
24
+ export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.25.0/textures/";
25
25
  export declare const slash: (base: string) => string;
26
26
  export declare function texturePaths(element: Element): {
27
27
  textureBase(): string;
@@ -0,0 +1,20 @@
1
+ import { type LineOptions } from "./line.ts";
2
+ import { type StarLook, type StarNumbers } from "./star.ts";
3
+ /**
4
+ * A star as a line drawing, as an SVG string: its outline (squeezed when it is oblate), its cells and spots as outlines, a ring of rays, and, drawn round it, the Sun's size and the orbits of the Earth and Jupiter
5
+ * wherever they fall in the picture, so the size can be read against what we know. A caption under it gives the radius, the temperature and the class. It takes the options of `lineSvg` (the size, `pose`, `fill`, `zoom`,
6
+ * `pan`, `lang` and the colours); a picture of a star with no `pose` is a portrait of the Sun's axis.
7
+ *
8
+ * @param star - The star's numbers, or a star already made with `starLook`.
9
+ * @param options - The drawing's size, pose and colours.
10
+ * @returns The SVG markup, `<svg ...>` to `</svg>`.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { starLineSvg } from "@johnmorrisdotca/wakusei-planets";
15
+ *
16
+ * const svg = starLineSvg({ name: "Betelgeuse", temperatureK: 3600, radiusSun: 760, luminosityClass: "Ia" }, { size: 320 });
17
+ * console.log(svg.startsWith("<svg"), svg.includes("Earth's orbit"));
18
+ * ```
19
+ */
20
+ export declare function starLineSvg(star: StarNumbers | StarLook, options?: LineOptions): string;
@@ -0,0 +1,59 @@
1
+ // A star as a line drawing: the Sun's outline drawing with this star's size, shape, cells and spots, and the Sun and two orbits drawn round it, so the size can be read against what we know. Pure: one SVG string.
2
+ import { portrait } from "./pose.js";
3
+ import { bodyGroup, mix, NAVY } from "./line.js";
4
+ import { starLook } from "./star.js";
5
+ /** What a star's size is drawn beside: the Sun, the Earth's orbit and Jupiter's orbit, in solar radii (one astronomical unit is 215.03). */
6
+ const RINGS = [
7
+ { ratio: 1, en: "Sun", ja: "太陽" },
8
+ { ratio: 215.03, en: "Earth's orbit", ja: "地球の軌道" },
9
+ { ratio: 1118, en: "Jupiter's orbit", ja: "木星の軌道" },
10
+ ];
11
+ const n = (v) => (Math.round(v * 100) / 100).toString();
12
+ const escape = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
13
+ /**
14
+ * A star as a line drawing, as an SVG string: its outline (squeezed when it is oblate), its cells and spots as outlines, a ring of rays, and, drawn round it, the Sun's size and the orbits of the Earth and Jupiter
15
+ * wherever they fall in the picture, so the size can be read against what we know. A caption under it gives the radius, the temperature and the class. It takes the options of `lineSvg` (the size, `pose`, `fill`, `zoom`,
16
+ * `pan`, `lang` and the colours); a picture of a star with no `pose` is a portrait of the Sun's axis.
17
+ *
18
+ * @param star - The star's numbers, or a star already made with `starLook`.
19
+ * @param options - The drawing's size, pose and colours.
20
+ * @returns The SVG markup, `<svg ...>` to `</svg>`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { starLineSvg } from "@johnmorrisdotca/wakusei-planets";
25
+ *
26
+ * const svg = starLineSvg({ name: "Betelgeuse", temperatureK: 3600, radiusSun: 760, luminosityClass: "Ia" }, { size: 320 });
27
+ * console.log(svg.startsWith("<svg"), svg.includes("Earth's orbit"));
28
+ * ```
29
+ */
30
+ export function starLineSvg(star, options = {}) {
31
+ const made = "look" in star ? star : starLook(star);
32
+ const size = options.size ?? 320;
33
+ const lang = options.lang ?? "en";
34
+ const stroke = options.stroke ?? mix(made.tone, "#ffffff", 0.3);
35
+ const paper = options.paper ?? mix(made.tone, NAVY, 0.7);
36
+ const hair = Math.max(0.6, size / 320);
37
+ const pose = options.pose ?? portrait("sun", options);
38
+ const fit = options.fill === undefined ? 0.94 / 1.08 : options.fill;
39
+ const zoom = options.zoom ?? 1;
40
+ const frame = { cx: (size / 2) * (1 - (options.panX ?? 0)), cy: (size / 2) * (1 + (options.panY ?? 0)), r: (size / 2) * fit * zoom };
41
+ const label = lang === "ja" ? `${made.facts.name.ja}の線画 (数字から描いた絵)` : `Line drawing of ${made.facts.name.en}, drawn from its numbers`;
42
+ const rings = [];
43
+ for (const ring of RINGS) {
44
+ const r = (ring.ratio / made.radiusSun) * frame.r;
45
+ // the star's own edge is drawn already; a ring too small to see or far outside the picture is left out
46
+ if (Math.abs(ring.ratio / made.radiusSun - 1) < 0.04 || r < 3 || r > size * 1.5)
47
+ continue;
48
+ const text = lang === "ja" ? ring.ja : ring.en;
49
+ const x = frame.cx + r * Math.SQRT1_2;
50
+ const y = frame.cy + r * Math.SQRT1_2;
51
+ rings.push(`<circle cx="${n(frame.cx)}" cy="${n(frame.cy)}" r="${n(r)}" fill="none" stroke="${stroke}" stroke-opacity="0.5" stroke-width="${n(hair)}" stroke-dasharray="${n(hair * 4)} ${n(hair * 4)}"/>` +
52
+ (x < size - 4 && y < size - 14 ? `<text x="${n(x)}" y="${n(y)}" font-size="${n(size / 38)}" fill="${stroke}" fill-opacity="0.85" font-family="system-ui,sans-serif">${escape(text)}</text>` : ""));
53
+ }
54
+ const radius = made.radiusSun >= 10 ? Math.round(made.radiusSun).toLocaleString("en-US") : String(Number(made.radiusSun.toPrecision(3)));
55
+ const caption = lang === "ja" ? `太陽の${radius}倍 · ${Math.round(made.temperatureK).toLocaleString("en-US")} K · ${made.luminosityClass}` : `${radius} × Sun · ${Math.round(made.temperatureK).toLocaleString("en-US")} K · ${made.luminosityClass}`;
56
+ const text = `<text x="${n(size / 2)}" y="${n(size - size / 40)}" text-anchor="middle" font-size="${n(size / 34)}" fill="${stroke}" fill-opacity="0.85" font-family="system-ui,sans-serif">${escape(caption)}</text>`;
57
+ const group = bodyGroup("sun", pose, frame, { stroke, paper }, hair, 1, made.facts, `wk-star-${[...made.key].reduce((h, c) => (h * 31 + c.charCodeAt(0)) >>> 0, 7).toString(36)}`);
58
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${n(size)} ${n(size)}" width="${n(size)}" height="${n(size)}" role="img" aria-label="${escape(label)}"><title>${escape(label)}</title>${rings.join("")}${group}${text}</svg>`;
59
+ }
package/dist/star.d.ts ADDED
@@ -0,0 +1,193 @@
1
+ import { type BodyFacts } from "./facts.ts";
2
+ import type { BodyLook } from "./scene/look.ts";
3
+ /**
4
+ * A star's luminosity class, as the spectral type writes it: `0` a hypergiant, `Ia`, `Iab` and `Ib` supergiants, `II` a bright giant, `III` a giant, `IV` a subgiant, `V` a dwarf (the Sun is G2 V), `VI` a subdwarf and `D` a white dwarf.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { LUMINOSITY_CLASSES, type LuminosityClass } from "@johnmorrisdotca/wakusei-planets";
9
+ *
10
+ * const supergiant: LuminosityClass = LUMINOSITY_CLASSES[1];
11
+ * console.log(supergiant, LUMINOSITY_CLASSES.length);
12
+ * ```
13
+ */
14
+ export declare const LUMINOSITY_CLASSES: readonly ["0", "Ia", "Iab", "Ib", "II", "III", "IV", "V", "VI", "D"];
15
+ /**
16
+ * One of the classes in `LUMINOSITY_CLASSES`.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import type { LuminosityClass } from "@johnmorrisdotca/wakusei-planets";
21
+ *
22
+ * const dwarf: LuminosityClass = "V";
23
+ * console.log(dwarf);
24
+ * ```
25
+ */
26
+ export type LuminosityClass = (typeof LUMINOSITY_CLASSES)[number];
27
+ /**
28
+ * The numbers that make a star's picture in `StarNumbers`, by name: the ones a page may mark as `estimated`.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import type { StarNumberName } from "@johnmorrisdotca/wakusei-planets";
33
+ *
34
+ * const name: StarNumberName = "radiusSun";
35
+ * console.log(name);
36
+ * ```
37
+ */
38
+ export type StarNumberName = "temperatureK" | "radiusSun" | "luminosityClass" | "rotationDays" | "oblateness";
39
+ /**
40
+ * The numbers a star is drawn from. Only the temperature and the radius are needed; the rest has a stated default.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { starLook, type StarNumbers } from "@johnmorrisdotca/wakusei-planets";
45
+ *
46
+ * const betelgeuse: StarNumbers = { name: "Betelgeuse", temperatureK: 3600, radiusSun: 760, luminosityClass: "Ia", rotationDays: 2100 };
47
+ * console.log(starLook(betelgeuse).colour);
48
+ * ```
49
+ */
50
+ export interface StarNumbers {
51
+ /** What to call it: the picture's label. Default `Star`. */
52
+ name?: string;
53
+ /** The effective surface temperature in kelvin, 1,000 to 200,000. It sets the colour. */
54
+ temperatureK: number;
55
+ /** The radius in solar radii (the Sun is 1), above 0 and up to 5,000. It sets the size beside the Sun and the size of the rings drawn round the star. */
56
+ radiusSun: number;
57
+ /** The luminosity class: it sets how coarse the surface is (fine cells on a dwarf, a few giant cells on a supergiant, none on a white dwarf). Default `V`. */
58
+ luminosityClass?: LuminosityClass;
59
+ /** Days for one turn at the equator, negative when it turns backwards. Left out, a slow turn is drawn and the picture says the rotation is not given. */
60
+ rotationDays?: number;
61
+ /** How spotted it is, 0 to 1. Left out it follows the temperature and the class: none on hot stars, many on cool dwarfs and red dwarfs, few and large on giants. The spots are illustrative either way. */
62
+ activity?: number;
63
+ /** (equatorial radius - polar radius) / equatorial radius, 0 to 0.4. A fast spinner such as Altair is about 0.2. The star is drawn squashed, with the poles hotter than the equator (gravity darkening). Default 0. */
64
+ oblateness?: number;
65
+ /** The strength of the soft glow round the star, 0 to 1. Default 0.8. */
66
+ corona?: number;
67
+ /** The numbers above that are estimates, not measurements (a radius worked out from brightness, say). The picture says so. */
68
+ estimated?: readonly StarNumberName[];
69
+ }
70
+ /**
71
+ * How well a part of a star's picture is known: `measured` is a number the page gave, `estimated` one it marked as an estimate, `derived` is worked out from those numbers by a stated rule, and `illustrative` is invented to look right.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import type { StarStatus } from "@johnmorrisdotca/wakusei-planets";
76
+ *
77
+ * const status: StarStatus = "illustrative";
78
+ * console.log(status);
79
+ * ```
80
+ */
81
+ export type StarStatus = "measured" | "estimated" | "derived" | "illustrative";
82
+ /**
83
+ * One part of a star's picture and how well it is known, with a sentence for a page to show in English and Japanese.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { starLook, type StarPart } from "@johnmorrisdotca/wakusei-planets";
88
+ *
89
+ * const parts: readonly StarPart[] = starLook({ temperatureK: 5772, radiusSun: 1 }).parts;
90
+ * console.log(parts.map((part) => `${part.part}: ${part.status}`).join(", "));
91
+ * ```
92
+ */
93
+ export interface StarPart {
94
+ part: "temperature" | "colour" | "size" | "edge" | "surface" | "spots" | "rotation" | "shape" | "poles" | "prominences" | "glow";
95
+ status: StarStatus;
96
+ note: {
97
+ en: string;
98
+ ja: string;
99
+ };
100
+ }
101
+ /**
102
+ * A star ready to draw: its numbers with the defaults filled in, its colour, the shaded look and the facts the line drawing uses, how fast it turns on a page, and which parts of the picture are known and which invented.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * import { starLook } from "@johnmorrisdotca/wakusei-planets";
107
+ *
108
+ * const star = starLook({ name: "Sirius A", temperatureK: 9940, radiusSun: 1.71, luminosityClass: "V", rotationDays: 5.5 });
109
+ * console.log(star.colour, star.disclaimer.en);
110
+ * ```
111
+ */
112
+ export interface StarLook {
113
+ /** The numbers it was made from, as they were given. */
114
+ numbers: StarNumbers;
115
+ name: string;
116
+ temperatureK: number;
117
+ radiusSun: number;
118
+ radiusKm: number;
119
+ /** Which drawing this is: `full` or `low` (see `StarLookOptions`). */
120
+ quality: "full" | "low";
121
+ luminosityClass: LuminosityClass;
122
+ /** `undefined` when the numbers gave none. */
123
+ rotationDays: number | undefined;
124
+ activity: number;
125
+ oblateness: number;
126
+ corona: number;
127
+ /** The black-body colour of the temperature, `#rrggbb`. */
128
+ colour: string;
129
+ /** The colour the line drawing and a page's accents take: the bright cells of the shaded look, a little stronger than the plain black body so a star reads as coloured, `#rrggbb`. */
130
+ tone: string;
131
+ /** The shaded look: its `surface` is shader code with the numbers written into it. Its `id` is `sun`, the one star among the bodies. Draw it through the element's `star` attribute; it is not registered under a body. */
132
+ look: BodyLook;
133
+ /** The facts the line drawing uses: the Sun's, with this star's name, size, shape and the outlines of its cells and spots. */
134
+ facts: BodyFacts;
135
+ /** How it turns on a page: degrees a second (negative for backwards), and how many times faster than the star really turns that is (`undefined` when its rotation is not given). */
136
+ turn: {
137
+ degreesPerSecond: number;
138
+ speedUp: number | undefined;
139
+ };
140
+ /** Which parts of the picture are measured, estimated, derived or illustrative. */
141
+ parts: readonly StarPart[];
142
+ /** The sentence for a page to show with the picture. */
143
+ disclaimer: {
144
+ en: string;
145
+ ja: string;
146
+ };
147
+ /** The same numbers give the same key: the renderer keeps one drawing for each. */
148
+ key: string;
149
+ }
150
+ /**
151
+ * The Sun as numbers: the first example of a star, and the size the others are drawn beside.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * import { STAR_SUN, starLook } from "@johnmorrisdotca/wakusei-planets";
156
+ *
157
+ * console.log(STAR_SUN.temperatureK, starLook(STAR_SUN).turn.degreesPerSecond);
158
+ * ```
159
+ */
160
+ export declare const STAR_SUN: StarNumbers;
161
+ /**
162
+ * How much to spend drawing a star: `full` boils its granulation and draws prominences and flares on the edge of an active star; `low` is a still surface and a soft glow, for weak devices.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * import { starLook, type StarLookOptions } from "@johnmorrisdotca/wakusei-planets";
167
+ *
168
+ * const options: StarLookOptions = { quality: "low" };
169
+ * console.log(starLook({ temperatureK: 3042, radiusSun: 0.154 }, options).quality);
170
+ * ```
171
+ */
172
+ export interface StarLookOptions {
173
+ quality?: "full" | "low";
174
+ }
175
+ /**
176
+ * Everything the package draws a star with, from the numbers alone: the same numbers always give the same star. Throws a `RangeError` that names the number when one is out of range.
177
+ *
178
+ * The colour is the black body of `temperatureK`. The surface is grained by the luminosity class (and faint on hot stars, smooth on a white dwarf), spotted by `activity` (none on hot stars by default, many on
179
+ * cool dwarfs), darker toward the edge by the temperature, flattened by `oblateness` with hotter poles, and ringed with a soft corona. The cells and the spots are invented; `parts` says which parts are not.
180
+ *
181
+ * @param numbers - The star's numbers.
182
+ * @param options - `quality: "low"` for a cheaper drawing for weak devices (no boiling granulation, no prominences or flares); the default is `full`.
183
+ * @returns The star ready to draw.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * import { starLook } from "@johnmorrisdotca/wakusei-planets";
188
+ *
189
+ * const rigel = starLook({ name: "Rigel", temperatureK: 12100, radiusSun: 78.9, luminosityClass: "Ia", rotationDays: 25 });
190
+ * console.log(rigel.colour, rigel.activity, rigel.parts.filter((part) => part.status === "illustrative").length);
191
+ * ```
192
+ */
193
+ export declare function starLook(numbers: StarNumbers, options?: StarLookOptions): StarLook;