Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Reducing the transfer size of the color names... #235

Merged
merged 1 commit into from

2 participants

Miles Jason Johnston
Miles

...by about -170 bytes (-90 bytes gzipped). Instead of alphabetical order and encoding each RGB value, sorting in ascending order according to RGB integer value where values are cumulative.

Miles Elam Reducing the transfer size of the color names by about -170 bytes (-9…
…0 bytes gzipped). Instead of alphabetical order and encoding each RGB value, in ascending order according to RGB integer value where values are cumulative.
7b8f544
Jason Johnston
Owner

Brilliant, thanks!

Jason Johnston lojjic merged commit 6855c66 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 8, 2012
  1. Reducing the transfer size of the color names by about -170 bytes (-9…

    Miles Elam authored
    …0 bytes gzipped). Instead of alphabetical order and encoding each RGB value, in ascending order according to RGB integer value where values are cumulative.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 sources/Color.js
9 sources/Color.js
View
@@ -62,11 +62,12 @@ PIE.Color = (function() {
*/
Color.names = {};
- var names = 'aliceblue|9ehhb|antiquewhite|9sgk7|aqua|1ekf|aquamarine|4zsno|azure|9eiv3|beige|9lhp8|bisque|9zg04|black|0|blanchedalmond|9zhe5|blue|73|blueviolet|5e31e|brown|6g016|burlywood|8ouiv|cadetblue|3qba8|chartreuse|4zshs|chocolate|87k0u|coral|9yvyo|cornflowerblue|3xael|cornsilk|9zjz0|crimson|8l4xo|cyan|1ekf|darkblue|3v|darkcyan|rkb|darkgoldenrod|776yz|darkgray|6mbhl|darkgreen|jr4|darkkhaki|7ehkb|darkmagenta|5f91n|darkolivegreen|3bzfz|darkorange|9yygw|darkorchid|5z6x8|darkred|5f8xs|darksalmon|9441m|darkseagreen|5lwgf|darkslateblue|2th1n|darkslategray|1ugcv|darkturquoise|14up|darkviolet|5rw7n|deeppink|9yavn|deepskyblue|11xb|dimgray|442g9|dodgerblue|16xof|firebrick|6y7tu|floralwhite|9zkds|forestgreen|1cisi|fuchsia|9y70f|gainsboro|8m8kc|ghostwhite|9pq0v|gold|9zda8|goldenrod|8j4f4|gray|50i2o|green|pa8|greenyellow|6senj|honeydew|9eiuo|hotpink|9yrp0|indianred|80gnw|indigo|2xcoy|ivory|9zldc|khaki|9edu4|lavender|90c8q|lavenderblush|9ziet|lawngreen|4vk74|lemonchiffon|9zkct|lightblue|6s73a|lightcoral|9dtog|lightcyan|8s1rz|lightgoldenrodyellow|9sjiq|lightgreen|5nkwg|lightgrey|89jo3|lightpink|9z6wx|lightsalmon|9z2ii|lightseagreen|19xgq|lightskyblue|5arju|lightslategray|4nwk9|lightsteelblue|6wau6|lightyellow|9zlcw|lime|1edc|limegreen|1zcxe|linen|9shk6|magenta|9y70f|maroon|4zsow|mediumauqamarine|40eju|mediumblue|5p|mediumorchid|79qkz|mediumpurple|5r3rs|mediumseagreen|2d9ip|mediumslateblue|4tcku|mediumspringgreen|1di2|mediumturquoise|2uabw|mediumvioletred|7rn9h|midnightblue|z980|mintcream|9ljp6|mistyrose|9zg0x|moccasin|9zfzp|navajowhite|9zest|navy|3k|oldlace|9wq92|olive|50hz4|olivedrab|42v4z|orange|9z3eo|orangered|9ykg0|orchid|8iu3a|palegoldenrod|9bl4a|palegreen|5yw0o|paleturquoise|6v4ku|palevioletred|8g0wj|papayawhip|9zi6t|peachpuff|9ze0p|peru|80oqn|pink|9z8wb|plum|8nba5|powderblue|6wgdi|purple|4zssg|red|9y6tc|rosybrown|7cv4f|royalblue|2jvtt|saddlebrown|5fmkz|salmon|9rvci|sandybrown|9jn1c|seagreen|1tdnb|seashell|9zje6|sienna|6973h|silver|7ir40|skyblue|5arjf|slateblue|45e4t|slategray|4e100|snow|9zke2|springgreen|1egv|steelblue|2r1kk|tan|87yx8|teal|pds|thistle|8ggk8|tomato|9yqfb|turquoise|2j4r4|violet|9b10u|wheat|9ld4j|white|9zldr|whitesmoke|9lhpx|yellow|9zl6o|yellowgreen|61fzm'.split('|'),
- i = 0, len = names.length, val;
+ var names = 'black|0|navy|3k|darkblue|b|mediumblue|1u|blue|1e|darkgreen|jk1|green|5j4|teal|3k|darkcyan|26j|deepskyblue|ad0|darkturquoise|2xe|mediumspringgreen|8nd|lime|va|springgreen|3j|aqua|3k|cyan|0|midnightblue|xunl|dodgerblue|7ogf|lightseagreen|2zsb|forestgreen|2lbs|seagreen|guut|darkslategray|12pk|limegreen|4wkj|mediumseagreen|dwlb|turquoise|5v8f|royalblue|r2p|steelblue|75qr|darkslateblue|2fh3|mediumturquoise|ta9|indigo|32d2|darkolivegreen|emr1|cadetblue|ebu9|cornflowerblue|6z4d|mediumaquamarine|3459|dimgray|3nwf|slateblue|1bok|olivedrab|1opi|slategray|6y5p|lightslategray|9vk9|mediumslateblue|5g0l|lawngreen|27ma|chartreuse|48ao|aquamarine|5w|maroon|18|purple|3k|olive|p6o|gray|3k|lightslateblue|5j7j|skyblue|4q98|lightskyblue|f|blueviolet|3bhk|darkred|15we|darkmagenta|3v|saddlebrown|djc|darkseagreen|69vg|lightgreen|1og1|mediumpurple|3ivc|darkviolet|sfv|palegreen|6zt1|darkorchid|awk|yellowgreen|292e|sienna|7r3v|brown|6sxp|darkgray|6bgf|lightblue|5vlp|greenyellow|7k9|paleturquoise|2pxb|lightsteelblue|169c|powderblue|5jc|firebrick|1rgc|darkgoldenrod|8z55|mediumorchid|2jm0|rosybrown|34jg|darkkhaki|1mfw|silver|49jp|mediumvioletred|8w5h|indianred|8tef|peru|82r|violetred|3ntd|feldspar|212d|chocolate|16eh|tan|ewe|lightgrey|1kqv|palevioletred|6h8g|metle|fnp|orchid|2dj2|goldenrod|abu|crimson|20ik|gainsboro|13mo|plum|12pt|burlywood|1j8q|lightcyan|3794|lavender|8agr|darksalmon|3rsw|violet|6wz8|palegoldenrod|k3g|lightcoral|28k6|khaki|k5o|aliceblue|3n7|honeydew|1dd|azure|f|sandybrown|5469|wheat|1q37|beige|4kp|whitesmoke|p|mintcream|1z9|ghostwhite|46bp|salmon|25bn|antiquewhite|l7p|linen|zz|lightgoldenrodyellow|1yk|oldlace|46qc|red|1gka|magenta|73|fuchsia|0|deeppink|3v8|orangered|9kd|tomato|5zb|hotpink|19p|coral|49o|darkorange|2i8|lightsalmon|41m|orange|w6|lightpink|3i9|pink|1ze|gold|4dx|peachpuff|qh|navajowhite|s4|moccasin|16w|bisque|f|mistyrose|t|blanchedalmond|1d8|papayawhip|so|lavenderblush|80|seashell|zd|cornsilk|ku|lemonchiffon|dt|floralwhite|z|snow|a|yellow|sm|lightyellow|68|ivory|g|white|f'.split('|'),
+ i = 0, len = names.length, color = 0, hexColor;
for(; i < len; i += 2) {
- val = parseInt(names[i + 1], 36).toString(16);
- Color.names[names[i]] = '#' + ('000000' + val).substr(val.length);
+ color += parseInt(names[i + 1], 36);
+ hexColor = color.toString(16);
+ Color.names[names[i]] = '#000000'.slice(0, -hexColor.length) + hexColor;
}
Color.prototype = {
Something went wrong with that request. Please try again.