Skip to content

Commit 1599825

Browse files
author
LashaKakabadze
committed
updated README
1 parent a17e221 commit 1599825

File tree

1 file changed

+69
-8
lines changed

1 file changed

+69
-8
lines changed

README.md

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<img align="right" src="https://mymodernmet.com/wp/wp-content/uploads/2018/09/color-theory-basics.jpg" width="300"/>
2+
13
## javascript-color-gradient
24

35
![MIT License](https://img.shields.io/npm/l/javascript-color-gradient)
@@ -9,16 +11,26 @@ Lightweight JavaScript library, used to generate an array of color gradients by
911

1012
## Demo
1113

12-
https://codesandbox.io/s/javascript-color-gradient-csgfd
14+
See [Live Preview on CodeSandbox](https://codesandbox.io/s/javascript-color-gradient-csgfd).
15+
16+
**Note:** All the examples are using ES6, be sure is supported in your browser or modify as needed, Chrome recommended.
1317

1418
## Installation
1519

1620
```bash
1721
npm install javascript-color-gradient
1822
```
1923

24+
or
25+
26+
```bash
27+
yarn add javascript-color-gradient
28+
```
29+
2030
## Usage
2131

32+
Using two color gradients
33+
2234
```javascript
2335
import Gradient from "javascript-color-gradient";
2436

@@ -30,26 +42,68 @@ const color2 = "#8BC2E3";
3042
colorGradient.setGradient(color1, color2);
3143
```
3244

45+
Or more:
46+
47+
```javascript
48+
import Gradient from "javascript-color-gradient";
49+
50+
const colorGradient = new Gradient();
51+
52+
const color1 = "#3F2CAF";
53+
const color2 = "#e9446a";
54+
const color3 = "#edc988";
55+
const color4 = "#607D8B";
56+
57+
colorGradient.setMidpoint(20);
58+
59+
colorGradient.setGradient(color1, color2, color3, color4);
60+
```
61+
3362
## Methods
3463

35-
##### setGradient(color1, color2) - sets two or more hex color values. Should always be defined.
64+
To set two or more hex color values. Should always be defined.
3665

37-
##### setMidpoint(n) - sets the number range to n. By default n is 10.
66+
```javascript
67+
setGradient(color1, color2);
68+
```
69+
70+
To set the number range to n. By default n is 10.
71+
72+
```javascript
73+
setMidpoint(n);
74+
```
75+
76+
To return an array of hex colors. Requires no parameters.
77+
78+
```javascript
79+
getArray();
80+
```
3881

39-
##### getArray() - returns an array of hex colors. Requires no parameters.
82+
To return certain hex color corresponding to the number.
4083

41-
##### getColor(n) - returns certain hex color, where n is a requested number of midpoint colors.
84+
```javascript
85+
getColor(n);
86+
```
87+
88+
Let's see them in action:
4289

4390
```javascript
44-
console.log(colorGradient.getArray()); // outputs ["#4e4ab9", "#5d68c4", "#6d86ce", "#7ca4d9", "#8bc2e3"]
45-
console.log(colorGradient.getColor(3)); // outputs #6d86ce
91+
console.log(colorGradient.getArray());
92+
// outputs ["#4e4ab9", "#5d68c4", "#6d86ce", "#7ca4d9", "#8bc2e3"]
93+
94+
console.log(colorGradient.getColor(3));
95+
// outputs #6d86ce
4696
```
4797

4898
## Example
4999

50100
Implementing javascript-color-gradient library into React.js application, using two gradient colors and 10 midpoints.
51101

52-
![image](https://user-images.githubusercontent.com/48876996/87862417-e1c44080-c960-11ea-817c-b025d8d236ea.PNG)
102+
![1](https://user-images.githubusercontent.com/48876996/98634350-9c2ae980-233c-11eb-91f5-8c97b2194191.png)
103+
104+
The following example is using four gradient colors and 20 midpoints.
105+
106+
![1](https://user-images.githubusercontent.com/48876996/98633966-e8c1f500-233b-11eb-8b86-26a39c12b7d0.png)
53107

54108
## Contributing
55109

@@ -60,3 +114,10 @@ Please make sure to update tests as appropriate.
60114
## License
61115

62116
javascript-color-gradient is [MIT licensed.](https://github.com/Adrinlol/javascript-color-gradient/blob/master/LICENSE)
117+
118+
## Contributors
119+
120+
Special thanks to all the contributors who have contributed for this project.
121+
122+
[![](https://avatars2.githubusercontent.com/u/48876996?s=60&u=56a4865489e47ec29133e8792094ae83d8a9952c&v=4)](https://github.com/adrinlol)
123+
[![](https://avatars2.githubusercontent.com/u/29488727?s=60&u=a25b4053dc78f359299c3b700cb13ff2554b92d7&v=4)](https://github.com/Saspect-IO)

0 commit comments

Comments
 (0)