diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-02-13 12:41:40 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-02-13 12:41:40 -0500 |
| commit | d67f7095d4d3f061431d9ec88996cda0e9b00267 (patch) | |
| tree | 96fc29ba270cd7d0520888360070d7ef428c87cf /js | |
| parent | 9a525a25fdb43bc1be866d8b4a50afee7b384c59 (diff) | |
adding hues
Diffstat (limited to 'js')
| -rw-r--r-- | js/color_code.js | 40 | ||||
| -rw-r--r-- | js/util.js | 4 |
2 files changed, 43 insertions, 1 deletions
diff --git a/js/color_code.js b/js/color_code.js index 55a284f..c8e8b84 100644 --- a/js/color_code.js +++ b/js/color_code.js @@ -18,7 +18,42 @@ var MircColor = (function(){ [127,127,127], [210,210,210] ] - + var HUES = [ + [255,255,255], + [0,0,0], + [0,0,127], + [0,147,0], + [255,0,0], + [127,0,0], + [156,0,156], + [252,127,0], + [255,255,0], + [0,252,0], + [0,147,147], + [0,255,255], + [0,0,252], + [255,0,255], + null, + null, + ] + var GRAYS = [ + [255,255,255], + [0,0,0], + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + [127,127,127], + [210,210,210] + ] function closest_to(pixel){ return COLORS.reduce(function(prev, curr, index) { var d = distance(pixel, curr) @@ -31,6 +66,7 @@ var MircColor = (function(){ } function distance(u, v){ + if (! v) return Math.Infinity var r = u[0] - v[0] var g = u[1] - v[1] var b = u[2] - v[2] @@ -137,6 +173,8 @@ var MircColor = (function(){ return { colors: COLORS, + hues: HUES, + grays: GRAYS, closest_to: closest_to, distance: distance, fromUrl: fromUrl, @@ -115,6 +115,10 @@ function weave(a){ reverse(aa[1]).forEach(function(el){ b.push(el) }) return b } +function cssRule (selector, declaration) { + var x = document.styleSheets, y = x.length-1; + x[y].insertRule(selector+"{"+declaration+"}", x[y].cssRules.length); +} // easing functions function circular (t) { return Math.sqrt( 1 - ( --t * t ) ) } |
