星曜
はじめに
星曜は紫微斗数の重要な構成要素であり、組み合わせによって異なる性格を表します。背景を学びたい方は星曜の体系をご覧ください。この章は開発での扱い方を説明します。
ヒント
iztroでは、主星、補助星、雑曜を星曜の体系にまとめ、48 神煞は別に扱います。48 神煞については48神煞をご覧ください。
クラスと分析メソッド
FunctionalAstrolabeやFunctionalPalaceと同様に、FunctionalStarを自分で生成するより、他のオブジェクトが返すインスタンスを使ってください。
FunctionalStar ^1.2.0
implements
IFunctionalStar extends Starインターフェースの定義
tsinterface IFunctionalStar extends Star { toJSON: () => Star; palace: () => IFunctionalPalace | undefined; setPalace: (p: IFunctionalPalace) => void; setAstrolabe: (a: IFunctionalAstrolabe) => void; surroundedPalaces: () => IFunctionalSurpalaces | undefined; oppositePalace: () => IFunctionalPalace | undefined; withBrightness: (brightness: Brightness | Brightness[]) => boolean; withMutagen: (mutagen: Mutagen | Mutagen[]) => boolean; }プロパティ
参照 Star
メソッド
toJSON() ^2.6.0
目的
機能付き星曜を通常のJSONオブジェクトに変換します。分析メソッド、関連する宮や命盤などの実行時参照は含めず、循環参照も安全に除外します。
定義
tstype toJSON = () => Star;パラメータ
なし
戻り値
使用例
tsconst data = astrolabe.star("紫微").toJSON();
❗️注意
FunctionalStarには、星を所属する宮と命盤に結び付けるsetPalace()とsetAstrolabe()があります。通常の利用では、データの誤りを避けるために直接呼び出さないでください。palace()
目的
星曜がある宮を取得します。
定義
tstype palace = () => IFunctionalPalace | undefined;パラメータ
none戻り値
FunctionalPalace|undefined使用例
紫微がある宮を取得します。tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palace = astrolabe.star("紫微").palace();
surroundedPalaces()
目的
現在の星曜の三方四正に当たる宮を取得します。
定義
tstype surroundedPalaces = () => IFunctionalSurpalaces | undefined;パラメータ
none戻り値
FunctionalSurpalaces|undefined使用例
紫微がある宮の三方四正に当たる宮を取得します。tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palaces = astrolabe.star("紫微").surroundedPalaces();
oppositePalace()
目的
現在の星曜がある宮の対宮を取得します。
定義
tstype oppositePalace = () => IFunctionalPalace | undefined;パラメータ
none戻り値
FunctionalPalace|undefined使用例
紫微がある宮の対宮を取得します。tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palace = astrolabe.star("紫微").oppositePalace();
withBrightness()
目的
星曜が指定した輝度かどうかを判定します。複数の輝度を渡した場合は、そのうち一つでも一致すれば
trueを返します。定義
tstype withBrightness = (brightness: Brightness | Brightness[]) => boolean;パラメータ
パラメータ 型 必須 デフォルト値 説明 brightness Brightness|Brightness[]true- 判定する星曜の輝度 戻り値
boolean使用例
紫微が廟または旺の状態であるかどうかを確認します。tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const result = astrolabe.star("紫微").withBrightness(["庙", "旺"]);
withMutagen()
目的
星曜に指定した四化があるかを判定します。複数を渡した場合は、そのうち一つでも一致すれば
trueを返します。定義
tstype withMutagen = (mutagen: Mutagen | Mutagen[]) => boolean;パラメータ
パラメータ 型 必須 デフォルト値 説明 mutagen Mutagen|Mutagen[]true- 四化(祿・權・科・忌) 戻り値
boolean使用例
紫微が權または科の状態であるかどうかを確認します。tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const result = astrolabe.star("紫微").withMutagen(["权", "科"]);