From 0b2fcfc03ffa8efc389825fe900620125922656b Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 4 Sep 2013 17:33:33 -0700 Subject: [PATCH] Why limit ourselves to two arguments? --- builds/appchan-x.user.js | 31 ++++++++++++++----------------- builds/crx/script.js | 31 ++++++++++++++----------------- src/Theming/Style.coffee | 31 +++++++++++-------------------- 3 files changed, 39 insertions(+), 54 deletions(-) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index a7e57952e..1f19c8c4b 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -12652,25 +12652,22 @@ node.disabled = true; } }, - matrix: function(foreground, background) { - var bg, bgHex, fg, fgHex; + matrix: function() { + var arg, color, colors, hex, i, rgb, val, _i, _len; - fgHex = Style.colorToHex(foreground) || "ffffff"; - fg = { - r: parseInt(fgHex.substr(0, 2), 16) / 255, - g: parseInt(fgHex.substr(2, 2), 16) / 255, - b: parseInt(fgHex.substr(4, 2), 16) / 255 - }; - if (background) { - bgHex = Style.colorToHex(background) || "000000"; - bg = { - r: parseInt(bgHex.substr(0, 2), 16) / 255, - g: parseInt(bgHex.substr(2, 2), 16) / 255, - b: parseInt(bgHex.substr(4, 2), 16) / 255 - }; - return [fg, bg]; + colors = []; + for (_i = 0, _len = arguments.length; _i < _len; _i++) { + arg = arguments[_i]; + hex = Style.colorToHex(arg) || "ffffff"; + color = {}; + rgb = ['r', 'g', 'b']; + i = 0; + while (val = rgb[i]) { + color[val] = parseInt(hex.substr(2 * i++, 2), 16) / 255; + } + colors.push(color); } - return [fg]; + return colors; }, filter: function(_arg) { var bg, fg; diff --git a/builds/crx/script.js b/builds/crx/script.js index 1b455c3fa..c36445c49 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -12648,25 +12648,22 @@ node.disabled = true; } }, - matrix: function(foreground, background) { - var bg, bgHex, fg, fgHex; + matrix: function() { + var arg, color, colors, hex, i, rgb, val, _i, _len; - fgHex = Style.colorToHex(foreground) || "ffffff"; - fg = { - r: parseInt(fgHex.substr(0, 2), 16) / 255, - g: parseInt(fgHex.substr(2, 2), 16) / 255, - b: parseInt(fgHex.substr(4, 2), 16) / 255 - }; - if (background) { - bgHex = Style.colorToHex(background) || "000000"; - bg = { - r: parseInt(bgHex.substr(0, 2), 16) / 255, - g: parseInt(bgHex.substr(2, 2), 16) / 255, - b: parseInt(bgHex.substr(4, 2), 16) / 255 - }; - return [fg, bg]; + colors = []; + for (_i = 0, _len = arguments.length; _i < _len; _i++) { + arg = arguments[_i]; + hex = Style.colorToHex(arg) || "ffffff"; + color = {}; + rgb = ['r', 'g', 'b']; + i = 0; + while (val = rgb[i]) { + color[val] = parseInt(hex.substr(2 * i++, 2), 16) / 255; + } + colors.push(color); } - return [fg]; + return colors; }, filter: function(_arg) { var bg, fg; diff --git a/src/Theming/Style.coffee b/src/Theming/Style.coffee index dbc80e886..5343d6bd9 100644 --- a/src/Theming/Style.coffee +++ b/src/Theming/Style.coffee @@ -93,27 +93,18 @@ Style = node.disabled = true return - matrix: (foreground, background) -> - fgHex = Style.colorToHex(foreground) or "ffffff" + matrix: -> + colors = [] + for arg in arguments + hex = Style.colorToHex(arg) or "ffffff" + color = {} + rgb = ['r', 'g', 'b'] + i = 0 + while val = rgb[i] + color[val] = parseInt(hex.substr((2 * i++), 2), 16) / 255 + colors.push color - fg = { - r: parseInt(fgHex.substr(0, 2), 16) / 255 - g: parseInt(fgHex.substr(2, 2), 16) / 255 - b: parseInt(fgHex.substr(4, 2), 16) / 255 - } - - if background - bgHex = Style.colorToHex(background) or "000000" - - bg = { - r: parseInt(bgHex.substr(0, 2), 16) / 255 - g: parseInt(bgHex.substr(2, 2), 16) / 255 - b: parseInt(bgHex.substr(4, 2), 16) / 255 - } - - return [fg, bg] - - [fg] + colors filter: ([fg, bg]) -> "#{bg.r} #{-fg.r} 0 0 #{fg.r} #{bg.g} #{-fg.g} 0 0 #{fg.g} #{bg.b} #{-fg.b} 0 0 #{fg.b}"