Accidentally broke all of this. Fix, refactor, golden.

This commit is contained in:
Zixaphir 2014-01-02 17:54:11 -07:00
parent 89ec27790d
commit f4ea956be3
3 changed files with 34 additions and 35 deletions

View File

@ -13618,7 +13618,7 @@
};
Color = (function() {
var calcRGB, colorToHex, minmax, shortToLong;
var colorToHex, minmax, shortToLong;
minmax = function(base) {
if (base < 0) {
@ -13630,12 +13630,6 @@
}
};
calcRGB = function(value) {
var hex;
hex = parseInt(value, 16);
return [(hex >> 16) & 0xFF, (hex >> 8) & 0xFF, hex & 0xFF];
};
shortToLong = function(hex) {
var i, longHex;
longHex = [];
@ -13682,10 +13676,6 @@
return "#" + this.raw;
};
Color.prototype.privateRGB = function() {
return calc_rgb(this.raw);
};
Color.prototype.rgb = function() {
return this.privateRGB().join("");
};
@ -13695,7 +13685,15 @@
};
Color.prototype.isLight = function() {
return (this.privateRGB[0] * 0.299 + this.privateRGB[1] * 0.587 + this.privateRGB[2] * 0.114) > 125;
var rgb;
rgb = this.privateRGB();
return (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125;
};
Color.prototype.privateRGB = function() {
var hex;
hex = parseInt(this.raw, 16);
return [(hex >> 16) & 0xFF, (hex >> 8) & 0xFF, hex & 0xFF];
};
Color.prototype.shiftRGB = function(shift, smart) {

View File

@ -13629,7 +13629,7 @@
};
Color = (function() {
var calcRGB, colorToHex, minmax, shortToLong;
var colorToHex, minmax, shortToLong;
minmax = function(base) {
if (base < 0) {
@ -13641,12 +13641,6 @@
}
};
calcRGB = function(value) {
var hex;
hex = parseInt(value, 16);
return [(hex >> 16) & 0xFF, (hex >> 8) & 0xFF, hex & 0xFF];
};
shortToLong = function(hex) {
var i, longHex;
longHex = [];
@ -13693,10 +13687,6 @@
return "#" + this.raw;
};
Color.prototype.privateRGB = function() {
return calc_rgb(this.raw);
};
Color.prototype.rgb = function() {
return this.privateRGB().join("");
};
@ -13706,7 +13696,15 @@
};
Color.prototype.isLight = function() {
return (this.privateRGB[0] * 0.299 + this.privateRGB[1] * 0.587 + this.privateRGB[2] * 0.114) > 125;
var rgb;
rgb = this.privateRGB();
return (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125;
};
Color.prototype.privateRGB = function() {
var hex;
hex = parseInt(this.raw, 16);
return [(hex >> 16) & 0xFF, (hex >> 8) & 0xFF, hex & 0xFF];
};
Color.prototype.shiftRGB = function(shift, smart) {

View File

@ -1,14 +1,6 @@
class Color
minmax = (base) -> if base < 0 then 0 else if base > 255 then 255 else base
calcRGB = (value) ->
hex = parseInt value, 16
return [ # 0xRRGGBB to [R, G, B]
(hex >> 16) & 0xFF
(hex >> 8) & 0xFF
hex & 0xFF
]
shortToLong = (hex) ->
longHex = []
i = 0
@ -43,13 +35,24 @@ class Color
"000000"
constructor: (value) ->
@raw = colorToHex value
@raw = colorToHex value
hex: -> "#" + @raw
privateRGB: -> calc_rgb @raw
rgb: -> @privateRGB().join ""
hover: -> @shiftRGB 16, true
isLight: -> (@privateRGB[0] * 0.299 + @privateRGB[1] * 0.587 + @privateRGB[2] * 0.114) > 125
isLight: ->
rgb = @privateRGB()
(rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125
privateRGB: ->
hex = parseInt @raw, 16
return [
# 0xRRGGBB to [R, G, B]
(hex >> 16) & 0xFF
(hex >> 8) & 0xFF
hex & 0xFF
]
shiftRGB: (shift, smart) ->
shift = (if @isLight() then -1 else 1) * Math.abs shift if smart