├── .gitignore
├── .npmignore
├── Cakefile
├── LICENSE
├── README.md
├── TODO.md
├── index.d.ts
├── index.html
├── lib
├── color-scheme.js
├── color-scheme.js.map
└── color-scheme.min.js
├── old_index.html
├── package.json
├── params.json
├── src
└── lib
│ └── color-scheme.coffee
├── test.coffee
├── test.js
└── test
├── mutablecolor.coffee
├── test.coffee
└── test.js
/.gitignore:
--------------------------------------------------------------------------------
1 | lib-cov
2 | *.seed
3 | *.log
4 | *.csv
5 | *.dat
6 | *.out
7 | *.pid
8 | *.gz
9 |
10 | pids
11 | logs
12 | results
13 |
14 | npm-debug.log
15 | node_modules
16 | .idea
17 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .idea
2 | src
3 | node_modules
--------------------------------------------------------------------------------
/Cakefile:
--------------------------------------------------------------------------------
1 | fs = require 'fs'
2 | sys = require 'sys'
3 | path = require 'path'
4 | {exec} = require 'child_process'
5 | UglifyJS = require 'uglify-js'
6 |
7 | task 'compile', 'Compile coffee-script to JavaScript', ->
8 | compile()
9 |
10 | task 'test', 'Test this module', ->
11 | test()
12 |
13 | task 'build', 'Build this module', ->
14 | build()
15 |
16 | task 'minify', 'Minify the compiled javascript source', ->
17 | minify()
18 |
19 | compile = (callback) ->
20 | console.log "Compiling..."
21 |
22 | # Create the lib directory if it doesn't exist
23 | if !fs.existsSync("lib")
24 | fs.mkdirSync "lib"
25 |
26 | # Compile the library
27 | child = exec '"node_modules/.bin/coffee" -m -o lib ./src/lib/color-scheme.coffee', (err, stdout, stderr) ->
28 | if err?
29 | throw err
30 | else
31 | callback() if callback?
32 |
33 | # Redirect the child process' output to our stdout
34 | child.stdout.on 'data', (data) -> sys.print data
35 | child.stderr.on 'data', (data) -> sys.print data
36 |
37 | test = (callback) ->
38 | console.log "Testing..."
39 |
40 | child = exec '"node_modules/.bin/mocha" --reporter list --compilers coffee:coffee-script/register test', (err, stdout, stderr) ->
41 | # console.log stdout
42 | # console.log stderr
43 |
44 | if err?
45 | process.exit()
46 | else
47 | callback() if callback?
48 |
49 | # Redirect the child process' output to our stdout
50 | child.stdout.on 'data', (data) -> sys.print data
51 | child.stderr.on 'data', (data) -> sys.print data
52 |
53 | minify = (callback) ->
54 | console.log "Minifying..."
55 |
56 | compiled = UglifyJS.minify('lib/color-scheme.js')
57 | fs.writeFileSync 'lib/color-scheme.min.js', compiled.code.toString()
58 |
59 | callback() if callback?
60 |
61 | # Run all the tasks one after the other!
62 | build = (callback) ->
63 | test () ->
64 | compile () ->
65 | minify () ->
66 | console.log "Done!"
67 | callback() if callback?
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 Brian Hann
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # color-scheme.js
2 |
3 | Generate pleasant color schemes (sets of colors).
4 |
5 | This library is based on the perl module [Color::Scheme](http://search.cpan.org/~rjbs/Color-Scheme-1.04/lib/Color/Scheme.pm), which is in turn based on the [Color Scheme Designer website](http://colorschemedesigner.com/).
6 |
7 | Check out [how it works](http://c0bra.github.com/color-scheme-js/).
8 |
9 | Get the [minified file](https://raw.github.com/c0bra/color-scheme-js/master/lib/color-scheme.min.js) (8kb).
10 |
11 | Or for some reason, you could use the [full file](https://raw.github.com/c0bra/color-scheme-js/master/lib/color-scheme.js) (18kb).
12 |
13 | ## Table of Contents
14 |
15 | - [Description](#description)
16 | - [Usage](#usage)
17 | - [Schemes](#schemes)
18 | - [mono](#mono-monochromatic)
19 | - [contrast](#contrast)
20 | - [triade](#triade)
21 | - [tetrade](#tetrade)
22 | - [analogic](#analogic)
23 | - [Variations](#variations)
24 | - [pastel](#pastel)
25 | - [soft](#soft)
26 | - [light](#light)
27 | - [hard](#hard)
28 | - [pale](#pale)
29 | - [Methods](#methods)
30 |
31 | ## Description
32 |
33 | This module is a JavaScript implementation of the Perl implementation of Color Schemes
34 | 2 ([http://wellstyled.com/tools/colorscheme2](http://wellstyled.com/tools/colorscheme2)), a color scheme generator.
35 | Start by visitng the Color Schemes 2 web site and playing with the colors.
36 | When you want to generate those schemes on the fly, begin using this modoule.
37 | The descriptions herein don't make too much sense without actually seeing the
38 | colorful results.
39 |
40 | Henceforth, paragraphs in quotes denote documentation copied from Color Schemes 2.
41 |
42 | *"Important note: **This tool doesn't use the standard HSV or HSB model** (the
43 | same HSV/HSB values ie. in Photoshop describe different colors!). The color
44 | wheel used here differs from the RGB spectre used on computer screens, it's
45 | more in accordance with the classical color theory. This is also why some
46 | colors (especially shades of blue) make less bright shades than the basic
47 | colors of the RGB-model. In plus, the RGB-model uses red-green-blue as primary
48 | colors, but the red-yellow-blue combination is used here. This deformation also
49 | causes incompatibility in color conversions from RGB-values. Therefore, the RGB
50 | input (eg. the HTML hex values like #F854A9) is not exact, the conversion is
51 | rough and sometimes may produce slightly different color."*
52 |
53 | ## Usage
54 |
55 | ### In node.js
56 |
57 | Gotta install it first:
58 |
59 | ```
60 | npm install color-scheme
61 | ```
62 |
63 | ```javascript
64 | var ColorScheme = require('color-scheme');
65 |
66 | var scheme = new ColorScheme;
67 | scheme.from_hue(21) // Start the scheme
68 | .scheme('triade') // Use the 'triade' scheme, that is, colors
69 | // selected from 3 points equidistant around
70 | // the color wheel.
71 | .variation('soft'); // Use the 'soft' color variation
72 |
73 | var colors = scheme.colors();
74 |
75 | /*
76 | colors = [ "e69373", "805240", "e6d5cf", "bf5830" ,
77 | "77d36a", "488040", "d2e6cf", "43bf30" ,
78 | "557aaa", "405c80", "cfd9e6", "306ebf" ]
79 | */
80 | ```
81 |
82 | ### In the browser
83 |
84 | ```html
85 |
86 |
87 |
40 |
41 |
(Note: this functions a bit differently from setting the hue above; it will create a custom variation "preset" that differs from any of the below options)
115 |
116 |
117 |
118 |
Scheme
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
Distance
132 |
(won't affect mono or contrast)
133 |
134 |
135 |
136 |
137 |
Variation
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
Web Safe
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
Generated Colors
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
Todo
175 |
176 | The code is translated but all the docs and tests need to be written/copied. Hang tight!
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
372 |
373 |
--------------------------------------------------------------------------------
/lib/color-scheme.js:
--------------------------------------------------------------------------------
1 | // Generated by CoffeeScript 1.12.7
2 | (function() {
3 | var ColorScheme,
4 | slice = [].slice;
5 |
6 | ColorScheme = (function() {
7 | var clone, l, len, ref, typeIsArray, word;
8 |
9 | typeIsArray = Array.isArray || function(value) {
10 | return {}.toString.call(value) === '[object Array]';
11 | };
12 |
13 | ColorScheme.SCHEMES = {};
14 |
15 | ref = "mono monochromatic contrast triade tetrade analogic".split(/\s+/);
16 | for (l = 0, len = ref.length; l < len; l++) {
17 | word = ref[l];
18 | ColorScheme.SCHEMES[word] = true;
19 | }
20 |
21 | ColorScheme.PRESETS = {
22 | "default": [-1, -1, 1, -0.7, 0.25, 1, 0.5, 1],
23 | pastel: [0.5, -0.9, 0.5, 0.5, 0.1, 0.9, 0.75, 0.75],
24 | soft: [0.3, -0.8, 0.3, 0.5, 0.1, 0.9, 0.5, 0.75],
25 | light: [0.25, 1, 0.5, 0.75, 0.1, 1, 0.5, 1],
26 | hard: [1, -1, 1, -0.6, 0.1, 1, 0.6, 1],
27 | pale: [0.1, -0.85, 0.1, 0.5, 0.1, 1, 0.1, 0.75]
28 | };
29 |
30 | ColorScheme.COLOR_WHEEL = {
31 | 0: [255, 0, 0, 100],
32 | 15: [255, 51, 0, 100],
33 | 30: [255, 102, 0, 100],
34 | 45: [255, 128, 0, 100],
35 | 60: [255, 153, 0, 100],
36 | 75: [255, 178, 0, 100],
37 | 90: [255, 204, 0, 100],
38 | 105: [255, 229, 0, 100],
39 | 120: [255, 255, 0, 100],
40 | 135: [204, 255, 0, 100],
41 | 150: [153, 255, 0, 100],
42 | 165: [51, 255, 0, 100],
43 | 180: [0, 204, 0, 80],
44 | 195: [0, 178, 102, 70],
45 | 210: [0, 153, 153, 60],
46 | 225: [0, 102, 178, 70],
47 | 240: [0, 51, 204, 80],
48 | 255: [25, 25, 178, 70],
49 | 270: [51, 0, 153, 60],
50 | 285: [64, 0, 153, 60],
51 | 300: [102, 0, 153, 60],
52 | 315: [153, 0, 153, 60],
53 | 330: [204, 0, 153, 80],
54 | 345: [229, 0, 102, 90]
55 | };
56 |
57 | function ColorScheme() {
58 | var colors, m;
59 | colors = [];
60 | for (m = 1; m <= 4; m++) {
61 | colors.push(new ColorScheme.mutablecolor(60));
62 | }
63 | this.col = colors;
64 | this._scheme = 'mono';
65 | this._distance = 0.5;
66 | this._web_safe = false;
67 | this._add_complement = false;
68 | }
69 |
70 |
71 | /*
72 |
73 | colors()
74 |
75 | Returns an array of 4, 8, 12 or 16 colors in RRGGBB hexidecimal notation
76 | (without a leading "#") depending on the color scheme and addComplement
77 | parameter. For each set of four, the first is usually the most saturated color,
78 | the second a darkened version, the third a pale version and fourth
79 | a less-pale version.
80 |
81 | For example: With a contrast scheme, "colors()" would return eight colors.
82 | Indexes 1 and 5 could be background colors, 2 and 6 could be foreground colors.
83 |
84 | Trust me, it's much better if you check out the Color Scheme web site, whose
85 | URL is listed in "Description"
86 | */
87 |
88 | ColorScheme.prototype.colors = function() {
89 | var dispatch, h, i, j, m, n, output, ref1, used_colors;
90 | used_colors = 1;
91 | h = this.col[0].get_hue();
92 | dispatch = {
93 | mono: (function(_this) {
94 | return function() {};
95 | })(this),
96 | contrast: (function(_this) {
97 | return function() {
98 | used_colors = 2;
99 | _this.col[1].set_hue(h);
100 | return _this.col[1].rotate(180);
101 | };
102 | })(this),
103 | triade: (function(_this) {
104 | return function() {
105 | var dif;
106 | used_colors = 3;
107 | dif = 60 * _this._distance;
108 | _this.col[1].set_hue(h);
109 | _this.col[1].rotate(180 - dif);
110 | _this.col[2].set_hue(h);
111 | return _this.col[2].rotate(180 + dif);
112 | };
113 | })(this),
114 | tetrade: (function(_this) {
115 | return function() {
116 | var dif;
117 | used_colors = 4;
118 | dif = 90 * _this._distance;
119 | _this.col[1].set_hue(h);
120 | _this.col[1].rotate(180);
121 | _this.col[2].set_hue(h);
122 | _this.col[2].rotate(180 + dif);
123 | _this.col[3].set_hue(h);
124 | return _this.col[3].rotate(dif);
125 | };
126 | })(this),
127 | analogic: (function(_this) {
128 | return function() {
129 | var dif;
130 | used_colors = _this._add_complement ? 4 : 3;
131 | dif = 60 * _this._distance;
132 | _this.col[1].set_hue(h);
133 | _this.col[1].rotate(dif);
134 | _this.col[2].set_hue(h);
135 | _this.col[2].rotate(360 - dif);
136 | _this.col[3].set_hue(h);
137 | return _this.col[3].rotate(180);
138 | };
139 | })(this)
140 | };
141 | dispatch['monochromatic'] = dispatch['mono'];
142 | if (dispatch[this._scheme] != null) {
143 | dispatch[this._scheme]();
144 | } else {
145 | throw "Unknown color scheme name: " + this._scheme;
146 | }
147 | output = [];
148 | for (i = m = 0, ref1 = used_colors - 1; 0 <= ref1 ? m <= ref1 : m >= ref1; i = 0 <= ref1 ? ++m : --m) {
149 | for (j = n = 0; n <= 3; j = ++n) {
150 | output[i * 4 + j] = this.col[i].get_hex(this._web_safe, j);
151 | }
152 | }
153 | return output;
154 | };
155 |
156 |
157 | /*
158 |
159 | colorset()
160 |
161 | Returns a list of lists of the colors in groups of four. This method simply
162 | allows you to reference a color in the scheme by its group isntead of its
163 | absolute index in the list of colors. I am assuming that "colorset()"
164 | will make it easier to use this module with the templating systems that are
165 | out there.
166 |
167 | For example, if you were to follow the synopsis, say you wanted to retrieve
168 | the two darkest colors from the first two groups of the scheme, which is
169 | typically the second color in the group. You could retrieve them with
170 | "colors()"
171 |
172 | first_background = (scheme.colors())[1];
173 | second_background = (scheme.colors())[5];
174 |
175 | Or, with this method,
176 |
177 | first_background = (scheme.colorset())[0][1]
178 | second_background = (scheme.colorset())[1][1]
179 | */
180 |
181 | ColorScheme.prototype.colorset = function() {
182 | var flat_colors, grouped_colors;
183 | flat_colors = clone(this.colors());
184 | grouped_colors = [];
185 | while (flat_colors.length > 0) {
186 | grouped_colors.push(flat_colors.splice(0, 4));
187 | }
188 | return grouped_colors;
189 | };
190 |
191 |
192 | /*
193 |
194 | from_hue( degrees )
195 |
196 | Sets the base color hue, where 'degrees' is an integer. (Values greater than
197 | 359 and less than 0 wrap back around the wheel.)
198 |
199 | The default base hue is 0, or bright red.
200 | */
201 |
202 | ColorScheme.prototype.from_hue = function(h) {
203 | if (h == null) {
204 | throw "from_hue needs an argument";
205 | }
206 | this.col[0].set_hue(h);
207 | return this;
208 | };
209 |
210 | ColorScheme.prototype.rgb2ryb = function() {
211 | var blue, green, iN, maxgreen, maxyellow, red, rgb, white, yellow;
212 | rgb = 1 <= arguments.length ? slice.call(arguments, 0) : [];
213 | if ((rgb[0] != null) && typeIsArray(rgb[0])) {
214 | rgb = rgb[0];
215 | }
216 | red = rgb[0], green = rgb[1], blue = rgb[2];
217 | white = Math.min(red, green, blue);
218 | red -= white;
219 | green -= white;
220 | blue -= white;
221 | maxgreen = Math.max(red, green, blue);
222 | yellow = Math.min(red, green);
223 | red -= yellow;
224 | green -= yellow;
225 | if (blue > 0 && green > 0) {
226 | blue /= 2;
227 | green /= 2;
228 | }
229 | yellow += green;
230 | blue += green;
231 | maxyellow = Math.max(red, yellow, blue);
232 | if (maxyellow > 0) {
233 | iN = maxgreen / maxyellow;
234 | red *= iN;
235 | yellow *= iN;
236 | blue *= iN;
237 | }
238 | red += white;
239 | yellow += white;
240 | blue += white;
241 | return [Math.floor(red), Math.floor(yellow), Math.floor(blue)];
242 | };
243 |
244 | ColorScheme.prototype.rgb2hsv = function() {
245 | var b, d, g, h, max, min, r, rgb, s, v;
246 | rgb = 1 <= arguments.length ? slice.call(arguments, 0) : [];
247 | if ((rgb[0] != null) && typeIsArray(rgb[0])) {
248 | rgb = rgb[0];
249 | }
250 | r = rgb[0], g = rgb[1], b = rgb[2];
251 | r /= 255;
252 | g /= 255;
253 | b /= 255;
254 | min = Math.min.apply(Math, [r, g, b]);
255 | max = Math.max.apply(Math, [r, g, b]);
256 | d = max - min;
257 | v = max;
258 | s;
259 | if (d > 0) {
260 | s = d / max;
261 | } else {
262 | return [0, 0, v];
263 | }
264 | h = (r === max ? (g - b) / d : (g === max ? 2 + (b - r) / d : 4 + (r - g) / d));
265 | h *= 60;
266 | h %= 360;
267 | return [h, s, v];
268 | };
269 |
270 | ColorScheme.prototype.rgbToHsv = function() {
271 | var b, d, g, h, max, min, r, rgb, s, v;
272 | rgb = 1 <= arguments.length ? slice.call(arguments, 0) : [];
273 | if ((rgb[0] != null) && typeIsArray(rgb[0])) {
274 | rgb = rgb[0];
275 | }
276 | r = rgb[0], g = rgb[1], b = rgb[2];
277 | r /= 255;
278 | g /= 255;
279 | b /= 255;
280 | max = Math.max(r, g, b);
281 | min = Math.min(r, g, b);
282 | h = void 0;
283 | s = void 0;
284 | v = max;
285 | d = max - min;
286 | s = max === 0 ? 0 : d / max;
287 | if (max === min) {
288 | h = 0;
289 | } else {
290 | switch (max) {
291 | case r:
292 | h = (g - b) / d + (g < b ? 6 : 0);
293 | break;
294 | case g:
295 | h = (b - r) / d + 2;
296 | break;
297 | case b:
298 | h = (r - g) / d + 4;
299 | }
300 | h /= 6;
301 | }
302 | return [h, s, v];
303 | };
304 |
305 |
306 | /*
307 |
308 | from_hex( color )
309 |
310 | Sets the base color to the given color, where 'color' is in the hexidecimal
311 | form RRGGBB. 'color' should not be preceded with a hash (#).
312 |
313 | The default base color is the equivalent of #ff0000, or bright red.
314 | */
315 |
316 | ColorScheme.prototype.from_hex = function(hex) {
317 | var b, g, h, h0, h1, h2, hsv, i1, i2, num, r, ref1, ref2, rgbcap, s, v;
318 | if (hex == null) {
319 | throw "from_hex needs an argument";
320 | }
321 | if (!/^([0-9A-F]{2}){3}$/im.test(hex)) {
322 | throw "from_hex(" + hex + ") - argument must be in the form of RRGGBB";
323 | }
324 | rgbcap = /(..)(..)(..)/.exec(hex).slice(1, 4);
325 | ref1 = (function() {
326 | var len1, m, results;
327 | results = [];
328 | for (m = 0, len1 = rgbcap.length; m < len1; m++) {
329 | num = rgbcap[m];
330 | results.push(parseInt(num, 16));
331 | }
332 | return results;
333 | })(), r = ref1[0], g = ref1[1], b = ref1[2];
334 | ref2 = this.rgb2ryb([r, g, b]), r = ref2[0], g = ref2[1], b = ref2[2];
335 | hsv = this.rgbToHsv(r, g, b);
336 | h0 = hsv[0];
337 | h1 = 0;
338 | h2 = 1000;
339 | i1 = null;
340 | i2 = null;
341 | h = null;
342 | s = null;
343 | v = null;
344 | h = hsv[0];
345 | s = hsv[1];
346 | v = hsv[2];
347 | this.from_hue(h * 360);
348 | this._set_variant_preset([s, v, s, v * 0.7, s * 0.25, 1, s * 0.5, 1]);
349 | return this;
350 | };
351 |
352 |
353 | /*
354 |
355 | add_complement( BOOLEAN )
356 |
357 | If BOOLEAN is true, an extra set of colors will be produced using the
358 | complement of the selected color.
359 |
360 | This only works with the analogic color scheme. The default is false.
361 | */
362 |
363 | ColorScheme.prototype.add_complement = function(b) {
364 | if (b == null) {
365 | throw "add_complement needs an argument";
366 | }
367 | this._add_complement = b;
368 | return this;
369 | };
370 |
371 |
372 | /*
373 |
374 | web_safe( BOOL )
375 |
376 | Sets whether the colors returned by L<"colors()"> or L<"colorset()"> will be
377 | web-safe.
378 |
379 | The default is false.
380 | */
381 |
382 | ColorScheme.prototype.web_safe = function(b) {
383 | if (b == null) {
384 | throw "web_safe needs an argument";
385 | }
386 | this._web_safe = b;
387 | return this;
388 | };
389 |
390 |
391 | /*
392 |
393 | distance( FLOAT )
394 |
395 | 'FLOAT'> must be a value from 0 to 1. You might use this with the "triade"
396 | "tetrade" or "analogic" color schemes.
397 |
398 | The default is 0.5.
399 | */
400 |
401 | ColorScheme.prototype.distance = function(d) {
402 | if (d == null) {
403 | throw "distance needs an argument";
404 | }
405 | if (d < 0) {
406 | throw "distance(" + d + ") - argument must be >= 0";
407 | }
408 | if (d > 1) {
409 | throw "distance(" + d + ") - argument must be <= 1";
410 | }
411 | this._distance = d;
412 | return this;
413 | };
414 |
415 |
416 | /*
417 |
418 | scheme( name )
419 |
420 | 'name' must be a valid color scheme name. See "Color Schemes". The default
421 | is "mono"
422 | */
423 |
424 | ColorScheme.prototype.scheme = function(name) {
425 | if (name == null) {
426 | return this._scheme;
427 | } else {
428 | if (ColorScheme.SCHEMES[name] == null) {
429 | throw "'" + name + "' isn't a valid scheme name";
430 | }
431 | this._scheme = name;
432 | return this;
433 | }
434 | };
435 |
436 |
437 | /*
438 |
439 | variation( name )
440 |
441 | 'name' must be a valid color variation name. See "Color Variations"
442 | */
443 |
444 | ColorScheme.prototype.variation = function(v) {
445 | if (v == null) {
446 | throw "variation needs an argument";
447 | }
448 | if (ColorScheme.PRESETS[v] == null) {
449 | throw "'$v' isn't a valid variation name";
450 | }
451 | this._set_variant_preset(ColorScheme.PRESETS[v]);
452 | return this;
453 | };
454 |
455 | ColorScheme.prototype._set_variant_preset = function(p) {
456 | var i, m, results;
457 | results = [];
458 | for (i = m = 0; m <= 3; i = ++m) {
459 | results.push(this.col[i].set_variant_preset(p));
460 | }
461 | return results;
462 | };
463 |
464 | clone = function(obj) {
465 | var flags, key, newInstance;
466 | if ((obj == null) || typeof obj !== 'object') {
467 | return obj;
468 | }
469 | if (obj instanceof Date) {
470 | return new Date(obj.getTime());
471 | }
472 | if (obj instanceof RegExp) {
473 | flags = '';
474 | if (obj.global != null) {
475 | flags += 'g';
476 | }
477 | if (obj.ignoreCase != null) {
478 | flags += 'i';
479 | }
480 | if (obj.multiline != null) {
481 | flags += 'm';
482 | }
483 | if (obj.sticky != null) {
484 | flags += 'y';
485 | }
486 | return new RegExp(obj.source, flags);
487 | }
488 | newInstance = new obj.constructor();
489 | for (key in obj) {
490 | newInstance[key] = clone(obj[key]);
491 | }
492 | return newInstance;
493 | };
494 |
495 | ColorScheme.mutablecolor = (function() {
496 | mutablecolor.prototype.hue = 0;
497 |
498 | mutablecolor.prototype.saturation = [];
499 |
500 | mutablecolor.prototype.value = [];
501 |
502 | mutablecolor.prototype.base_red = 0;
503 |
504 | mutablecolor.prototype.base_green = 0;
505 |
506 | mutablecolor.prototype.base_saturation = 0;
507 |
508 | mutablecolor.prototype.base_value = 0;
509 |
510 | function mutablecolor(hue) {
511 | if (hue == null) {
512 | throw "No hue specified";
513 | }
514 | this.saturation = [];
515 | this.value = [];
516 | this.base_red = 0;
517 | this.base_green = 0;
518 | this.base_blue = 0;
519 | this.base_saturation = 0;
520 | this.base_value = 0;
521 | this.set_hue(hue);
522 | this.set_variant_preset(ColorScheme.PRESETS['default']);
523 | }
524 |
525 | mutablecolor.prototype.get_hue = function() {
526 | return this.hue;
527 | };
528 |
529 | mutablecolor.prototype.set_hue = function(h) {
530 | var avrg, color, colorset1, colorset2, d, derivative1, derivative2, en, i, k;
531 | avrg = function(a, b, k) {
532 | return a + Math.round((b - a) * k);
533 | };
534 | this.hue = Math.round(h % 360);
535 | d = this.hue % 15 + (this.hue - Math.floor(this.hue));
536 | k = d / 15;
537 | derivative1 = this.hue - Math.floor(d);
538 | derivative2 = (derivative1 + 15) % 360;
539 | if (derivative1 === 360) {
540 | derivative1 = 0;
541 | }
542 | if (derivative2 === 360) {
543 | derivative2 = 0;
544 | }
545 | colorset1 = ColorScheme.COLOR_WHEEL[derivative1];
546 | colorset2 = ColorScheme.COLOR_WHEEL[derivative2];
547 | en = {
548 | red: 0,
549 | green: 1,
550 | blue: 2,
551 | value: 3
552 | };
553 | for (color in en) {
554 | i = en[color];
555 | this["base_" + color] = avrg(colorset1[i], colorset2[i], k);
556 | }
557 | this.base_saturation = avrg(100, 100, k) / 100;
558 | return this.base_value /= 100;
559 | };
560 |
561 | mutablecolor.prototype.rotate = function(angle) {
562 | var newhue;
563 | newhue = (this.hue + angle) % 360;
564 | return this.set_hue(newhue);
565 | };
566 |
567 | mutablecolor.prototype.get_saturation = function(variation) {
568 | var s, x;
569 | x = this.saturation[variation];
570 | s = x < 0 ? -x * this.base_saturation : x;
571 | if (s > 1) {
572 | s = 1;
573 | }
574 | if (s < 0) {
575 | s = 0;
576 | }
577 | return s;
578 | };
579 |
580 | mutablecolor.prototype.get_value = function(variation) {
581 | var v, x;
582 | x = this.value[variation];
583 | v = x < 0 ? -x * this.base_value : x;
584 | if (v > 1) {
585 | v = 1;
586 | }
587 | if (v < 0) {
588 | v = 0;
589 | }
590 | return v;
591 | };
592 |
593 | mutablecolor.prototype.set_variant = function(variation, s, v) {
594 | this.saturation[variation] = s;
595 | return this.value[variation] = v;
596 | };
597 |
598 | mutablecolor.prototype.set_variant_preset = function(p) {
599 | var i, m, results;
600 | results = [];
601 | for (i = m = 0; m <= 3; i = ++m) {
602 | results.push(this.set_variant(i, p[2 * i], p[2 * i + 1]));
603 | }
604 | return results;
605 | };
606 |
607 | mutablecolor.prototype.get_hex = function(web_safe, variation) {
608 | var c, color, formatted, i, k, len1, len2, m, max, min, n, ref1, rgb, rgbVal, s, str, v;
609 | max = Math.max.apply(Math, (function() {
610 | var len1, m, ref1, results;
611 | ref1 = ['red', 'green', 'blue'];
612 | results = [];
613 | for (m = 0, len1 = ref1.length; m < len1; m++) {
614 | color = ref1[m];
615 | results.push(this["base_" + color]);
616 | }
617 | return results;
618 | }).call(this));
619 | min = Math.min.apply(Math, (function() {
620 | var len1, m, ref1, results;
621 | ref1 = ['red', 'green', 'blue'];
622 | results = [];
623 | for (m = 0, len1 = ref1.length; m < len1; m++) {
624 | color = ref1[m];
625 | results.push(this["base_" + color]);
626 | }
627 | return results;
628 | }).call(this));
629 | v = (variation < 0 ? this.base_value : this.get_value(variation)) * 255;
630 | s = variation < 0 ? this.base_saturation : this.get_saturation(variation);
631 | k = max > 0 ? v / max : 0;
632 | rgb = [];
633 | ref1 = ['red', 'green', 'blue'];
634 | for (m = 0, len1 = ref1.length; m < len1; m++) {
635 | color = ref1[m];
636 | rgbVal = Math.min.apply(Math, [255, Math.round(v - (v - this["base_" + color] * k) * s)]);
637 | rgb.push(rgbVal);
638 | }
639 | if (web_safe) {
640 | rgb = (function() {
641 | var len2, n, results;
642 | results = [];
643 | for (n = 0, len2 = rgb.length; n < len2; n++) {
644 | c = rgb[n];
645 | results.push(Math.round(c / 51) * 51);
646 | }
647 | return results;
648 | })();
649 | }
650 | formatted = "";
651 | for (n = 0, len2 = rgb.length; n < len2; n++) {
652 | i = rgb[n];
653 | str = i.toString(16);
654 | if (str.length < 2) {
655 | str = "0" + str;
656 | }
657 | formatted += str;
658 | }
659 | return formatted;
660 | };
661 |
662 | return mutablecolor;
663 |
664 | })();
665 |
666 | return ColorScheme;
667 |
668 | })();
669 |
670 | if ((typeof module !== "undefined" && module !== null) && (module.exports != null)) {
671 | module.exports = ColorScheme;
672 | } else {
673 | if (typeof define === 'function' && define.amd) {
674 | define([], function() {
675 | return ColorScheme;
676 | });
677 | } else {
678 | window.ColorScheme = ColorScheme;
679 | }
680 | }
681 |
682 | }).call(this);
683 |
684 | //# sourceMappingURL=color-scheme.js.map
685 |
--------------------------------------------------------------------------------
/lib/color-scheme.js.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "file": "color-scheme.js",
4 | "sourceRoot": "..",
5 | "sources": [
6 | "src/lib/color-scheme.coffee"
7 | ],
8 | "names": [],
9 | "mappings": ";AACA;AAAA,MAAA,WAAA;IAAA;;EAAM;AAGJ,QAAA;;IAAA,WAAA,GAAc,KAAK,CAAC,OAAN,IAAiB,SAAE,KAAF;AAAa,aAAO,EAAE,CAAC,QAAQ,CAAC,IAAZ,CAAkB,KAAlB,CAAA,KAA6B;IAAjD;;IAG/B,WAAC,CAAA,OAAD,GAAW;;AACX;AAAA,SAAA,qCAAA;;MAAA,WAAC,CAAA,OAAQ,CAAA,IAAA,CAAT,GAAiB;AAAjB;;IAEA,WAAC,CAAA,OAAD,GACE;MAAA,CAAA,OAAA,CAAA,EAAU,CAAE,CAAC,CAAH,EAAQ,CAAC,CAAT,EAAe,CAAf,EAAoB,CAAC,GAArB,EAA0B,IAA1B,EAAgC,CAAhC,EAAqC,GAArC,EAA2C,CAA3C,CAAV;MACA,MAAA,EAAU,CAAE,GAAF,EAAQ,CAAC,GAAT,EAAe,GAAf,EAAoB,GAApB,EAA0B,GAA1B,EAAgC,GAAhC,EAAqC,IAArC,EAA2C,IAA3C,CADV;MAEA,IAAA,EAAU,CAAE,GAAF,EAAQ,CAAC,GAAT,EAAe,GAAf,EAAoB,GAApB,EAA0B,GAA1B,EAAgC,GAAhC,EAAqC,GAArC,EAA2C,IAA3C,CAFV;MAGA,KAAA,EAAU,CAAE,IAAF,EAAQ,CAAR,EAAe,GAAf,EAAoB,IAApB,EAA0B,GAA1B,EAAgC,CAAhC,EAAqC,GAArC,EAA2C,CAA3C,CAHV;MAIA,IAAA,EAAU,CAAE,CAAF,EAAQ,CAAC,CAAT,EAAe,CAAf,EA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CAAA,GAAI,GAApB,GAA6B;QAEjC,GAAA,GAAM;AACN;AAAA,aAAA,wCAAA;;UACE,MAAA,GAAS,IAAI,CAAC,GAAL,aAAS,CAAE,GAAF,EAAO,IAAI,CAAC,KAAL,CAAW,CAAA,GAAI,CAAE,CAAA,GAAI,IAAK,CAAA,OAAA,GAAQ,KAAR,CAAL,GAAwB,CAA9B,CAAA,GAAoC,CAAnD,CAAP,CAAT;UACT,GAAG,CAAC,IAAJ,CAAS,MAAT;AAFF;QAIA,IAAG,QAAH;UACE,GAAA;;AAAQ;iBAAA,uCAAA;;2BAAA,IAAI,CAAC,KAAL,CAAW,CAAA,GAAI,EAAf,CAAA,GAAqB;AAArB;;eADV;;QAGA,SAAA,GAAY;AACZ,aAAA,uCAAA;;UACE,GAAA,GAAM,CAAC,CAAC,QAAF,CAAW,EAAX;UACN,IAAG,GAAG,CAAC,MAAJ,GAAa,CAAhB;YACE,GAAA,GAAM,GAAA,GAAI,IADZ;;UAGA,SAAA,IAAa;AALf;AAQA,eAAO;MA1BA;;;;;;;;;;EA4Bb,IAAG,kDAAA,IAAY,wBAAf;IACE,MAAM,CAAC,OAAP,GAAiB,YADnB;GAAA,MAAA;IAGE,IAAG,OAAO,MAAP,KAAiB,UAAjB,IAAgC,MAAM,CAAC,GAA1C;MACE,MAAA,CAAO,EAAP,EAAW,SAAA;AACT,eAAO;MADE,CAAX,EADF;KAAA,MAAA;MAIE,MAAM,CAAC,WAAP,GAAqB,YAJvB;KAHF;;AA/kBA"
10 | }
--------------------------------------------------------------------------------
/lib/color-scheme.min.js:
--------------------------------------------------------------------------------
1 | (function(){var t,e=[].slice;t=function(){function t(){var e,n;for(e=[],n=1;n<=4;n++)e.push(new t.mutablecolor(60));this.col=e,this._scheme="mono",this._distance=.5,this._web_safe=!1,this._add_complement=!1}var n,r,o,a,i,u;for(i=Array.isArray||function(t){return"[object Array]"==={}.toString.call(t)},t.SCHEMES={},a="mono monochromatic contrast triade tetrade analogic".split(/\s+/),r=0,o=a.length;r=u;n=0<=u?++o:--o)for(r=a=0;a<=3;r=++a)i[4*n+r]=this.col[n].get_hex(this._web_safe,r);return i},t.prototype.colorset=function(){var t,e;for(t=n(this.colors()),e=[];t.length>0;)e.push(t.splice(0,4));return e},t.prototype.from_hue=function(t){if(null==t)throw"from_hue needs an argument";return this.col[0].set_hue(t),this},t.prototype.rgb2ryb=function(){var t,n,r,o,a,u,s,h,l;return s=1<=arguments.length?e.call(arguments,0):[],null!=s[0]&&i(s[0])&&(s=s[0]),u=s[0],n=s[1],t=s[2],h=Math.min(u,n,t),u-=h,n-=h,t-=h,o=Math.max(u,n,t),l=Math.min(u,n),u-=l,n-=l,t>0&&n>0&&(t/=2,n/=2),l+=n,t+=n,a=Math.max(u,l,t),a>0&&(r=o/a,u*=r,l*=r,t*=r),u+=h,l+=h,t+=h,[Math.floor(u),Math.floor(l),Math.floor(t)]},t.prototype.rgb2hsv=function(){var t,n,r,o,a,u,s,h,l,c;return h=1<=arguments.length?e.call(arguments,0):[],null!=h[0]&&i(h[0])&&(h=h[0]),s=h[0],r=h[1],t=h[2],s/=255,r/=255,t/=255,u=Math.min.apply(Math,[s,r,t]),a=Math.max.apply(Math,[s,r,t]),n=a-u,c=a,n>0?(l=n/a,o=s===a?(r-t)/n:r===a?2+(t-s)/n:4+(s-r)/n,o*=60,o%=360,[o,l,c]):[0,0,c]},t.prototype.rgbToHsv=function(){var t,n,r,o,a,u,s,h,l,c;if(h=1<=arguments.length?e.call(arguments,0):[],null!=h[0]&&i(h[0])&&(h=h[0]),s=h[0],r=h[1],t=h[2],s/=255,r/=255,t/=255,a=Math.max(s,r,t),u=Math.min(s,r,t),o=void 0,l=void 0,c=a,n=a-u,l=0===a?0:n/a,a===u)o=0;else{switch(a){case s:o=(r-t)/n+(r= 0";if(t>1)throw"distance("+t+") - argument must be <= 1";return this._distance=t,this},t.prototype.scheme=function(e){if(null==e)return this._scheme;if(null==t.SCHEMES[e])throw"'"+e+"' isn't a valid scheme name";return this._scheme=e,this},t.prototype.variation=function(e){if(null==e)throw"variation needs an argument";if(null==t.PRESETS[e])throw"'$v' isn't a valid variation name";return this._set_variant_preset(t.PRESETS[e]),this},t.prototype._set_variant_preset=function(t){var e,n,r;for(r=[],e=n=0;n<=3;e=++n)r.push(this.col[e].set_variant_preset(t));return r},n=function(t){var e,r,o;if(null==t||"object"!=typeof t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return e="",null!=t.global&&(e+="g"),null!=t.ignoreCase&&(e+="i"),null!=t.multiline&&(e+="m"),null!=t.sticky&&(e+="y"),new RegExp(t.source,e);o=new t.constructor;for(r in t)o[r]=n(t[r]);return o},t.mutablecolor=function(){function e(e){if(null==e)throw"No hue specified";this.saturation=[],this.value=[],this.base_red=0,this.base_green=0,this.base_blue=0,this.base_saturation=0,this.base_value=0,this.set_hue(e),this.set_variant_preset(t.PRESETS.default)}return e.prototype.hue=0,e.prototype.saturation=[],e.prototype.value=[],e.prototype.base_red=0,e.prototype.base_green=0,e.prototype.base_saturation=0,e.prototype.base_value=0,e.prototype.get_hue=function(){return this.hue},e.prototype.set_hue=function(e){var n,r,o,a,i,u,s,h,l,c;n=function(t,e,n){return t+Math.round((e-t)*n)},this.hue=Math.round(e%360),i=this.hue%15+(this.hue-Math.floor(this.hue)),c=i/15,u=this.hue-Math.floor(i),s=(u+15)%360,360===u&&(u=0),360===s&&(s=0),o=t.COLOR_WHEEL[u],a=t.COLOR_WHEEL[s],h={red:0,green:1,blue:2,value:3};for(r in h)l=h[r],this["base_"+r]=n(o[l],a[l],c);return this.base_saturation=n(100,100,c)/100,this.base_value/=100},e.prototype.rotate=function(t){var e;return e=(this.hue+t)%360,this.set_hue(e)},e.prototype.get_saturation=function(t){var e,n;return n=this.saturation[t],e=n<0?-n*this.base_saturation:n,e>1&&(e=1),e<0&&(e=0),e},e.prototype.get_value=function(t){var e,n;return n=this.value[t],e=n<0?-n*this.base_value:n,e>1&&(e=1),e<0&&(e=0),e},e.prototype.set_variant=function(t,e,n){return this.saturation[t]=e,this.value[t]=n},e.prototype.set_variant_preset=function(t){var e,n,r;for(r=[],e=n=0;n<=3;e=++n)r.push(this.set_variant(e,t[2*e],t[2*e+1]));return r},e.prototype.get_hex=function(t,e){var n,r,o,a,i,u,s,h,l,c,f,p,_,m,d,v;for(l=Math.max.apply(Math,function(){var t,e,n,o;for(n=["red","green","blue"],o=[],e=0,t=n.length;e0?v/l:0,p=[],f=["red","green","blue"],h=0,u=f.length;h
2 |
3 |
4 |
5 |
6 | Color-scheme-js by c0bra
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:
If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.
41 |
42 |
Designer Templates
43 |
44 |
We've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.
45 |
46 |
Rather Drive Stick?
47 |
48 |
If you prefer to not use the automatic generator, push a branch named gh-pages to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.
49 |
50 |
Authors and Contributors
51 |
52 |
You can @mention a GitHub username to generate a link to their profile. The resulting <a> element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.