Skip to content

Commit 3aae9b0

Browse files
vincentmvdmk-vyn
authored andcommitted
Add documentation (#8)
Looks good! Thanks!
1 parent 22a009d commit 3aae9b0

File tree

1 file changed

+108
-1
lines changed

1 file changed

+108
-1
lines changed

README.md

+108-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,109 @@
11
# coloralgorithm
2-
Javacript function to produce color sets
2+
3+
A JavaScript function for producing color sets. Used to build Lyft's color system (Spectrum) and power [ColorBox](https://www.colorbox.io/).
4+
5+
## Background
6+
7+
- [Re-Approaching Color by Lyft Design](https://design.lyft.com/re-approaching-color-9e604ba22c88)
8+
- [Designing a Comprehensive Color System by Linda Dong](https://www.rethinkhq.com/videos/designing-a-comprehensive-color-system-for-lyft)
9+
10+
## Usage
11+
12+
The function takes in a JavaScript object with a `specs` key that describes the properties of the desired color palette:
13+
14+
```javascript
15+
import generate from "./src/generate";
16+
17+
const input = {
18+
specs: {
19+
// Number of colors
20+
steps: 11,
21+
// Hue Start Value (0 - 359)
22+
hue_start: 315,
23+
// Hue End Value (0 - 359)
24+
hue_end: 293,
25+
// Hue Curve (See Curves Section)
26+
hue_curve: "easeInQuad",
27+
// Saturation Start Value (0 - 100)
28+
sat_start: 4,
29+
// Saturation End Value (0 - 100)
30+
sat_end: 90,
31+
// Saturation Curve (See Curves Section)
32+
sat_curve: "easeOutQuad",
33+
// Saturation Rate (0 - 200)
34+
sat_rate: 130,
35+
// Luminosity Start Value (0 - 100)
36+
lum_start: 100,
37+
// Luminosity End Value (0 - 100)
38+
lum_end: 53,
39+
// Luminosity Curve (See Curves Section)
40+
lum_curve: "easeOutQuad",
41+
// Modifier Scale
42+
// Every generated color gets a modifier (label) that
43+
// indicates its lightness. A value of 10 results in
44+
// two-digit modifiers. The lightest color will be 0 (e.g. Red 0)
45+
// and the darkest color will be 100 (e.g. Red 100), given
46+
// that you generate 11 colors
47+
modifier: 10
48+
}
49+
};
50+
51+
const palette = generate(input);
52+
```
53+
54+
Contrary to ColorBox, this version of the algorithm _does not_ support a lock color.
55+
56+
## Example Output
57+
58+
The function returns the generated palette as an array of color objects:
59+
60+
```javascript
61+
[
62+
{
63+
contrastBlack: "19.32",
64+
contrastWhite: "1.09",
65+
displayColor: "black",
66+
hex: "#fff2fc",
67+
hsl: [315, 1, 0.974],
68+
hsv: [314.99999999999994, 0.052000000000000074, 1],
69+
hue: 314.99999999999994,
70+
hueRange: [315, 293],
71+
label: 0,
72+
lum: 1,
73+
rgb: [255, 242, 252],
74+
sat: 0.052000000000000074,
75+
steps: 11
76+
},
77+
...
78+
];
79+
```
80+
81+
## Curves
82+
83+
Hue, Saturation, and Luminosity all allow you to specify a curve. The following curves are supported:
84+
85+
- _easeInQuad_ (Quad - EaseIn)
86+
- _easeOutQuad_ (Quad - EaseOut)
87+
- _easeInOutQuad_ (Quad - EaseInOut)
88+
- _easeInQuart_ (Quart - EaseIn)
89+
- _easeOutQuart_ (Quart - EaseOut)
90+
- _easeInOutQuart_ (Quart - EaseInOut)
91+
- _easeInSine_ (Sine - EaseIn)
92+
- _easeOutSine_ (Sine - EaseOut)
93+
- _easeInOutSine_ (Sine - EaseInOut)
94+
- _easeInCubic_ (Cubic - EaseIn)
95+
- _easeOutCubic_ (Cubic - EaseOut)
96+
- _easeInOutCubic_ (Cubic - EaseInOut)
97+
- _easeInExpo_ (Expo - EaseIn)
98+
- _easeOutExpo_ (Expo - EaseOut)
99+
- _easeInOutExpo_ (Expo - EaseInOut)
100+
- _easeInQuint_ (Quint - EaseIn)
101+
- _easeOutQuint_ (Quint - EaseOut)
102+
- _easeInOutQuint_ (Quint - EaseInOut)
103+
- _easeInCirc_ (Circ - EaseIn)
104+
- _easeOutCirc_ (Circ - EaseOut)
105+
- _easeInOutCirc_ (Circ - EaseInOut)
106+
- _easeInBack_ (Back - EaseIn)
107+
- _easeOutBack_ (Back - EaseOut)
108+
- _easeInOutBack_ (Back - EaseInOut)
109+
- _linear_ (linear)

0 commit comments

Comments
 (0)