| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Color Test</title> |
| 5 |
<style> |
| 6 |
|
| 7 |
#color { |
| 8 |
position: fixed; |
| 9 |
top: 0; |
| 10 |
left: 250px; |
| 11 |
} |
| 12 |
</style> |
| 13 |
|
| 14 |
<script> |
| 15 |
|
| 16 |
var colors = [ |
| 17 |
'aliceblue', |
| 18 |
'antiquewhite', |
| 19 |
'aqua', |
| 20 |
'aquamarine', |
| 21 |
'azure', |
| 22 |
'beige', |
| 23 |
'bisque', |
| 24 |
'black', |
| 25 |
'blanchedalmond', |
| 26 |
'blue', |
| 27 |
'blueviolet', |
| 28 |
'brown', |
| 29 |
'burlywood', |
| 30 |
'cadetblue', |
| 31 |
'chartreuse', |
| 32 |
'chocolate', |
| 33 |
'coral', |
| 34 |
'cornflowerblue', |
| 35 |
'cornsilk', |
| 36 |
'crimson', |
| 37 |
'cyan', |
| 38 |
'darkblue', |
| 39 |
'darkcyan', |
| 40 |
'darkgoldenrod', |
| 41 |
'darkgray', |
| 42 |
'darkgreen', |
| 43 |
'darkgrey', |
| 44 |
'darkkhaki', |
| 45 |
'darkmagenta', |
| 46 |
'darkolivegreen', |
| 47 |
'darkorange', |
| 48 |
'darkorchid', |
| 49 |
'darkred', |
| 50 |
'darksalmon', |
| 51 |
'darkseagreen', |
| 52 |
'darkslateblue', |
| 53 |
'darkslategray', |
| 54 |
'darkslategrey', |
| 55 |
'darkturquoise', |
| 56 |
'darkviolet', |
| 57 |
'deeppink', |
| 58 |
'deepskyblue', |
| 59 |
'dimgray', |
| 60 |
'dimgrey', |
| 61 |
'dodgerblue', |
| 62 |
'firebrick', |
| 63 |
'floralwhite', |
| 64 |
'forestgreen', |
| 65 |
'fuchsia', |
| 66 |
'gainsboro', |
| 67 |
'ghostwhite', |
| 68 |
'gold', |
| 69 |
'goldenrod', |
| 70 |
'gray', |
| 71 |
'grey', |
| 72 |
'green', |
| 73 |
'greenyellow', |
| 74 |
'honeydew', |
| 75 |
'hotpink', |
| 76 |
'indianred', |
| 77 |
'indigo', |
| 78 |
'ivory', |
| 79 |
'khaki', |
| 80 |
'lavender', |
| 81 |
'lavenderblush', |
| 82 |
'lawngreen', |
| 83 |
'lemonchiffon', |
| 84 |
'lightblue', |
| 85 |
'lightcoral', |
| 86 |
'lightcyan', |
| 87 |
'lightgoldenrodyellow', |
| 88 |
'lightgreen', |
| 89 |
'lightgrey', |
| 90 |
'lightpink', |
| 91 |
'lightsalmon', |
| 92 |
'lightseagreen', |
| 93 |
'lightskyblue', |
| 94 |
'lightslategray', |
| 95 |
'lightslategrey', |
| 96 |
'lightsteelblue', |
| 97 |
'lightyellow', |
| 98 |
'lime', |
| 99 |
'limegreen', |
| 100 |
'linen', |
| 101 |
'magenta', |
| 102 |
'maroon', |
| 103 |
'mediumaquamarine', |
| 104 |
'mediumblue', |
| 105 |
'mediumorchid', |
| 106 |
'mediumpurple', |
| 107 |
'mediumseagreen', |
| 108 |
'mediumslateblue', |
| 109 |
'mediumspringgreen', |
| 110 |
'mediumturquoise', |
| 111 |
'mediumvioletred', |
| 112 |
'midnightblue', |
| 113 |
'mintcream', |
| 114 |
'mistyrose', |
| 115 |
'moccasin', |
| 116 |
'navajowhite', |
| 117 |
'navy', |
| 118 |
'oldlace', |
| 119 |
'olive', |
| 120 |
'olivedrab', |
| 121 |
'orange', |
| 122 |
'orangered', |
| 123 |
'orchid', |
| 124 |
'palegoldenrod', |
| 125 |
'palegreen', |
| 126 |
'paleturquoise', |
| 127 |
'palevioletred', |
| 128 |
'papayawhip', |
| 129 |
'peachpuff', |
| 130 |
'peru', |
| 131 |
'pink', |
| 132 |
'plum', |
| 133 |
'powderblue', |
| 134 |
'purple', |
| 135 |
'red', |
| 136 |
'rosybrown', |
| 137 |
'royalblue', |
| 138 |
'saddlebrown', |
| 139 |
'salmon', |
| 140 |
'sandybrown', |
| 141 |
'seagreen', |
| 142 |
'seashell', |
| 143 |
'sienna', |
| 144 |
'silver', |
| 145 |
'skyblue', |
| 146 |
'slateblue', |
| 147 |
'slategray', |
| 148 |
'slategrey', |
| 149 |
'snow', |
| 150 |
'springgreen', |
| 151 |
'steelblue', |
| 152 |
'tan', |
| 153 |
'teal', |
| 154 |
'thistle', |
| 155 |
'tomato', |
| 156 |
'turquoise', |
| 157 |
'violet', |
| 158 |
'wheat', |
| 159 |
'white', |
| 160 |
'whitesmoke', |
| 161 |
'yellow', |
| 162 |
'yellowgreen' |
| 163 |
]; |
| 164 |
|
| 165 |
function drawNamedColors() { |
| 166 |
var el = document.getElementById('named'); |
| 167 |
var ctx = el.getContext('2d'); |
| 168 |
|
| 169 |
for (var i = 0; i < colors.length; i++) { |
| 170 |
ctx.fillStyle = colors[i]; |
| 171 |
ctx.fillRect(0, i * 5, 100, 5); |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
function drawRgbColors() { |
| 176 |
var el = document.getElementById('rgb'); |
| 177 |
var ctx = el.getContext('2d'); |
| 178 |
|
| 179 |
for (var y = 0; y < 100; y += 5) { |
| 180 |
for (var x = 0; x < 100; x += 5) { |
| 181 |
ctx.fillStyle = 'rgb(0%, ' + x + '%, ' + y + '%)'; |
| 182 |
ctx.fillRect(x, y, 10, 10); |
| 183 |
} |
| 184 |
} |
| 185 |
|
| 186 |
ctx.translate(0, 100); |
| 187 |
|
| 188 |
for (var y = 0; y < 100; y += 5) { |
| 189 |
for (var x = 0; x < 100; x += 5) { |
| 190 |
ctx.fillStyle = 'rgb(' + x + '%, 0%, ' + y + '%)'; |
| 191 |
ctx.fillRect(x, y, 10, 10); |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
ctx.translate(0, 100); |
| 196 |
|
| 197 |
for (var y = 0; y < 100; y += 5) { |
| 198 |
for (var x = 0; x < 100; x += 5) { |
| 199 |
ctx.fillStyle = 'rgb(' + x + '%, ' + y + '%, 0%)'; |
| 200 |
ctx.fillRect(x, y, 10, 10); |
| 201 |
} |
| 202 |
} |
| 203 |
} |
| 204 |
|
| 205 |
function drawHslColors() { |
| 206 |
var el = document.getElementById('hsl'); |
| 207 |
var ctx = el.getContext('2d'); |
| 208 |
|
| 209 |
for (var y = 0; y < 100; y += 5) { |
| 210 |
for (var x = 0; x < 100; x += 5) { |
| 211 |
ctx.fillStyle = 'hsl(0, ' + x + '%, ' + y + '%)'; |
| 212 |
ctx.fillRect(0 + x, y, 10, 10); |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
ctx.translate(0, 100); |
| 217 |
|
| 218 |
for (var y = 0; y < 100; y += 5) { |
| 219 |
for (var x = 0; x < 360; x += 18) { |
| 220 |
ctx.fillStyle = 'hsl(' + x + ',50%, ' + y + '%)'; |
| 221 |
ctx.fillRect(x / 3.6, y, 10, 10); |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
ctx.translate(0, 100); |
| 226 |
|
| 227 |
for (var y = 0; y < 100; y += 5) { |
| 228 |
for (var x = 0; x < 360; x += 18) { |
| 229 |
ctx.fillStyle = 'hsl(' + x + ', ' + y + '%, 50%)'; |
| 230 |
ctx.fillRect(x / 3.6, y, 10, 10); |
| 231 |
} |
| 232 |
} |
| 233 |
|
| 234 |
ctx.save(); |
| 235 |
ctx.translate(50, 200); |
| 236 |
|
| 237 |
for (var r = 0; r < 45; r += 5) { |
| 238 |
for (var a = 0; a < 360; a += 18) { |
| 239 |
ctx.save(); |
| 240 |
|
| 241 |
ctx.rotate(a * Math.PI / 180); |
| 242 |
ctx.translate(0, r); |
| 243 |
ctx.fillStyle = 'hsl(' + a + ', 100%, ' + r + '%)'; |
| 244 |
var w = Math.max(5, r / 3); |
| 245 |
ctx.fillRect(-w / 2, -w / 2, w, w); |
| 246 |
|
| 247 |
ctx.restore(); |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
ctx.restore(); |
| 252 |
} |
| 253 |
|
| 254 |
window.onload = function() { |
| 255 |
drawNamedColors(); |
| 256 |
drawRgbColors(); |
| 257 |
drawHslColors(); |
| 258 |
}; |
| 259 |
|
| 260 |
</script> |
| 261 |
</head> |
| 262 |
<body> |
| 263 |
|
| 264 |
<canvas id=named width=100 height=730></canvas> |
| 265 |
<canvas id=rgb width=100 height=730></canvas> |
| 266 |
<canvas id=hsl width=100 height=730></canvas> |
| 267 |
<div id=color></div> |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
</body> |
| 272 |
</html> |