/
start.html
104 lines (84 loc) · 2.62 KB
/
start.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Quick Tip: How to Manipulate Colors in JavaScript using Chroma.js</title>
<meta name="description" content="">
<meta name="author" content="Adi Purdila">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, sans-serif;
}
.container {
width: 85%;
margin: 2rem auto;
}
label {
display: block;
}
.color-scheme,
.color-scale {
margin: 3rem auto;
padding: 0;
list-style: none;
overflow: hidden;
}
.color-scheme li {
width: 10rem;
height: 10rem;
float: left;
position: relative;
}
.color-scale li {
width: 5rem;
height: 5rem;
float: left;
position: relative;
-webkit-transition: opacity 0.3s ease-in-out;
-moz-transition: opacity 0.3s ease-in-out;
transition: opacity 0.3s ease-in-out;
cursor: pointer;
}
.color-scale li:hover {
opacity: 0.8;
}
.color-info {
position: absolute;
padding: .5rem;
background-color: #FFF;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 5px;
font-size: 85%;
text-align: center;
}
.color-info span {
display: block;
}
</style>
</head>
<body>
<div class="container">
<label for="user-color">Select your color:</label>
<input type="color" id="user-color" value="#0161b2" />
<button id="generate-color-scheme">Generate color scheme</button>
<ol class="color-scheme"></ol>
<hr>
<label for="scale-color-1">Select color 1:</label>
<input type="color" id="scale-color-1" value="#ffffff" />
<label for="scale-color-2">Select color 2:</label>
<input type="color" id="scale-color-2" value="#000000" />
<label for="scale-count">Enter the number of colors:</label>
<input type="number" id="scale-count" value="10" />
<button id="generate-color-scale">Generate color scale</button>
<ol class="color-scale"></ol>
</div>
<!-- JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.3/chroma.min.js"></script>
<script>
</script>
</body>
</html>