placeLabel関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Put a name on one side of a star: right, left, above (centred over it) or below (centred under it), with the star's catalogue letter under the name when designation is true. Writes into out and answers whether the whole block, and its line, are inside the view.
createStarNames tries the four sides in order and takes the first that covers no other name and no star.
インポート
import { placeLabel } from "@johnmorrisdotca/hoshi-stars/sky-labels";
定義
function placeLabel(x: number, y: number, width: number, style: LabelStyle, view: SkyView, out: StarNameLabel, designation?: boolean, side?: LabelSide): boolean
引数
| 名前 | 型 | 説明 |
|---|---|---|
x | number | The star's x on the screen. |
y | number | The star's y on the screen. |
width | number | The widest line's width in pixels ( |
style | LabelStyle | A complete look. |
view | SkyView | The part of the screen names may use. |
out | StarNameLabel | Where the answer is written. |
designation (省略可) | boolean | True when a line for the catalogue letter goes under the name. |
side (省略可) | "below" | "right" | "left" | "above" | Which side; |
戻り値
boolean
true when it fits.
例
import { labelStyle, labelWidth, placeLabel, type StarNameLabel } from "@johnmorrisdotca/hoshi-stars/sky-labels";
const style = labelStyle({ leader: 14 });
const out = {} as StarNameLabel;
console.log(placeLabel(395, 100, labelWidth("Rigel", style), style, { width: 400, height: 300 }, out), placeLabel(395, 100, labelWidth("Rigel", style), style, { width: 400, height: 300 }, out, false, "left"), out.anchor);false true end出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。