https://github.com/wraith13/phi-colors
phi-colors is a library that generates phi ratio colors for JavaScript/TypeScript.
https://github.com/wraith13/phi-colors
Last synced: about 2 months ago
JSON representation
phi-colors is a library that generates phi ratio colors for JavaScript/TypeScript.
- Host: GitHub
- URL: https://github.com/wraith13/phi-colors
- Owner: wraith13
- License: bsl-1.0
- Created: 2019-02-13T02:57:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-10T02:08:07.000Z (over 4 years ago)
- Last Synced: 2025-02-12T13:43:08.010Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE_1_0.txt
Awesome Lists containing this project
README
# phi-colors
phi-colors is a library that generates phi ratio colors that like [this](https://wraith13.github.io/phi-ratio-coloring/phi-ratio-coloring.htm) for JavaScript/TypeScript.
## How to use
```javascript
const phiColors = require('phi-colors').phiColors;
console.log(phiColors.phi); // 1.618033988749895
const rgba = phiColors.rgbaFromStyle("#FFCC8844"); // {"r":1,"g":0.8,"b":0.5333333333333333,"a":0.26666666666666666}
const hsla = phiColors.rgbaToHsla(rgba); // {"h":0.6058911188392467,"s":0.27034500134658757,"l":0.7777777777777778,"a":0.26666666666666666}
const newColors = [];
for(let i = 0; i < 7; ++i)
{
const generatedHsla = phiColors.generate
(
hsla, // base color
i, // hue arrange index
0.0, // saturation arrange index
0.0, // lightness arrange index
0.0 // alpha arrange index
);
const generatedRgba = phiColors.hslaToRgba(generatedHsla);
const generatedStyle = phiColors.rgbaForStyle(generatedRgba);
newColors.push(generatedStyle);
}
console.log(JSON.stringify(newColors)); // ["#FFCC8844","#EAE1FF44","#97FE9644","#FFC7D944","#B5E0FF44","#D6E57644",
```
## How to build
requires: [Node.js](https://nodejs.org/), [TypeScript Compiler](https://www.npmjs.com/package/typescript)
`tsc -P .` or `tsc -P . -w`
### In VS Code
You can use automatic build. Run `Tasks: Allow Automatic Tasks in Folder` command from command palette ( Mac: F1 or Shift+Command+P, Windows and Linux: F1 or Shift+Ctrl+P), and restart VS Code.
## License
[Boost Software License](./LICENSE_1_0.txt)