import type { CityFrame } from "../cities/geometry.ts"; import { SEA_FEATURES } from "./features.ts"; export { SEA_FEATURES }; /** * One named place: an ocean, a sea, a gulf, a bay or a continent, with the point its name is set at. * * @example * ```ts * import type { SeaFeature } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const pacific: SeaFeature = { id: "pacific-ocean", kind: "ocean", lon: -145.5, lat: -8, name: { en: "Pacific Ocean", ja: "太平洋" } }; * console.log(pacific.name.en); * ``` */ export interface SeaFeature { id: string; kind: "ocean" | "continent" | "sea" | "gulf" | "bay"; lon: number; lat: number; name: { en: string; ja: string; }; } /** * A name placed for one draw: its id, the text, and the box it takes. * * @example * ```ts * import type { SeaName } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const say = (one: SeaName): string => one.text; * console.log(typeof say); * ``` */ export interface SeaName { id: string; kind: SeaFeature["kind"]; text: string; left: number; top: number; width: number; height: number; size: number; } /** * The Earth's radius, in CSS pixels, at which seas, gulfs and bays join the oceans and continents. * Below this the view is the wide Earth: only oceans and continents are named. * * @example * ```ts * import { SEA_RADIUS } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(SEA_RADIUS > 200); * ``` */ export declare const SEA_RADIUS = 280; /** Space between the letters of a water name, as a share of the text size. Continents use a little less. */ export declare const SEA_LETTER_SPACING = 0.22; export declare const LAND_LETTER_SPACING = 0.06; /** * The names a view of this size may show: oceans and continents while the Earth is small, and seas, gulfs and bays once it is at least {@link SEA_RADIUS} pixels in radius. * * @param radius - The Earth's radius on the screen, in CSS pixels. * @returns The features, oceans and continents first. * * @example * ```ts * import { seaNamesFor } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(seaNamesFor(120).some((one) => one.id === "pacific-ocean")); * console.log(seaNamesFor(120).some((one) => one.id === "sea-of-japan")); * console.log(seaNamesFor(400).some((one) => one.id === "mediterranean-sea")); * ``` */ export declare function seaNamesFor(radius: number): readonly SeaFeature[]; /** * Reads the `sea-names` attribute. Absent or `off` is off. A bare attribute, or any other value, is on. * * @param value - The attribute's value, or null when it is absent. * @returns Whether the names are on. * * @example * ```ts * import { readSeaNames } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(readSeaNames(null), readSeaNames(""), readSeaNames("off")); * ``` */ export declare function readSeaNames(value: string | null): boolean; /** The attributes the elements watch for these names. */ export declare const SEA_NAMES_ATTRIBUTES: readonly ["sea-names"]; /** * Lays the names out for one draw. A name on the far side, or off the Earth's disc, is left out. A box in `taken` (a city name, a place, a country) keeps its space: the name moves aside, and if the only room is taken it is left out, so a city that was placed first wins. * * @param radius - The Earth's radius on the screen. It chooses oceans and continents, or those plus the seas. * @param frame - Where the Earth is, and how to project a place. `project` returns how squarely the place faces the viewer. * @param lang - `en` or `ja`. * @param taken - Boxes already used. A name is not put over one. * @returns The names to show. * * @example * ```ts * import { layoutSeaNames } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const frame = { width: 400, height: 400, radius: 160, project: (lon: number, lat: number, out: { x: number; y: number }) => { out.x = 200 + lon; out.y = 200 - lat; return 1; } }; * console.log(layoutSeaNames(160, frame, "en", []).some((one) => one.id === "africa")); * ``` */ export declare function layoutSeaNames(radius: number, frame: CityFrame & { disc?: { x: number; y: number; radius: number; }; }, lang: "en" | "ja", taken: readonly { left: number; top: number; width: number; height: number; }[]): SeaName[];