本文へ移動

Hoshi Stars星

肉眼で見える星の名前・色・距離、88星座の線と境界、メシエ天体、そしてそれらを描くための7種類の図法を使えます。

「星」(ほし) は、夜空に光って見えるものです。 名前について(英語)

目次

リファレンス · /chart

ChartSvgOptions型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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

インポート

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

定義

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;
}

メンバー

名前型説明
widthnumber

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

heightnumber
projection (省略可)"stereographic" | "orthographic" | "gnomonic" | "equidistant" | "equirectangular" | "mollweide" | "hammer" | undefined

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

ra (省略可)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 (省略可)number | undefined
zoom (省略可)number | undefined

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

magnitude (省略可)number | undefined

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

layers (省略可)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 (省略可)Language | undefined

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

culture (省略可)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 (省略可)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 (省略可)string | undefined

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

markers (省略可)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 (省略可)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 (省略可)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 (省略可)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 (省略可)boolean | undefined

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

label (省略可)string | undefined

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

measure (省略可)((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.

例

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/hoshi-stars 0.47.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。