@johnmorrisdotca/wakusei-planets 0.23.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.
- package/CHANGELOG.md +10 -0
- package/README.md +41 -14
- package/dist/blackbody.d.ts +2 -0
- package/dist/blackbody.js +10 -0
- package/dist/element.d.ts +12 -0
- package/dist/element.js +160 -23
- package/dist/embed.d.ts +5 -0
- package/dist/embed.js +32 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/kids/data.d.ts +109 -0
- package/dist/kids/data.js +164 -0
- package/dist/kids/index.d.ts +4 -0
- package/dist/kids/index.js +5 -0
- package/dist/kids/land.d.ts +3 -0
- package/dist/kids/land.js +29 -0
- package/dist/kids/picture.d.ts +39 -0
- package/dist/kids/picture.js +255 -0
- package/dist/kids/sheet.d.ts +60 -0
- package/dist/kids/sheet.js +79 -0
- package/dist/kids/svg.d.ts +46 -0
- package/dist/kids/svg.js +193 -0
- package/dist/line.d.ts +9 -1
- package/dist/line.js +3 -4
- package/dist/portrait/element.d.ts +9 -0
- package/dist/portrait/element.js +39 -5
- package/dist/scene/body.d.ts +8 -1
- package/dist/scene/body.js +33 -9
- package/dist/scene/glsl.d.ts +7 -2
- package/dist/scene/glsl.js +49 -3
- package/dist/scene/look.d.ts +43 -0
- package/dist/scene/look.js +39 -1
- package/dist/scene/store.d.ts +3 -0
- package/dist/scene/store.js +3 -1
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +6 -0
- package/dist/space/element.js +18 -0
- package/dist/star-line.d.ts +20 -0
- package/dist/star-line.js +59 -0
- package/dist/star.d.ts +193 -0
- package/dist/star.js +261 -0
- package/dist/stars.js +3 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -2
package/dist/embed.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BodyId, type Look } from "./facts.ts";
|
|
2
|
+
import type { StarNumbers } from "./star.ts";
|
|
2
3
|
/**
|
|
3
4
|
* The ways `embedCode` writes a body into a page.
|
|
4
5
|
*
|
|
@@ -35,6 +36,8 @@ export type EmbedKind = (typeof EMBED_KINDS)[number];
|
|
|
35
36
|
*/
|
|
36
37
|
export interface EmbedOptions {
|
|
37
38
|
body: BodyId;
|
|
39
|
+
/** A star drawn from numbers instead of the body (`body` is then ignored: give `sun`, the one star among the bodies): the `star` attribute and the numbers' attributes (`temperature-k`, `radius-sun` and the rest) are written, and no entry point besides the element is loaded. `time` and `moons` do not apply to it. */
|
|
40
|
+
star?: StarNumbers;
|
|
38
41
|
look?: Look;
|
|
39
42
|
/** The date and time as an ISO string, or `now`: the body as the Earth sees it then. Left out, a portrait. */
|
|
40
43
|
time?: string;
|
|
@@ -44,6 +47,8 @@ export interface EmbedOptions {
|
|
|
44
47
|
turn?: number;
|
|
45
48
|
/** Pixels across. */
|
|
46
49
|
size?: number;
|
|
50
|
+
/** How far in the embed page starts, as its `zoom` address key has it (1 is the whole body). Left out or 1, the page starts at Fit. Only the iframe way carries it: the element's own start is Fit. */
|
|
51
|
+
zoom?: number;
|
|
47
52
|
}
|
|
48
53
|
/**
|
|
49
54
|
* Where the embed code points: the package's version on jsDelivr, and the published demo, where `embed.html` is.
|
package/dist/embed.js
CHANGED
|
@@ -25,14 +25,33 @@ export function entryOf(id) {
|
|
|
25
25
|
return DWARF_IDS.includes(id) ? "dwarfs" : id;
|
|
26
26
|
return DWARF_IDS.includes(parent) ? "moons-dwarf" : `moons-${parent}`;
|
|
27
27
|
}
|
|
28
|
+
/** A star's numbers as the attributes that carry them, in the order they are written: the same names are the iframe's address keys. */
|
|
29
|
+
function starAttributes(star) {
|
|
30
|
+
const out = [["temperature-k", String(star.temperatureK)], ["radius-sun", String(star.radiusSun)]];
|
|
31
|
+
if (star.luminosityClass !== undefined)
|
|
32
|
+
out.push(["luminosity-class", star.luminosityClass]);
|
|
33
|
+
if (star.rotationDays !== undefined)
|
|
34
|
+
out.push(["rotation-days", String(star.rotationDays)]);
|
|
35
|
+
if (star.activity !== undefined)
|
|
36
|
+
out.push(["activity", String(star.activity)]);
|
|
37
|
+
if (star.oblateness !== undefined)
|
|
38
|
+
out.push(["oblateness", String(star.oblateness)]);
|
|
39
|
+
if (star.corona !== undefined)
|
|
40
|
+
out.push(["corona", String(star.corona)]);
|
|
41
|
+
if (star.estimated !== undefined && star.estimated.length > 0)
|
|
42
|
+
out.push(["estimated", star.estimated.join(",")]);
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
28
45
|
/** The attributes of the element for these choices, in the order they are written. */
|
|
29
46
|
function attributesOf(o) {
|
|
30
|
-
const out = [["body", o.body], ["look", o.look ?? "realistic"]];
|
|
47
|
+
const out = o.star !== undefined ? [["star", o.star.name ?? ""], ["look", o.look ?? "realistic"]] : [["body", o.body], ["look", o.look ?? "realistic"]];
|
|
31
48
|
if (o.size !== undefined && o.size !== 320)
|
|
32
49
|
out.push(["size", String(o.size)]);
|
|
33
|
-
if (o.
|
|
50
|
+
if (o.star !== undefined)
|
|
51
|
+
out.push(...starAttributes(o.star));
|
|
52
|
+
if (o.time !== undefined && o.star === undefined)
|
|
34
53
|
out.push(["time", o.time]);
|
|
35
|
-
if (o.moons === true && o.time !== undefined)
|
|
54
|
+
if (o.moons === true && o.time !== undefined && o.star === undefined)
|
|
36
55
|
out.push(["moons", ""]);
|
|
37
56
|
if (o.turn !== undefined && o.turn > 0)
|
|
38
57
|
out.push(["turn", String(o.turn)]);
|
|
@@ -61,20 +80,23 @@ export function embedCode(options, kind = "html", settings = {}) {
|
|
|
61
80
|
const cdn = settings.cdn ?? CDN;
|
|
62
81
|
const site = settings.site ?? SITE;
|
|
63
82
|
const size = options.size ?? 320;
|
|
64
|
-
const
|
|
65
|
-
|
|
83
|
+
const body = options.body;
|
|
84
|
+
const query = new URLSearchParams(options.star !== undefined ? { ...(options.star.name !== undefined ? { star: options.star.name } : { star: "" }), look: options.look ?? "realistic", ...Object.fromEntries(starAttributes(options.star)) } : { body, look: options.look ?? "realistic" });
|
|
85
|
+
if (options.time !== undefined && options.star === undefined)
|
|
66
86
|
query.set("time", options.time);
|
|
67
|
-
if (options.moons === true && options.time !== undefined)
|
|
87
|
+
if (options.moons === true && options.time !== undefined && options.star === undefined)
|
|
68
88
|
query.set("moons", "1");
|
|
69
89
|
if (options.turn !== undefined && options.turn > 0)
|
|
70
90
|
query.set("turn", String(options.turn));
|
|
91
|
+
if (options.zoom !== undefined && options.zoom !== 1 && Number.isFinite(options.zoom) && options.zoom > 0)
|
|
92
|
+
query.set("zoom", String(Math.round(options.zoom * 1000) / 1000));
|
|
71
93
|
return snippet(kind, {
|
|
72
94
|
tag: "wakusei-body",
|
|
73
95
|
element: "element",
|
|
74
|
-
entries: needsShading(options) ? [entryOf(
|
|
96
|
+
entries: needsShading(options) && options.star === undefined ? [entryOf(body)] : [],
|
|
75
97
|
attrs: attributesOf(options),
|
|
76
98
|
name: "planet",
|
|
77
|
-
iframe: { src: `${site}embed.html?${query.toString()}`, title: BODIES[
|
|
99
|
+
iframe: { src: `${site}embed.html?${query.toString()}`, title: options.star !== undefined ? (options.star.name ?? "Star") : BODIES[body].name.en, width: size, height: size },
|
|
78
100
|
}, cdn);
|
|
79
101
|
}
|
|
80
102
|
/**
|
|
@@ -119,6 +141,8 @@ export function portraitCode(options, kind = "html", settings = {}) {
|
|
|
119
141
|
* ```
|
|
120
142
|
*/
|
|
121
143
|
export function embedCredit(options) {
|
|
144
|
+
if (options.star !== undefined)
|
|
145
|
+
return "Wakusei Planets by John Morris (MIT). A star drawn from its numbers, not a photo: the colour from its temperature, the size from its radius; the surface cells, spots and glow are illustrative.";
|
|
122
146
|
const base = "Wakusei Planets by John Morris (MIT). Sizes, tilt and rotation: IAU and NASA fact sheets.";
|
|
123
147
|
const photos = options.look !== "line" && options.look !== "illustrated";
|
|
124
148
|
const painted = photos ? " Surface pictures: NASA, USGS and JPL imagery in the public domain (details in the package's NOTICE.md)." : "";
|
package/dist/index.d.ts
CHANGED
|
@@ -6,3 +6,5 @@ export { lineSvg, mix, type LineOptions } from "./line.ts";
|
|
|
6
6
|
export { ringStrip, type RingStrip } from "./scene/rings.ts";
|
|
7
7
|
export { embedCode, embedCredit, EMBED_KINDS, portraitCode, type EmbedKind, type EmbedOptions, type EmbedSettings, type PortraitEmbed } from "./embed.ts";
|
|
8
8
|
export { addBody, decodeScene, defaultPortrait, encodeScene, PRESETS as PORTRAIT_PRESETS, resolve as layoutPortrait, type Item as PortraitItem, type Placed as PlacedItem, type Portrait, type Preset as PortraitPreset, type Resolved as PortraitLayout } from "./portrait/model.ts";
|
|
9
|
+
export { LUMINOSITY_CLASSES, STAR_SUN, starLook, type LuminosityClass, type StarLook, type StarNumberName, type StarNumbers, type StarPart, type StarStatus } from "./star.ts";
|
|
10
|
+
export { starLineSvg } from "./star-line.ts";
|
package/dist/index.js
CHANGED
|
@@ -6,3 +6,5 @@ export { lineSvg, mix } from "./line.js";
|
|
|
6
6
|
export { ringStrip } from "./scene/rings.js";
|
|
7
7
|
export { embedCode, embedCredit, EMBED_KINDS, portraitCode } from "./embed.js";
|
|
8
8
|
export { addBody, decodeScene, defaultPortrait, encodeScene, PRESETS as PORTRAIT_PRESETS, resolve as layoutPortrait } from "./portrait/model.js";
|
|
9
|
+
export { LUMINOSITY_CLASSES, STAR_SUN, starLook } from "./star.js";
|
|
10
|
+
export { starLineSvg } from "./star-line.js";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type BodyId, type HostId } from "../facts.ts";
|
|
2
|
+
export type Lang = "en" | "ja";
|
|
3
|
+
/**
|
|
4
|
+
* The bodies that have a colouring sheet of their own: the Sun, the planets and Pluto, and the big moons.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { KIDS_BODIES } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
9
|
+
*
|
|
10
|
+
* console.log(KIDS_BODIES.length, KIDS_BODIES[0]);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const KIDS_BODIES: readonly ["sun", "mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", "moon", "io", "europa", "ganymede", "callisto", "titan", "triton", "charon"];
|
|
14
|
+
/**
|
|
15
|
+
* The name of a body that has a colouring sheet: `sun`, a planet, `pluto`, `moon`, `io`, `europa`, `ganymede`, `callisto`, `titan`, `triton` or `charon`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { KIDS_BODIES, type KidsBody } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
20
|
+
*
|
|
21
|
+
* const body: KidsBody = KIDS_BODIES[5];
|
|
22
|
+
* console.log(body);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export type KidsBody = (typeof KIDS_BODIES)[number];
|
|
26
|
+
/**
|
|
27
|
+
* Every sheet: a colouring page for each of `KIDS_BODIES`, then `lineup`, all the planets in a row at their true relative size.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { KIDS_SHEETS } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
32
|
+
*
|
|
33
|
+
* console.log(KIDS_SHEETS.at(-1));
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const KIDS_SHEETS: readonly ["sun", "mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", "moon", "io", "europa", "ganymede", "callisto", "titan", "triton", "charon", "lineup"];
|
|
37
|
+
/**
|
|
38
|
+
* The name of a sheet: a `KidsBody` or `lineup`.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { type KidsSheet } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
43
|
+
*
|
|
44
|
+
* const sheet: KidsSheet = "lineup";
|
|
45
|
+
* console.log(sheet);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export type KidsSheet = (typeof KIDS_SHEETS)[number];
|
|
49
|
+
/** A body's name for a child: in Japanese the reading in hiragana, then the kanji in brackets. */
|
|
50
|
+
export declare function kidsName(id: BodyId, lang: Lang): string;
|
|
51
|
+
/** The name alone, as a child says it. */
|
|
52
|
+
export declare const kidsSay: (id: BodyId, lang: Lang) => string;
|
|
53
|
+
/** A colour to colour with: the real colour as `#rrggbb` and its name. */
|
|
54
|
+
export interface Swatch {
|
|
55
|
+
hex: string;
|
|
56
|
+
en: string;
|
|
57
|
+
ja: string;
|
|
58
|
+
}
|
|
59
|
+
/** The real colours of each body, a few words each. The first is the colour the package draws the body in. */
|
|
60
|
+
export declare const SWATCHES: Readonly<Record<KidsBody, readonly Swatch[]>>;
|
|
61
|
+
/** A body's width across the middle, in kilometres, to three figures. */
|
|
62
|
+
export declare const widthKm: (id: BodyId) => number;
|
|
63
|
+
/** How many Earths wide a body is. */
|
|
64
|
+
export declare const earthsWide: (id: BodyId) => number;
|
|
65
|
+
/** How long a planet takes to go once round the Sun, in days, from the size of its orbit (Kepler's third law). */
|
|
66
|
+
export declare const yearDays: (id: HostId) => number;
|
|
67
|
+
/** How long a moon takes to go once round its planet, in days, from its mean motion. */
|
|
68
|
+
export declare const moonPeriodDays: (id: BodyId) => number;
|
|
69
|
+
/**
|
|
70
|
+
* The three facts on a body's sheet, in plain words, worked out from the package's numbers: its width and how it compares with Earth, how long it takes to spin and to go round, and for a moon the face it shows.
|
|
71
|
+
* @param id - A body with a sheet.
|
|
72
|
+
* @param lang - `en` or `ja`.
|
|
73
|
+
* @returns Three short sentences.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { kidsFacts } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
78
|
+
*
|
|
79
|
+
* console.log(kidsFacts("jupiter", "en"));
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function kidsFacts(id: KidsBody, lang?: Lang): string[];
|
|
83
|
+
/** The planets of the lineup sheet, nearest the Sun first. */
|
|
84
|
+
export declare const LINEUP_IDS: readonly ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune"];
|
|
85
|
+
/** The words on the sheets that are not a body's own. */
|
|
86
|
+
export declare const SAY: {
|
|
87
|
+
readonly en: {
|
|
88
|
+
readonly colour: "Colour me!";
|
|
89
|
+
readonly brand: "Space Program X";
|
|
90
|
+
readonly pack: "Wakusei Planets";
|
|
91
|
+
readonly credits: "Sizes and spins: IAU and NASA. Drawn from numbers, not copied.";
|
|
92
|
+
readonly lineup: "All the planets";
|
|
93
|
+
readonly lineupLine: "The planets in a row, drawn to the same scale.";
|
|
94
|
+
readonly rings: "Rings";
|
|
95
|
+
readonly info: "Colouring sheet";
|
|
96
|
+
};
|
|
97
|
+
readonly ja: {
|
|
98
|
+
readonly colour: "ぬってね!";
|
|
99
|
+
readonly brand: "Space Program X";
|
|
100
|
+
readonly pack: "Wakusei Planets 惑星";
|
|
101
|
+
readonly credits: "おおきさや まわりかた: IAU と NASA。すうじから かいた え です。";
|
|
102
|
+
readonly lineup: "わくせいの ならびかた";
|
|
103
|
+
readonly lineupLine: "おなじ ものさしで ならべた わくせい。";
|
|
104
|
+
readonly rings: "リング";
|
|
105
|
+
readonly info: "ぬりえ";
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/** The three facts of the lineup sheet: the biggest, the smallest and the Sun, at this sheet's scale (`mmPerKm`). */
|
|
109
|
+
export declare function lineupFacts(lang: Lang, mmPerKm: number): string[];
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// What the kids' colouring sheets say: the names (with the Japanese readings), the colours to colour with and the three facts, all worked out from the package's own numbers.
|
|
2
|
+
import { BODIES, PLANET_IDS } from "../facts.js";
|
|
3
|
+
import { meanSunAu } from "../ephemeris.js";
|
|
4
|
+
import { ORBITS } from "../data/orbits.js";
|
|
5
|
+
/**
|
|
6
|
+
* The bodies that have a colouring sheet of their own: the Sun, the planets and Pluto, and the big moons.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { KIDS_BODIES } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
11
|
+
*
|
|
12
|
+
* console.log(KIDS_BODIES.length, KIDS_BODIES[0]);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export const KIDS_BODIES = ["sun", ...PLANET_IDS, "moon", "io", "europa", "ganymede", "callisto", "titan", "triton", "charon"];
|
|
16
|
+
/**
|
|
17
|
+
* Every sheet: a colouring page for each of `KIDS_BODIES`, then `lineup`, all the planets in a row at their true relative size.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { KIDS_SHEETS } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
22
|
+
*
|
|
23
|
+
* console.log(KIDS_SHEETS.at(-1));
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export const KIDS_SHEETS = [...KIDS_BODIES, "lineup"];
|
|
27
|
+
const READING = {
|
|
28
|
+
sun: "たいよう", mercury: "すいせい", venus: "きんせい", earth: "ちきゅう", mars: "かせい", jupiter: "もくせい", saturn: "どせい", uranus: "てんのうせい", neptune: "かいおうせい", pluto: "めいおうせい", moon: "つき",
|
|
29
|
+
};
|
|
30
|
+
/** A body's name for a child: in Japanese the reading in hiragana, then the kanji in brackets. */
|
|
31
|
+
export function kidsName(id, lang) {
|
|
32
|
+
const name = BODIES[id].name;
|
|
33
|
+
if (lang === "en")
|
|
34
|
+
return name.en;
|
|
35
|
+
const reading = READING[id];
|
|
36
|
+
return reading === undefined ? name.ja : `${reading}(${name.ja})`;
|
|
37
|
+
}
|
|
38
|
+
/** The name alone, as a child says it. */
|
|
39
|
+
export const kidsSay = (id, lang) => (lang === "ja" ? (READING[id] ?? BODIES[id].name.ja) : BODIES[id].name.en);
|
|
40
|
+
const s = (hex, en, ja) => ({ hex, en, ja });
|
|
41
|
+
/** The real colours of each body, a few words each. The first is the colour the package draws the body in. */
|
|
42
|
+
export const SWATCHES = {
|
|
43
|
+
sun: [s("#ffcf4d", "Yellow", "きいろ"), s("#f28c28", "Orange", "オレンジ"), s("#5b3a29", "Dark brown", "こいちゃいろ")],
|
|
44
|
+
mercury: [s("#a39b92", "Grey", "はいいろ"), s("#6f6a65", "Dark grey", "こいはいいろ"), s("#cfc7bb", "Light grey", "うすいはい")],
|
|
45
|
+
venus: [s("#e8cf94", "Cream", "クリーム"), s("#e0b45a", "Gold", "きんいろ"), s("#c98a4b", "Orange", "オレンジ")],
|
|
46
|
+
earth: [s("#3b78c4", "Blue", "あお"), s("#4f9a52", "Green", "みどり"), s("#9b7b4f", "Brown", "ちゃいろ"), s("#ffffff", "White", "しろ")],
|
|
47
|
+
mars: [s("#c76a3f", "Rust", "さびいろ"), s("#7a4a35", "Brown", "ちゃいろ"), s("#d9a77a", "Sand", "すないろ"), s("#ffffff", "White", "しろ")],
|
|
48
|
+
jupiter: [s("#e8d9bd", "Cream", "クリーム"), s("#c78b55", "Orange", "オレンジ"), s("#b9503a", "Red", "あか"), s("#ffffff", "White", "しろ")],
|
|
49
|
+
saturn: [s("#e4d09c", "Gold", "きんいろ"), s("#efe3c2", "Cream", "クリーム"), s("#b39b73", "Brown", "ちゃいろ")],
|
|
50
|
+
uranus: [s("#a9e0e5", "Light blue", "みずいろ"), s("#6fc2cb", "Teal", "あおみどり"), s("#7d868c", "Grey", "はいいろ")],
|
|
51
|
+
neptune: [s("#4a6ee0", "Blue", "あお"), s("#2f46a8", "Dark blue", "こいあお"), s("#ffffff", "White", "しろ")],
|
|
52
|
+
pluto: [s("#c9a98a", "Tan", "うすちゃいろ"), s("#8c6a50", "Brown", "ちゃいろ"), s("#ecdcc8", "Cream", "クリーム")],
|
|
53
|
+
moon: [s("#b8b5ae", "Grey", "はいいろ"), s("#7c7a76", "Dark grey", "こいはいいろ"), s("#eeeeea", "White", "しろ")],
|
|
54
|
+
io: [s("#e5d26a", "Yellow", "きいろ"), s("#d98b3a", "Orange", "オレンジ"), s("#3a3530", "Black", "くろ")],
|
|
55
|
+
europa: [s("#dcd2c0", "Cream", "クリーム"), s("#a0664a", "Brown", "ちゃいろ"), s("#ffffff", "White", "しろ")],
|
|
56
|
+
ganymede: [s("#a09484", "Tan", "うすちゃいろ"), s("#6f6458", "Dark brown", "こいちゃいろ"), s("#d7cdbd", "Light", "うすいいろ")],
|
|
57
|
+
callisto: [s("#70675d", "Dark brown", "こいちゃいろ"), s("#a89c8c", "Tan", "うすちゃいろ"), s("#ffffff", "White", "しろ")],
|
|
58
|
+
titan: [s("#dba84a", "Orange", "オレンジ"), s("#a8743a", "Brown", "ちゃいろ"), s("#f0d58a", "Yellow", "きいろ")],
|
|
59
|
+
triton: [s("#cdbbac", "Cream", "クリーム"), s("#d9a9a0", "Pink", "ピンク"), s("#8d9aa6", "Blue-grey", "あおぐろ")],
|
|
60
|
+
charon: [s("#9c9189", "Grey", "はいいろ"), s("#8b4a3a", "Red-brown", "あかちゃ"), s("#d8d2cc", "Light grey", "うすいはい")],
|
|
61
|
+
};
|
|
62
|
+
/** Round to three significant figures. */
|
|
63
|
+
const three = (n) => {
|
|
64
|
+
const digits = Math.floor(Math.log10(Math.abs(n))) + 1;
|
|
65
|
+
const step = 10 ** (digits - 3);
|
|
66
|
+
return Math.round(n / step) * step;
|
|
67
|
+
};
|
|
68
|
+
const group = (n) => Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
69
|
+
const one = (n) => (Math.round(n * 10) / 10).toString();
|
|
70
|
+
/** 1 decimal below 100 (the "0" is dropped), whole above. */
|
|
71
|
+
const short = (n) => (n < 100 ? one(n) : group(n));
|
|
72
|
+
const times = (n) => (n >= 10 ? Math.round(n).toString() : one(n));
|
|
73
|
+
const EARTH_KM = BODIES.earth.radiusKm;
|
|
74
|
+
/** A body's width across the middle, in kilometres, to three figures. */
|
|
75
|
+
export const widthKm = (id) => three(BODIES[id].radiusKm * 2);
|
|
76
|
+
/** How many Earths wide a body is. */
|
|
77
|
+
export const earthsWide = (id) => BODIES[id].radiusKm / EARTH_KM;
|
|
78
|
+
const sizeFact = (id, lang) => {
|
|
79
|
+
const w = group(widthKm(id));
|
|
80
|
+
const ratio = earthsWide(id);
|
|
81
|
+
if (id === "earth")
|
|
82
|
+
return lang === "ja" ? `よこはば ${w}km。わたしたちの おうち!` : `${w} km across. Our home!`;
|
|
83
|
+
if (ratio > 0.9 && ratio < 1.1)
|
|
84
|
+
return lang === "ja" ? `よこはば ${w}km。ちきゅうと ほとんど おなじ おおきさ。` : `${w} km across, almost as wide as Earth.`;
|
|
85
|
+
if (ratio >= 1.1)
|
|
86
|
+
return lang === "ja" ? `よこはば ${w}km。ちきゅうの ${times(ratio)}ばい。` : `${w} km across: ${times(ratio)} times as wide as Earth.`;
|
|
87
|
+
return lang === "ja" ? `よこはば ${w}km。ちきゅうの ほうが ${times(1 / ratio)}ばい おおきい。` : `${w} km across. Earth is ${times(1 / ratio)} times wider.`;
|
|
88
|
+
};
|
|
89
|
+
const daysOrHours = (hours, lang) => {
|
|
90
|
+
if (hours < 48)
|
|
91
|
+
return lang === "ja" ? `${one(hours)}じかん` : `${one(hours)} hours`;
|
|
92
|
+
return lang === "ja" ? `${short(hours / 24)}にち` : `${short(hours / 24)} days`;
|
|
93
|
+
};
|
|
94
|
+
const spinFact = (id, lang) => {
|
|
95
|
+
const hours = Math.abs(BODIES[id].rotationHours);
|
|
96
|
+
const time = daysOrHours(hours, lang);
|
|
97
|
+
const back = BODIES[id].rotationHours < 0;
|
|
98
|
+
if (lang === "ja")
|
|
99
|
+
return `${back ? "ぎゃくむきに " : ""}${time}で 1かい まわる。`;
|
|
100
|
+
return back ? `It spins backwards, once in ${time}.` : `It spins once in ${time}.`;
|
|
101
|
+
};
|
|
102
|
+
/** How long a planet takes to go once round the Sun, in days, from the size of its orbit (Kepler's third law). */
|
|
103
|
+
export const yearDays = (id) => meanSunAu(id) ** 1.5 * 365.25;
|
|
104
|
+
const yearFact = (id, lang) => {
|
|
105
|
+
const days = yearDays(id);
|
|
106
|
+
const years = days / 365.25;
|
|
107
|
+
const time = years < 1.2 ? (lang === "ja" ? `${Math.round(days)}にち` : `${Math.round(days)} days`) : lang === "ja" ? `${times(years)}ねん` : `${times(years)} years`;
|
|
108
|
+
return lang === "ja" ? `たいように 1しゅうするのに ${time}。` : `It goes around the Sun in ${time}.`;
|
|
109
|
+
};
|
|
110
|
+
/** How long a moon takes to go once round its planet, in days, from its mean motion. */
|
|
111
|
+
export const moonPeriodDays = (id) => 360 / Math.abs(ORBITS[id].sid);
|
|
112
|
+
const hostOf = (id) => BODIES[id].parent;
|
|
113
|
+
const hostName = (id, lang) => kidsSay(hostOf(id), lang);
|
|
114
|
+
const orbitFact = (id, lang) => {
|
|
115
|
+
const days = short(moonPeriodDays(id));
|
|
116
|
+
const back = BODIES[id].rotationHours < 0;
|
|
117
|
+
if (lang === "ja")
|
|
118
|
+
return `${hostName(id, lang)}を ${back ? "ぎゃくむきに " : ""}1しゅうするのに ${days}にち。`;
|
|
119
|
+
return `It goes around ${hostName(id, lang)} in ${days} days${back ? ", backwards!" : "."}`;
|
|
120
|
+
};
|
|
121
|
+
const faceFact = (id, lang) => (lang === "ja" ? `いつも おなじ めんを ${hostName(id, lang)}に むけている。` : `It always shows the same face to ${hostName(id, lang)}.`);
|
|
122
|
+
const sunFacts = (lang) => [
|
|
123
|
+
sizeFact("sun", lang),
|
|
124
|
+
lang === "ja" ? `${one(BODIES.sun.rotationHours / 24)}にちで 1かい まわる。` : `It spins once in ${one(BODIES.sun.rotationHours / 24)} days.`,
|
|
125
|
+
lang === "ja" ? "ちきゅうから やく 1おく5000まんkm。" : "It is about 150 million km from Earth.",
|
|
126
|
+
];
|
|
127
|
+
/**
|
|
128
|
+
* The three facts on a body's sheet, in plain words, worked out from the package's numbers: its width and how it compares with Earth, how long it takes to spin and to go round, and for a moon the face it shows.
|
|
129
|
+
* @param id - A body with a sheet.
|
|
130
|
+
* @param lang - `en` or `ja`.
|
|
131
|
+
* @returns Three short sentences.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { kidsFacts } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
136
|
+
*
|
|
137
|
+
* console.log(kidsFacts("jupiter", "en"));
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export function kidsFacts(id, lang = "en") {
|
|
141
|
+
if (id === "sun")
|
|
142
|
+
return sunFacts(lang);
|
|
143
|
+
if (BODIES[id].kind === "moon")
|
|
144
|
+
return [sizeFact(id, lang), orbitFact(id, lang), faceFact(id, lang)];
|
|
145
|
+
return [sizeFact(id, lang), spinFact(id, lang), yearFact(id, lang)];
|
|
146
|
+
}
|
|
147
|
+
/** The planets of the lineup sheet, nearest the Sun first. */
|
|
148
|
+
export const LINEUP_IDS = ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune"];
|
|
149
|
+
/** The words on the sheets that are not a body's own. */
|
|
150
|
+
export const SAY = {
|
|
151
|
+
en: { colour: "Colour me!", brand: "Space Program X", pack: "Wakusei Planets", credits: "Sizes and spins: IAU and NASA. Drawn from numbers, not copied.", lineup: "All the planets", lineupLine: "The planets in a row, drawn to the same scale.", rings: "Rings", info: "Colouring sheet" },
|
|
152
|
+
ja: { colour: "ぬってね!", brand: "Space Program X", pack: "Wakusei Planets 惑星", credits: "おおきさや まわりかた: IAU と NASA。すうじから かいた え です。", lineup: "わくせいの ならびかた", lineupLine: "おなじ ものさしで ならべた わくせい。", rings: "リング", info: "ぬりえ" },
|
|
153
|
+
};
|
|
154
|
+
/** The three facts of the lineup sheet: the biggest, the smallest and the Sun, at this sheet's scale (`mmPerKm`). */
|
|
155
|
+
export function lineupFacts(lang, mmPerKm) {
|
|
156
|
+
const radii = LINEUP_IDS.map((id) => [id, BODIES[id].radiusKm]);
|
|
157
|
+
const biggest = radii.reduce((a, b) => (b[1] > a[1] ? b : a))[0];
|
|
158
|
+
const smallest = radii.reduce((a, b) => (b[1] < a[1] ? b : a))[0];
|
|
159
|
+
const sun = Math.round((BODIES.sun.radiusKm * 2 * mmPerKm) / 10);
|
|
160
|
+
const x = times(earthsWide(biggest));
|
|
161
|
+
return lang === "ja"
|
|
162
|
+
? [`いちばん おおきい: ${kidsSay(biggest, lang)}。ちきゅうの ${x}ばい。`, `いちばん ちいさい: ${kidsSay(smallest, lang)}。`, `ここでは たいようは ${sun}cm にも なる!`]
|
|
163
|
+
: [`Biggest: ${kidsSay(biggest, lang)}, ${x} times as wide as Earth.`, `Smallest: ${kidsSay(smallest, lang)}.`, `The Sun would be ${sun} cm wide here!`];
|
|
164
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// The kids' colouring sheets: thick-line pictures of the Sun, the planets and the big moons, to print and colour, with the real colours to use and three facts, in English and Japanese.
|
|
2
|
+
export { KIDS_BODIES, KIDS_SHEETS, kidsFacts } from "./data.js";
|
|
3
|
+
export { colouringArt } from "./picture.js";
|
|
4
|
+
export { kidsRoom, kidsSvg } from "./svg.js";
|
|
5
|
+
export { kidsLayout, kidsSheet } from "./sheet.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BodyId, Feature } from "../facts.ts";
|
|
2
|
+
/** The shapes a sheet draws instead of a body's own features: the Earth's lands, Pluto's heart (a bright plain) with a few craters, Mars's dark regions and its polar cap, and Saturn's bands without the hexagon, none of them crossing another. */
|
|
3
|
+
export declare const OWN_FEATURES: Partial<Record<BodyId, readonly Feature[]>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The Earth's big lands as a few corner points each (longitude, latitude in degrees), rough on purpose: a child colours a continent, not a coastline.
|
|
2
|
+
const LAND = [
|
|
3
|
+
[[-165, 64], [-150, 70], [-125, 70], [-95, 70], [-82, 68], [-62, 58], [-55, 50], [-67, 45], [-76, 38], [-81, 30], [-80, 25], [-84, 30], [-90, 29], [-97, 26], [-97, 20], [-92, 18], [-87, 21], [-83, 15], [-78, 8], [-83, 8], [-92, 14], [-105, 20], [-110, 24], [-115, 30], [-118, 34], [-124, 40], [-124, 48], [-132, 54], [-140, 60], [-152, 59], [-165, 55]],
|
|
4
|
+
[[-72, 78], [-55, 83], [-25, 82], [-20, 72], [-40, 62], [-52, 66], [-58, 75]],
|
|
5
|
+
[[-78, 8], [-72, 12], [-62, 10], [-52, 5], [-50, 0], [-35, -6], [-39, -14], [-41, -22], [-48, -26], [-58, -35], [-63, -41], [-66, -47], [-69, -52], [-72, -52], [-74, -45], [-72, -30], [-70, -18], [-76, -14], [-81, -5], [-80, 0], [-77, 3]],
|
|
6
|
+
[[-17, 21], [-10, 30], [-6, 36], [10, 37], [22, 33], [32, 31], [34, 28], [43, 12], [51, 12], [44, -2], [40, -15], [35, -24], [32, -29], [20, -35], [18, -32], [12, -18], [13, -8], [9, 4], [-8, 4], [-15, 11], [-17, 15]],
|
|
7
|
+
[[-9, 37], [-9, 43], [-2, 44], [-4, 48], [5, 52], [8, 55], [10, 58], [5, 62], [15, 69], [28, 71], [45, 68], [60, 70], [80, 73], [105, 77], [130, 72], [160, 70], [180, 68], [170, 60], [160, 55], [160, 52], [142, 53], [140, 45], [135, 43], [128, 40], [129, 35], [121, 38], [122, 31], [120, 23], [108, 21], [106, 10], [100, 13], [104, 1], [98, 8], [98, 16], [92, 22], [80, 15], [77, 8], [73, 20], [67, 25], [57, 25], [56, 27], [50, 30], [43, 13], [35, 28], [34, 31], [27, 37], [26, 40], [20, 40], [14, 45], [18, 40], [15, 38], [8, 44], [3, 43], [-1, 37]],
|
|
8
|
+
[[114, -22], [122, -18], [130, -12], [137, -12], [142, -11], [146, -19], [153, -26], [150, -37], [141, -38], [130, -32], [115, -34]],
|
|
9
|
+
[[130.8, 33.8], [135, 34.5], [139.8, 35], [141, 38], [141.5, 41.5], [139.5, 40], [136, 36.5], [132.5, 35.5]],
|
|
10
|
+
];
|
|
11
|
+
/** The shapes a sheet draws instead of a body's own features: the Earth's lands, Pluto's heart (a bright plain) with a few craters, Mars's dark regions and its polar cap, and Saturn's bands without the hexagon, none of them crossing another. */
|
|
12
|
+
export const OWN_FEATURES = {
|
|
13
|
+
earth: LAND.map((points) => ({ kind: "line", points, close: true })),
|
|
14
|
+
pluto: [
|
|
15
|
+
{ kind: "line", points: [[190, -10], [178, 0], [170, 12], [172, 24], [182, 30], [190, 24], [198, 30], [208, 24], [210, 12], [202, 0]], close: true },
|
|
16
|
+
{ kind: "circle", lon: 145, lat: 25, radius: 8 },
|
|
17
|
+
{ kind: "circle", lon: 235, lat: -20, radius: 8 },
|
|
18
|
+
{ kind: "circle", lon: 160, lat: -40, radius: 8 },
|
|
19
|
+
],
|
|
20
|
+
mars: [
|
|
21
|
+
{ kind: "band", lat: 72 },
|
|
22
|
+
{ kind: "oval", lon: 70, lat: 8, rx: 14, ry: 10 },
|
|
23
|
+
{ kind: "oval", lon: 20, lat: -28, rx: 20, ry: 8 },
|
|
24
|
+
{ kind: "circle", lon: 75, lat: -45, radius: 9 },
|
|
25
|
+
{ kind: "oval", lon: 30, lat: 40, rx: 16, ry: 9 },
|
|
26
|
+
{ kind: "oval", lon: 115, lat: -8, rx: 12, ry: 9 },
|
|
27
|
+
],
|
|
28
|
+
saturn: [72, 58, 44, 28, 12, -6, -22, -40, -56].map((lat) => ({ kind: "band", lat })),
|
|
29
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type BodyId } from "../facts.ts";
|
|
2
|
+
import type { Pose } from "../ephemeris.ts";
|
|
3
|
+
/** The thickness of the outline of a body and of every line inside it, in millimetres. */
|
|
4
|
+
export declare const OUTLINE_MM = 3;
|
|
5
|
+
export declare const LINE_MM = 2.5;
|
|
6
|
+
export interface Art {
|
|
7
|
+
/** The SVG markup, to put inside an `<svg>` measured in millimetres. */
|
|
8
|
+
markup: string;
|
|
9
|
+
/** How far the picture reaches from its centre: half its width and half its height. */
|
|
10
|
+
halfWidth: number;
|
|
11
|
+
halfHeight: number;
|
|
12
|
+
}
|
|
13
|
+
/** The pose a sheet draws: the body's own tilt, looked at a little from above, full face. */
|
|
14
|
+
export declare function sheetPose(id: BodyId): Pose;
|
|
15
|
+
/** How far a body reaches from its centre, in units of its radius: its outline, its rings and, for the Sun, its rays. */
|
|
16
|
+
export declare function reach(id: BodyId, pose?: Pose): {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A body as a colouring picture: thick black outlines on white (the outline 3 mm, every line inside 2.5 mm), its big features, its rings, and the Sun's rays. The picture is drawn at its centre `(cx, cy)` with `r`
|
|
22
|
+
* millimetres for the body's radius. `outline` is the outline's thickness; the lines inside are 2.5 mm or, for a thinner outline, a little less.
|
|
23
|
+
* @param id - The body's name.
|
|
24
|
+
* @param cx - The centre's place, in millimetres.
|
|
25
|
+
* @param cy - The centre's place, in millimetres.
|
|
26
|
+
* @param r - The body's radius, in millimetres.
|
|
27
|
+
* @param outline - The outline's thickness in millimetres. Default 3.
|
|
28
|
+
* @returns The SVG markup of the body, to put inside an `<svg>` measured in millimetres.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { colouringArt } from "@johnmorrisdotca/wakusei-planets/sheets";
|
|
33
|
+
*
|
|
34
|
+
* console.log(colouringArt("mars", 50, 50, 40).startsWith("<g"));
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function colouringArt(id: BodyId, cx: number, cy: number, r: number, outline?: number): string;
|
|
38
|
+
/** A body's picture made as large as fits a box `width` by `height` millimetres, in the middle of it. */
|
|
39
|
+
export declare function colouringPicture(id: BodyId, width: number, height: number, top?: number): Art;
|