GithubHelp home page GithubHelp logo

sylarlong / iztro Goto Github PK

View Code? Open in Web Editor NEW
1.6K 19.0 200.0 26.84 MB

⭐A lightweight open-source JavaScript library for obtaining The Purple Star Astrology (Zi Wei Dou Shu) astrolabe information.. 支持多语言轻量级获取紫微斗数排盘信息的javascript开源库。

Home Page: https://iztro.com

License: MIT License

TypeScript 99.43% JavaScript 0.57%
astrolabe astrology horoscope ziweidoushu chinese-astrology javascript npm typescript natal-chart

iztro's Introduction

banner2

一套轻量级紫微斗数排盘工具库。

Maintainability Codecov npm Codecov npm GitHub GitHub code size in bytes npm bundle size FOSSA Status Package Quality


简体中文 🔸 繁體中文 🔸 English


介绍

用于紫微斗数排盘的javascript开源库,有以下功能。

  • 输入

    • 生日(阳历或农历皆可)
    • 出生时间
    • 性别
  • 可以实现下列功能

    • 紫微斗数 12 宫的星盘数据
    • 获取生肖
    • 获取星座
    • 获取四柱(干支纪年法的生辰)
    • 获取运限(大限,小限,流年,流月,流日,流时)的数据
    • 获取流耀(大限和流年的动态星耀)
    • 判断指定宫位是否存在某些星耀
    • 判断指定宫位三方四正是否存在某些星耀
    • 判断指定宫位三方四正是否存在四化
    • 判断指定星耀是否存在四化
    • 判断指定星耀三方四正是否存在四化
    • 判断指定星耀是否是某个亮度
    • 根据天干获取四化
    • 获取指定星耀所在宫位
    • 获取指定宫位三方四正宫位
    • 获取指定星耀三方四正宫位
    • 获取指定星耀对宫
    • 获取指定运限宫位
    • 获取指定运限宫位的三方四正
    • 判断指定运限宫位内是否存在某些星耀
    • 判断指定运限宫位内是否存在四化
    • 判断指定运限三方四正内是否存在某些星耀
    • 判断指定运限三方四正内是否存在四化
    • 判断指定宫位是否是空宫
    • 判断宫位是否产生飞星到目标宫位
    • 获取宫位产生的四化宫位
  • 其他

    • 多语言输入/输出

      输入的时候支持多个国家和地区语言混合输入,可以输出指定语言。目前支持 简体中文,繁体中文,英文,日文,韩文,越南语。英文的翻译目前还没有标准,所以我大多是意译的,但也正因为如此,可能英文版本的会更加易懂。如果有精通星象翻译的欢迎提 PR 。任何语言都可以。

    • 链式调用

      假如你想判断 紫微星 的 三方四正 有没有 化忌,你可以这样做

      import { astro } from 'iztro';
      
      const astrolabe = astro.bySolar('2000-8-16', 2, '男', true, 'zh-CN');
      
      astrolabe.star('紫微').surroundedPalaces().haveMutagen('忌');
    • 配置和插件

      紫微斗数流派众多,不同的流派的四化以及星耀亮度都会有些许差异,为了满足不同流派的需求和功能的扩展,iztro在 v2.3.0 版本加入了全局配置和第三方插件功能。详见配置文档

Important

如果你在开发中遇到任何问题,可以添加作者微信咨询
你也可以任意魔改代码,或联系作者获取技术支持
WeChat

快捷跳转

安装依赖

你可以使用任何你熟悉的包管理库来安装iztro

  • NPM

    npm install iztro -S
    
  • Yarn

    yarn add iztro
    
  • pnpm

    pnpm install iztro -S
    

独立js库

假如你使用的是静态 html 文件,可以下载 release 资源文件中的 iztro-min-js.tar.gz 压缩包,里面包含了一个 iztro 压缩混淆过的js文件和对应的sourcemap文件。

v2.0.4+ 版本才提供独立js库。

iztro.min.js 用script标签引入html文件使用。

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>iztro-紫微斗数开源库</title>
  </head>
  <body>
    <script src="./iztro.min.js"></script>
    <script>
      // 获取一张星盘数据
      var astrolabe = iztro.astro.bySolar('2000-8-16', 2, '男', true, 'zh-CN');
    </script>
  </body>
</html>

当然,我们更推荐你直接使用 CDN 加速链接,你可以在下面列表中选择一个,在没有指定版本号的时候,会自动指向最新版本的代码库

你也可以使用如下规则来指定版本:

应为纯JS库没有代码提示和注释,所以在集成的时候请参阅 iztro开发文档

例子

这里是一个简单的例子显示如何调用iztro获取到紫微斗数星盘数据,详细文档请移步开发文档

  • ES6 Module

    import { astro } from 'iztro';
    
    // 通过阳历获取星盘信息
    const astrolabe = astro.bySolar('2000-8-16', 2, '女', true, 'zh-CN');
    
    // 通过农历获取星盘信息
    const astrolabe = astro.byLunar('2000-7-17', 2, '女', false, true, 'zh-CN');
  • CommonJS

    var iztro = require('iztro');
    
    // 通过阳历获取星盘信息
    var astrolabe = iztro.astro.bySolar('2000-8-16', 2, '女', true, 'zh-CN');
    
    // 通过农历获取星盘信息
    var astrolabe = iztro.astro.byLunar('2000-7-17', 2, '女', false, true, 'zh-CN');

如果你对iztro有兴趣,也想加入贡献队伍,我们非常欢迎,你可以用以下方式进行:

  • 如果你对程序功能有什么建议,请到这里创建一个功能需求
  • 如果你发现程序有BUG,请到这里创建一个BUG报告
  • 你也可以将本仓库fork到你自己的仓库进行编辑,然后提交PR到本仓库。
  • 假如你擅长外语,我们也欢迎你对国际化文件的翻译做出你的贡献,你可以fork本仓库,然后在locales文件夹下创建一个国际化语言文件,然后复制其他语言文件目录里面的文件到你的目录下进行更改。
  • 当然,如果你觉得本程序对你有用,请给我买杯咖啡☕️ Static Badge

Important

如果你觉得代码对你有用,请点⭐支持,你的⭐是我持续更新的动力

总结

使用本程序返回的数据,你可以生成这样一张星盘,当然这只是一个例子,你可以把注意力集中在星盘的设计上,也可以把重心放在数据的分析上,本程序为你解决了最繁冗的工作,让你可以把精力更多的放在你所需要关注的事情上面。

image

Star趋势

Star History Chart

MIT License

Copyright © 2023 All Contributors

Note

请合理使用本开源代码,禁止用于非法目的。

FOSSA Status

iztro's People

Contributors

dependabot[bot] avatar fossabot avatar sanchun333 avatar sylarlong avatar thiepwong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iztro's Issues

v2.2.1 : 来因宫错误

描述(Description)

来因宫应该以生年天干判断,程序内目前错误的以地支判断了。

版本(Version)

  • v2.2.1

[v2.0.6-] 小限顺序错误

描述(Description)

由于没有考虑到多语言的判断问题导致小限的排列错误。

版本(Version)

  • v2.0.6(含)以前版本

请问什么时候出手机版本?

摘要(Summary)

🇨🇳

🇺🇸


Ref. {referrence}

需求(Requirements)

🇨🇳

  • 需求一
  • 需求二
  • ...

🇺🇸

  • feature 1
  • feature 2
  • ...

开发插件相关功能

摘要(Summary)

新建插件功能,以支持更多、更灵活的配置以及方法。


需求(Requirements)

  • 全局配置插件
  • 全局配置数据(比如四化)

加入流时信息|Add timely scope information

摘要(Summary)

🇨🇳
在运限信息中加入流时信息。

🇺🇸
Add timely scope information to horoscope.


Ref. #1 (comment)

需求(Requirements)

🇨🇳

  • 包含流时所在宫位索引
  • 流时天干
  • 流时四化

🇺🇸

  • timely scope index should be included
  • heavenly stem of timely scope should be included
  • mutagen of timely scope should be included.

是否加入流时星耀,还需在今后大家的使用中来决定。

新增小限12宫

摘要(Summary)

⚠️ 对于小限来说,只有小限命宫有意义,但是有用户有展示小限12宫的需求,所以在此添加到age字段中以便有需求的用户取用。

返回对象里加入获取运限的方法|Add a function to get horoscope in the response object

摘要(Summary)

🇨🇳
现在返回的星盘对象和获取流耀的方法是分开的,这样在调用的时候不是很方便,所以需要在返回的对象里面加入一个方法来获取制定日期的运限信息以及流曜。

🇺🇸
The astrolabe object and get horoscope stars function are detached. It's not convenient. So it would be better to add a function to get horoscope of specific date.


需求(Requirements)

🇨🇳

  • 传入时间可选,当没传入时间的时候默认获取当前日期
  • 返回数据应该包含当前时间大限、流年、流月以及流日的索引
  • 返回虚岁以便通过虚岁定位小限宫位
  • 返回大限以及流年的流曜
  • 返回大限、流年、流月以及流日的四化

🇺🇸

  • Date can be optional. When no date is provided, it will default to the current date.
  • The returned data should include the indexes of the decadal scope, yearly scope, monthly scope, and daily scope.
  • Return nominal age to determine the age-related scope.
  • Return decadal and yearly scope stars.
  • Return mutagen of decadal yearly monthly and daily scope.

重构代码

摘要(Summary)

将以前 Star 转化为 FunctionalStar 的方法去掉,改为在初始化的时候就生成 FunctionalStar 实例。

需求(Requirements)

  • 删除 _toFunctionalStars() 方法
  • 重构代码
  • 修改UT

是否支持python调用?

首先感谢您的无私开源,这个仓库对我的帮助很大。
如题,请问目前该库是否支持python调用?
如果支持的话,请问应当如何调用呢?
如果不支持的话,是否在未来有添加python支持的可能性?
期待着您的回复,这对我非常重要,谢谢!

新增空宫判断

摘要(Summary)

FunctionalPalace 中新增一个方法,判断该宫位是否为空宫。

优化Horoscope|optimize Horoscope

摘要(Summary)

🇨🇳
目前Horoscope对象还有些不方便,需要新增name字段

🇺🇸
need to add a new field name


需求(Requirements)

🇨🇳

  • Horoscope 添加 name 字段
  • name 字段添加国际化翻译
  • 更新文档
  • 更新UT

🇺🇸

  • add name field to Horoscope
  • name should be localized
  • update docs
  • update UT

新增静态方法|add some static methods

摘要(Summary)

🇨🇳
新增一些静态方法

🇺🇸
add some static methods


Ref. {referrence}

需求(Requirements)

🇨🇳

  • 新增获取命宫主星方法
  • 新增获取生肖方法
  • 新增获取星座方法

🇺🇸

  • add a function to get major stars
  • add a function to get Chinese zodiac
  • add a function to get sign

宫位飞星判断

摘要(Summary)

🇨🇳
目前功能只有生年四化和流四化的判断,需要加入宫位飞星四化的判断。


需求(Requirements)

🇨🇳

  • 判断指定宫位是否飞化到目标宫位,四化传入数组,中一个即返回true
    • 目标宫位序号或名字,四化(数组)
    • 输出布尔值
  • 判断指定宫位是否没有飞化到目标宫位,四化传入数组,所有四化都没有中才返回true
    • 目标宫位序号或名字,四化(数组)
    • 输出布尔值
  • 判断指定宫位是否有自化
    • 传入四化(可选),如果不传入则会判断所有四化
    • 输出布尔值
  • 获取指定宫位飞化宫位数据
    • 目标宫位序号或名字
    • 输出禄权科忌所在宫位实例数组,数组下标对应 [禄,权,科,忌]

支持国际化输出|support localization

摘要(Summary)

🇨🇳
暂定支持 🇨🇳 简体中文🇭🇰 繁体中文🇺🇸 英文🇯🇵 日文🇰🇷 韩文 输出。

🇺🇸
Provisionally support 🇨🇳 Simplify Chinese, 🇭🇰 Traditional Chinese, 🇺🇸 English, 🇯🇵 Japanese and 🇰🇷 Korean.

三方四正宫位|surrounded palaces

摘要(Summary)

🇨🇳
获取三方四正宫位以及对三方四正宫位星耀的判断

🇺🇸
Get surrounded palaces. Stars analyzation.


需求(Requirements)

🇨🇳

  • 能够获取三方四正宫位
  • 判断指定星耀是否全部在三方四正内
  • 判断指定星耀是否至少有一颗在三方四正内
  • 判断指定星耀是否全不在三方四正内

🇺🇸

  • get surrounded palaces.
  • check whether all specific stars are in the surrounded palaces
  • check whether one of the specific stars are in the surrounded palaces
  • check whether all specific stars are not in the surrounded palaces

v2.0.7:排盘-天梁星在申宫亮度错误

描述(Description)

天梁星在申宫时,亮度应为陷,排出来的亮度是庙

版本(Version)

  • v2.0.7

环境(Environment)

网页

重现(Reproduce)

  • 调用的方法(funciton name)

链接

  • 参数(parameters)

  • 返回值(returns)

v2.2.0: 疑似小限数据错误

描述(Description)

据用户报告,在运限时间超过85岁以后,小限数据不再变化。

版本(Version)

  • v2.2.0

环境(Environment)

重现(Reproduce)

  • 调用的方法(funciton name)

    horoscope()

{2.2.2}:{decadal}-运钺和运魁可能设置反了

  1. 用生日制作一个astrolabe
  2. horoscope = astrolabe.horoscope()得到十年大运
  3. 在大运数据里,找到decadal = horoscope["decadal"]大运具体信息
  4. 再找到此大运相关的天魁天钺decadal["stars"]
  5. 此时会发现运魁运钺(或者叫大魁大钺)可能是反的

v2.0.4:horoscope-计算流日不准确

描述(Description)

版本(Version)

  • {version number}

环境(Environment)

重现(Reproduce)

  • 调用的方法(funciton name)

  • 参数(parameters)

  • 返回值(returns)

创建FunctionalHoroscope类|create FunctionalHoroscope class

摘要(Summary)

🇨🇳
需要加入FunctionalHoroscope类来进行运限的分析。

🇺🇸
in order to analyze horoscope, we need to add FunctionalHoroscope class.


Ref. {referrence}

需求(Requirements)

🇨🇳

  • FunctionalHoroscope 需要继承 Horoscope 的所有属性
  • FunctionalHoroscope 需要实现类似 FunctionalAstrolabe 的功能
    • 获取运限的宫位
    • 获取运限指定宫位的三方四正
    • 判断宫位星耀情况
    • 判断运限四化情况 为了不让一个PR过于复杂,将在下一个版本实现

🇺🇸

  • extends properties of Horoscope
  • implements functions like FunctionalAstrolabe
    • to get specific palace of a horoscope
    • to get surrounded palaces of a horoscope
    • to check stars of a horoscope
    • to check mutagens of a horoscope will be implemented in the next version to keep the PR simpler

ziwei.pub footer css 样式问题

描述(Description)

页面滚动到最下方后,部分内容被 footer 遮挡
image

footer 的 position: fixed; -> position: sticky; 应该可以解决

版本(Version)

环境(Environment)

重现(Reproduce)

判断星耀是否有四化|Check mutagen state for stars

摘要(Summary)

🇨🇳
紫微斗数的大部分主星和部分辅星会起四化(禄、权、科、忌),而限运和宫位也会起四化,此版本只实现本命四化

🇺🇸
Most major stars and some minor stars in Zi Wei Dou Shu have four mutagens which are addtional mutagen, forceful mutagen, easygoing mutagen and focused mutagen. Besides, horoscope and palaces have those mutagens as well. We only focus on original mutagens in this issue.


需求(Requirements)

🇨🇳

  • 判断指定星耀是否有四化
  • 判断指定宫位内是否有四化
  • 判断三方四正内是否有四化
  • 判断对宫是否有四化

🇺🇸

  • check mutagen status for specific start
  • check mutagen status for specific palace
  • check mutagen status for surrounded palaces
  • check mutagen status for opposite palace

农历月底晚子时不对

描述(Description)

农历月底的时候晚子时加一天以后没有考虑到月份也要加一的问题。

版本(Version)

  • 所有版本

重现(Reproduce)

  • 调用的方法(funciton name)

    • astrolabeByLunarDate()
  • 参数(parameters)

    • lunarDateStr: 1987-10-30
    • timeIndex: 12
    • gender: 女

星辰排布

摘要(Summary)

🇨🇳
看着很别扭,为什么不是竖着排,从右到左的顺序,这个排盘的布局还得自己实现吗,底层调上来的星辰得转换成竖着吗

流月索引错误 | monthly index is incorrect

描述(Description)

由于对流月索引计算方式的理解错误,导致原本正确的流月索引出现了错误。感谢网友 先不要慌 的指出。

Monthly horoscope index is incorrect because of my misunderstanding. Thanks to 先不要慌

版本(Version)

  • v1.2.3
  • v1.2.4
  • v1.2.5

v1.2.3 以前的版本不受影响
only affect v1.2.3 v1.2.4 and v1.2.5


#36 引发。(caused by #36 )

真太陽時間校正

摘要(Summary)

🇨🇳

因為經度產生時差的問題,會讓我們以為生日當時紀錄的時間是正確的。例如,在台北同一時間在重慶出生的人,雖然行政時間是一樣的,但是其實已經有很巨大的時差。真太陽時間就是在進行這個與中原標準時間的校正,這樣就可以進行全球東西半球正確的紫微斗數的排盤。

分离日期转换组件

摘要(Summary)

将农历阳历转换代码解耦

需求(Requirements)

  • 分离calendar文件夹下代码到 新的仓库
  • 覆盖当前calendar组件所有功能

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.