phi-colors
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

phi-colors

phi-colors is a library that generates phi ratio colors that like this for JavaScript/TypeScript.

How to use

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, TypeScript Compiler

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

Package Sidebar

Install

npm i phi-colors

Weekly Downloads

0

Version

1.0.1

License

BSL-1.0

Unpacked Size

36.1 kB

Total Files

9

Last publish

Collaborators

  • wraith13