Reference · A star drawn from its numbers as SVG, and next to the Sun
starComparisonfunction
The star beside the Sun at one scale, as SVG text. A star smaller than about a hundred Suns is drawn as a disc next to the Sun's disc. A bigger one fills the picture, with the Sun a dot at its centre and the orbits of Earth (and Mars and Jupiter where they fit) drawn over it, so a supergiant's size can be read against the solar system. The picture says how many times the Sun's radius the star is.
Import it
import { starComparison } from "@johnmorrisdotca/hoshi-stars/portrait";
Definition
function starComparison(profile: StarProfile, options?: PortraitOptions): string | undefined
Parameters
| Name | Type | Description |
|---|---|---|
profile | StarProfile | A star's profile from |
options (optional) | PortraitOptions | Size, language, name and background. |
Returns
string | undefined
An SVG document as a string, or undefined where the profile has no radius or no temperature.
Examples
import { starByName } from "@johnmorrisdotca/hoshi-stars";
import { starProfile } from "@johnmorrisdotca/hoshi-stars/profile";
import { starComparison } from "@johnmorrisdotca/hoshi-stars/portrait";
const svg = starComparison(starProfile(starByName("Aldebaran")!), { name: "Aldebaran" });
console.log(svg?.includes("Earth's orbit"));falseWhat it prints (run when this page was built)