From af7e57b1d9aee8346bb7121e064862eeb6c435fa Mon Sep 17 00:00:00 2001 From: mattpass Date: Wed, 30 Dec 2020 15:47:26 +0000 Subject: [PATCH] Can use rgba (+uc), rgbToHex ignores 4th alpha param --- assets/js/icecoder.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/assets/js/icecoder.js b/assets/js/icecoder.js index 23cf5c8..8c5c04d 100644 --- a/assets/js/icecoder.js +++ b/assets/js/icecoder.js @@ -3163,9 +3163,9 @@ var ICEcoder = { farbtastic('picker','color'); // If we have a color value, set it in picker if (color) { - // If an RGB value, convert to hex - if (-1 < color.indexOf("rgb")) { - color = color.replace(/rgb|\(|\)|\s+/g, "").split(","); + // If a RGB(A) value, convert to Hex + if (-1 < color.toLowerCase().indexOf("rgb")) { + color = color.replace(/rgba?|\(|\)|\s+/gi, "").split(","); color = "#" + this.rgbToHex(...color); } get('picker').farbtastic.setColor(color); @@ -3263,8 +3263,9 @@ var ICEcoder = { } }, - // Convert RGB values to Hex - rgbToHex: function(r, g, b) { + // Convert RGB(A) values to Hex + rgbToHex: function(r, g, b, a) { + // Ignore alpha, use r, g, b return this.toHex(r) + this.toHex(g) + this.toHex(b); },