Skip to the content

Hoshi Stars星

The stars you can see without a telescope, with names, colours and distances; the 88 constellations with their lines and boundaries; the Messier objects; and seven map projections to draw them on.

Hoshi is the Japanese word 星 for a star. About the name

Contents

Reference · Names on the brightest stars and the constellation figures as faint lines, for a sky you draw yourself: a count or a magnitude, the figure under the pointer at full strength, a body that covers part of the sky, and a look set by settings alone

FigureLinestype

The figures of one sky. update lays the lines out for the screen as it is, point picks the figure under the pointer.

Import it

import type { FigureLines } from "@johnmorrisdotca/hoshi-stars/sky-labels";

Definition

interface FigureLines {
    readonly settings: Readonly<FigureLinesSettings & {
        strength: number;
    }>;
    readonly style: Readonly<LabelStyle>;
    readonly segments: Float32Array;
    readonly count: number;
    readonly figures: readonly FigureOnScreen[];
    readonly picked: FigureOnScreen | undefined;
    readonly name: FigureName | undefined;
    set(settings: FigureLinesSettings): void;
    opacityOf(figure: FigureOnScreen): number;
    update(project: SkyProjector, view: SkyView, avoid?: readonly Box[]): number;
    point(x?: number, y?: number): boolean;
    step(direction: 1 | -1): boolean;
}

Members

NameTypeDescription
settingsReadonly<FigureLinesSettings & { strength: number; }>

The settings in force, with the strength held to 0 up to 1.

styleReadonly<LabelStyle>

The look in force for the picked figure's name.

segmentsFloat32Array<ArrayBufferLike>

The line ends laid out by the last update, four numbers for each line: x and y of one end, x and y of the other. Reused, until set takes a new culture; read only up to 4 * count.

countnumber

How many lines the last update laid out.

figuresreadonly FigureOnScreen[]

The figures (the 88, in the order of the catalogue, or the culture's, in its order), each with the lines of segments that belong to it.

pickedFigureOnScreen | undefined

The figure the pointer is on, or undefined.

nameFigureName | undefined

The picked figure's name and where to draw it, or undefined when none is picked.

set(settings: FigureLinesSettings): void

Change the settings; the next update uses them. Every setting is replaced, so set({ strength }) alone goes back to the 88, in English, in the default look: keep the rest with lines.set({ ...lines.settings, strength }). A new culture makes the figures again: segments and figures are new objects after it.

opacityOf(figure: FigureOnScreen): number

The opacity to draw a figure's lines at: the picked figure's is 1, every other is the strength. 0 for all when the strength is 0.

update(project: SkyProjector, view: SkyView, avoid?: readonly Box[]): number

Lay the lines out for the screen as it is now. Call it when the view, the size or the settings changed. A picked figure that is no longer in view is let go.

point(x?: number, y?: number): boolean

Say where the pointer (or a finger) is, in the page's pixels, or call with nothing when it has left. The figure with a line or a star nearest the point, within reach pixels, is picked: on a star of the figure lights the whole figure, as on a line.

step(direction: 1 | -1): boolean

Pick the next figure in view, or the one before (for the keyboard): in the catalogue's order, round from the last to the first, skipping figures with no line in view. With none picked, 1 starts at the first and -1 at the last.

Examples

import type { FigureLines } from "@johnmorrisdotca/hoshi-stars/sky-labels";

const total = (lines: FigureLines): number => lines.figures.reduce((sum, f) => sum + f.end - f.start, 0);
console.log(typeof total);
function

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hoshi-stars 0.47.0.