From 1cefb0d7a6de05e9b25aff9b9496d09f592044fc Mon Sep 17 00:00:00 2001 From: geosogel Date: Tue, 19 May 2020 11:12:14 +0200 Subject: [PATCH] Update rgb2hex.min.js Alpha values 1.0, 1.00, ... are parsed correctly --- rgb2hex.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rgb2hex.min.js b/rgb2hex.min.js index fd02b6e..fd1e41b 100644 --- a/rgb2hex.min.js +++ b/rgb2hex.min.js @@ -1 +1 @@ -!function(r){var e=function(r){if("string"!=typeof r)throw new Error("color has to be type of `string`");if("#"===r.substr(0,1))return{hex:r,alpha:1};var e=r.replace(/\s+/g,""),t=/(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|0??\.([0-9]{0,})))??\)/.exec(e);if(!t)throw new Error("given color ("+r+") isn't a valid rgb or rgba color");var n=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),i=t[6]?/([0-9\.]+)/.exec(t[6])[0]:"1",s=(a|o<<8|n<<16|1<<24).toString(16).slice(1);return"."===i.substr(0,1)&&(i=parseFloat("0"+i)),1