123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <script src='https://code.jquery.com/jquery-2.1.3.min.js'></script>
- <style>
- span {
- display: inline-block;
- }
- </style>
- <div>
- <span>Control:</span>
- <span>Decisions: 330</span>
- <span>Iteration: 300</span>
- <span>Functions: 210</span>
- <span>Properties:</span>
- <span>Manipulations: 240</span>
- <span>Calculations: 270</span>
- <span>Special:</span>
- <span>Generic Function: 180</span>
- <span>Plotting: 170</span>
- <span>Utility: 160</span>
- <span>Data:</span>
- <span>Simple Data: 100</span>
- <span>Lists: 30</span>
- <span>Dictionaries: 0</span>
- <span>Concrete:</span>
- <span>UNRESERVED: 75</span>
- <span>Weather: 70</span>
- <span>Earthquakes: 65</span>
- <span>Stocks: 60</span>
- <span>Crime: 55</span>
- <span>Books: 50</span>
- <span>ENDING: 330</span>
- </div>
- <script>
- // Changes the RGB/HEX temporarily to a HSL-Value, modifies that value
- // and changes it back to RGB/HEX.
- function changeHue(rgb, degree) {
- var hsl = rgbToHSL(rgb);
- hsl.h += degree;
- if (hsl.h > 360) {
- hsl.h -= 360;
- }
- else if (hsl.h < 0) {
- hsl.h += 360;
- }
- return hslToRGB(hsl);
- }
- // exepcts a string and returns an object
- function rgbToHSL(rgb) {
- // strip the leading # if it's there
- rgb = rgb.replace(/^\s*#|\s*$/g, '');
- // convert 3 char codes --> 6, e.g. `E0F` --> `EE00FF`
- if(rgb.length == 3){
- rgb = rgb.replace(/(.)/g, '$1$1');
- }
- var r = parseInt(rgb.substr(0, 2), 16) / 255,
- g = parseInt(rgb.substr(2, 2), 16) / 255,
- b = parseInt(rgb.substr(4, 2), 16) / 255,
- cMax = Math.max(r, g, b),
- cMin = Math.min(r, g, b),
- delta = cMax - cMin,
- l = (cMax + cMin) / 2,
- h = 0,
- s = 0;
- if (delta == 0) {
- h = 0;
- }
- else if (cMax == r) {
- h = 60 * (((g - b) / delta) % 6);
- }
- else if (cMax == g) {
- h = 60 * (((b - r) / delta) + 2);
- }
- else {
- h = 60 * (((r - g) / delta) + 4);
- }
- if (delta == 0) {
- s = 0;
- }
- else {
- s = (delta/(1-Math.abs(2*l - 1)))
- }
- return {
- h: h,
- s: s,
- l: l
- }
- }
- // expects an object and returns a string
- function hslToRGB(hsl) {
- var h = hsl.h,
- s = hsl.s,
- l = hsl.l,
- c = (1 - Math.abs(2*l - 1)) * s,
- x = c * ( 1 - Math.abs((h / 60 ) % 2 - 1 )),
- m = l - c/ 2,
- r, g, b;
- if (h < 60) {
- r = c;
- g = x;
- b = 0;
- }
- else if (h < 120) {
- r = x;
- g = c;
- b = 0;
- }
- else if (h < 180) {
- r = 0;
- g = c;
- b = x;
- }
- else if (h < 240) {
- r = 0;
- g = x;
- b = c;
- }
- else if (h < 300) {
- r = x;
- g = 0;
- b = c;
- }
- else {
- r = c;
- g = 0;
- b = x;
- }
- r = normalize_rgb_value(r, m);
- g = normalize_rgb_value(g, m);
- b = normalize_rgb_value(b, m);
- return rgbToHex(r,g,b);
- }
- function normalize_rgb_value(color, m) {
- color = Math.floor((color + m) * 255);
- if (color < 0) {
- color = 0;
- }
- return color;
- }
- function rgbToHex(r, g, b) {
- return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
- }
- $("span").each(function(i, e) {
- var i = parseInt($(e).text().split(":")[1])-130;
- $(e).css("background-color",
- changeHue('5ba55b',
- i)).after("<br/>");
- });</script>
|