📢 介绍
用于紫微斗数排盘的工具库,目前支持简体中文、繁体中文、英文、韩文、日文,大家有任何问题欢迎到这里提问交流,如果发现程序有不对的地方,欢迎到这里提交Bug。扣码不易,希望得到各位大佬的星星。🍻
🌰 举个栗子
🎲 用法
🚀 让我们开始把
npm i @sylarlong/astro -S
❓ 调用方法
-
ES6 Module
import { astro } from '@sylarlong/astro';
const astrolabe = astro.astrolabeBySolarDate('2000-8-16', 2, '女', true, 'zh-CN');
const astrolabe = astro.astrolabeByLunarDate('2000-7-17', 2, '女', false, true, 'zh-CN');
-
CommonJS
var astroObj = require('@sylarlong/astro');
var astrolabe = astroObj.astro.astrolabeBySolarDate('2000-8-16', 2, '女', true, 'zh-CN');
var astrolabe = astroObj.astro.astrolabeByLunarDate('2000-7-17', 2, '女', false, true, 'zh-CN');
✍️ 方法定义
-
astrolabeBySolarDate
type astrolabeBySolarDate = (
solarDateStr: string,
timeIndex: number,
gender: Gender,
fixLeap: boolean = true,
language: Language = 'zh-CN'
) => Astrolabe;
-
astrolabeByLunarDate
type astrolabeByLunarDate = (
lunarDateStr: string,
timeIndex: number,
gender: Gender,
isLeapMonth: boolean = false,
fixLeap: boolean = true,
language: Language = 'zh-CN'
) => Astrolabe;
📑 返回数据
{
solarDate: '2000-8-16',
lunarDate: '二〇〇〇年七月十七',
chineseDate: '庚辰 甲申 丙午 庚寅',
time: '寅时',
timeRange: '03:00~05:00',
sign: '狮子座',
zodiac: '龙',
earthlyBranchOfSoulPalace: '午',
earthlyBranchOfBodyPalace: '戌',
soul: '破军',
body: '文昌',
fiveElementsClass: '木三局',
palaces: [
{
name: '财帛',
isBodyPalace: false,
isOriginalPalace: false,
heavenlyStem: '戊',
earthlyBranch: '寅',
majorStars: [
{ name: '武曲', type: 'major', scope: 'origin', brightness: '得' },
{ name: '天相', type: 'major', scope: 'origin', brightness: '庙' },
{ name: '天马', type: 'tianma', scope: 'origin', brightness: '' },
],
minorStars: [],
adjectiveStars: [
{ name: '月解', type: 'helper', scope: 'origin' },
{ name: '三台', type: 'adjective', scope: 'origin' },
{ name: '天寿', type: 'adjective', scope: 'origin' },
{ name: '天巫', type: 'adjective', scope: 'origin' },
{ name: '天厨', type: 'adjective', scope: 'origin' },
{ name: '阴煞', type: 'adjective', scope: 'origin' },
{ name: '天哭', type: 'adjective', scope: 'origin' },
],
changsheng12: '绝',
boshi12: '蜚廉',
jiangqian12: '岁驿',
suiqian12: '吊客',
decadal: { range: [44, 53], heavenlyStem: '戊' },
ages: [9, 21, 33, 45, 57, 69, 81],
},
],
}
✍️ 返回数据定义
export type Star = {
name: string;
type: StarType;
scope: Scope;
brightness?: StarBrightness;
mutagen?: Mutagen;
};
export type Decadal = {
range: number[];
heavenlyStem: HeavenlyStem;
earthlyBranch: EarthlyBranch;
};
export type Palace = {
name: PalaceName;
isBodyPalace: boolean;
isOriginalPalace: boolean;
heavenlyStem: HeavenlyStem;
earthlyBranch: EarthlyBranch;
majorStars: Star[];
minorStars: Star[];
adjectiveStars: Star[];
changsheng12: string;
boshi12: string;
jiangqian12: string;
suiqian12: string;
decadal: Decadal;
ages: number[];
};
export type Astrolabe = {
solarDate: string;
lunarDate: string;
chineseDate: string;
time: BirthTime;
timeRange: TimeRange;
sign: string;
zodiac: string;
earthlyBranchOfSoulPalace: EarthlyBranch;
earthlyBranchOfBodyPalace: EarthlyBranch;
soul: string;
body: string;
fiveElementsClass: FiveElementsClassName;
palaces: Palace[];
};
✨ 获取流耀
❓ 调用方法
-
ES6 Module
import { star } from '@sylarlong/astro';
const horoscopeStars = star.getHoroscopeStar('庚', '辰', 'decadal');
-
CommonJS
var astroObj = require('@sylarlong/astro');
var horoscopeStars = astroObj.star.getHoroscopeStar('庚', '辰', 'decadal');
✍️ 方法定义
-
getHoroscopeStar
type getHoroscopeStar = (
heavenlyStem: HeavenlyStem,
earthlyBranch: EarthlyBranch,
scope: 'decadal' | 'yearly',
) => Star[][];
📑 返回数据
[
[{ name: '运马', type: 'tianma', scope: 'decadal' }],
[{ name: '运曲', type: 'soft', scope: 'decadal' }],
[],
[{ name: '运喜', type: 'flower', scope: 'decadal' }],
[],
[
{ name: '运钺', type: 'soft', scope: 'decadal' },
{ name: '运陀', type: 'tough', scope: 'decadal' },
],
[{ name: '运禄', type: 'lucun', scope: 'decadal' }],
[{ name: '运羊', type: 'tough', scope: 'decadal' }],
[],
[
{ name: '运昌', type: 'soft', scope: 'decadal' },
{ name: '运鸾', type: 'flower', scope: 'decadal' },
],
[],
[{ name: '运魁', type: 'soft', scope: 'decadal' }],
];
☕ 总结
如果您觉得本程序对您有用的话,可以给我带杯咖啡吗?👍 Paypal Me
以上数据可以生成如下星盘,其中palaces
数据用于填充12宫,其他数据用于填充中宫。
📜 版权(LICENSE)
MIT License
Copyright © 2023 Sylar Long
请合理使用本开源代码,禁止用于非法目的。