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 · /chart

ChartSvgOptionstype

What to draw. Only width and height are needed; everything else starts where the demo starts.

Import it

import type { ChartSvgOptions } from "@johnmorrisdotca/hoshi-stars/chart";

Definition

interface ChartSvgOptions {
    width: number;
    height: number;
    projection?: Projection | undefined;
    ra?: number | undefined;
    dec?: number | undefined;
    zoom?: number | undefined;
    magnitude?: number | undefined;
    layers?: readonly ChartLayer[] | undefined;
    lang?: Language | undefined;
    culture?: Culture | undefined;
    constellation?: string | undefined;
    picked?: string | undefined;
    markers?: readonly SkyMarker[] | undefined;
    timeRange?: MarkerRange | undefined;
    tracks?: boolean | readonly string[] | undefined;
    bodies?: readonly SkyBody[] | undefined;
    showUncertainty?: boolean | undefined;
    label?: string | undefined;
    measure?: ((text: string, font: string) => number) | undefined;
}

Members

NameTypeDescription
widthnumber

The size in CSS pixels; the SVG's viewBox is this size and it scales with its box.

heightnumber
projection (optional)"stereographic" | "orthographic" | "gnomonic" | "equidistant" | "equirectangular" | "mollweide" | "hammer" | undefined

The projection: stereographic (the default), orthographic, gnomonic, equidistant, equirectangular, mollweide or hammer.

ra (optional)number | undefined

The point in the middle, in degrees: right ascension 0 to 360 and declination -90 to 90 (Orion's, 84 and 0, by default).

dec (optional)number | undefined
zoom (optional)number | undefined

How far in: 1 is the projection's own fit; left out, the zoom the projection opens at for this size.

magnitude (optional)number | undefined

The faintest star at that zoom (5); zooming in shows fainter ones, as a telescope does.

layers (optional)readonly ("names" | "milky" | "lines" | "boundaries" | "deep" | "holes" | "ecliptic" | "grid")[] | undefined

What to draw over the stars (DEFAULT_CHART_LAYERS when left out); an empty list draws the stars alone.

lang (optional)Language | undefined

The language of the names: en (the default) or ja.

culture (optional)Culture | undefined

The sky culture whose figures and names are drawn: the Western sky when left out. Pass japanese or chinese from @johnmorrisdotca/hoshi-stars/cultures/….

constellation (optional)string | undefined

A figure to show brighter, with its boundary when it is a constellation: a constellation's abbreviation (Ori), or a figure's id in the Japanese and Chinese skies.

picked (optional)string | undefined

The star (its HR number, 2491 for Sirius) or Messier object (M42) to mark as picked.

markers (optional)readonly SkyMarker[] | undefined

Your own points, each with a place and, if you like, a date, a name, a colour, a size and a group (SkyMarker). They are drawn over the stars and their names are placed clear of the stars and of each other.

timeRange (optional)MarkerRange | undefined

Show only the markers dated inside it ({ from, to, fade? }, ISO texts, milliseconds or Dates); a marker with no date is always shown. Every marker when left out.

tracks (optional)boolean | readonly string[] | undefined

Join a group of markers with a line in date order: true for every group, or the groups' names (["Comet"]). No lines when left out.

bodies (optional)readonly SkyBody[] | undefined

Planets, the Moon and other bodies you have worked out (SkyBody: id, names in English and Japanese, ra, dec in degrees, magnitude, phase as a lit fraction, and if you like brightLimb and size). Each is drawn by its magnitude over the stars, the Moon (id moon) as a disc with its phase, with its name in the chart's language. This package computes no positions and imports no package that does: your page works them out and passes the list.

showUncertainty (optional)boolean | undefined

Draw the stars of grade C (a rough or missing distance, /accuracy) dimmer. Off when left out.

label (optional)string | undefined

The SVG's accessible name: "Star chart" (星図 in Japanese) when left out.

measure (optional)((text: string, font: string) => number) | undefined

The width of a text in pixels for a CSS font ("400 11px system-ui, sans-serif"), which the names are laid out by. Left out: a canvas where there is a document, else a built-in table, so a browser and a server can place a name a little differently. Pass your own (a font's metrics, or a fixed width a character) for the same SVG everywhere.

Examples

import { chartSvg, type ChartSvgOptions } from "@johnmorrisdotca/hoshi-stars/chart";

const options: ChartSvgOptions = { width: 480, height: 320, projection: "orthographic", ra: 10.7, dec: 41.3, zoom: 6, lang: "ja" };
console.log(chartSvg(options).includes('aria-label="星図"'));
// true
true

What it prints (run when this page was built)

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