Small refactor
This commit is contained in:
parent
749b950f5f
commit
0733ceb3b6
@ -13699,20 +13699,17 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
Color.prototype.shiftRGB = function(shift, smart) {
|
Color.prototype.shiftRGB = function(shift, smart) {
|
||||||
var color;
|
var color, rgb, _i, _len, _ref;
|
||||||
if (smart) {
|
if (smart) {
|
||||||
shift = (this.isLight ? -1 : 1) * Math.abs(shift);
|
shift = (this.isLight() ? -1 : 1) * Math.abs(shift);
|
||||||
}
|
}
|
||||||
return ((function() {
|
rgb = [];
|
||||||
var _i, _len, _ref, _results;
|
_ref = this.privateRGB;
|
||||||
_ref = this.privateRGB;
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
_results = [];
|
color = _ref[_i];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
rgb.push(minmax(color + shift));
|
||||||
color = _ref[_i];
|
}
|
||||||
_results.push(minmax(color + shift));
|
return rgb.join("");
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
}).call(this)).join(",");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Color;
|
return Color;
|
||||||
|
|||||||
@ -13710,20 +13710,17 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
Color.prototype.shiftRGB = function(shift, smart) {
|
Color.prototype.shiftRGB = function(shift, smart) {
|
||||||
var color;
|
var color, rgb, _i, _len, _ref;
|
||||||
if (smart) {
|
if (smart) {
|
||||||
shift = (this.isLight ? -1 : 1) * Math.abs(shift);
|
shift = (this.isLight() ? -1 : 1) * Math.abs(shift);
|
||||||
}
|
}
|
||||||
return ((function() {
|
rgb = [];
|
||||||
var _i, _len, _ref, _results;
|
_ref = this.privateRGB;
|
||||||
_ref = this.privateRGB;
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
_results = [];
|
color = _ref[_i];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
rgb.push(minmax(color + shift));
|
||||||
color = _ref[_i];
|
}
|
||||||
_results.push(minmax(color + shift));
|
return rgb.join("");
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
}).call(this)).join(",");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Color;
|
return Color;
|
||||||
|
|||||||
@ -52,5 +52,7 @@ class Color
|
|||||||
isLight: -> (@privateRGB[0] * 0.299 + @privateRGB[1] * 0.587 + @privateRGB[2] * 0.114) > 125
|
isLight: -> (@privateRGB[0] * 0.299 + @privateRGB[1] * 0.587 + @privateRGB[2] * 0.114) > 125
|
||||||
|
|
||||||
shiftRGB: (shift, smart) ->
|
shiftRGB: (shift, smart) ->
|
||||||
shift = (if @isLight then -1 else 1) * Math.abs shift if smart
|
shift = (if @isLight() then -1 else 1) * Math.abs shift if smart
|
||||||
return (minmax color + shift for color in @privateRGB).join ","
|
rgb = []
|
||||||
|
rgb.push minmax color + shift for color in @privateRGB
|
||||||
|
rgb.join ""
|
||||||
Loading…
x
Reference in New Issue
Block a user