Files
enviPy-bayer/static/js/ketcher2/node_modules/rgb2hex/rgb2hex.min.js
2025-06-23 20:13:54 +02:00

1 line
734 B
JavaScript

(function(b){var a=function(d){if(typeof d!=="string"){throw new Error("color has to be type of `string`")}else{if(d.substr(0,1)==="#"){return{hex:d,alpha:1}}}var g=/(.*?)rgb(a)*\((\d+),(\d+),(\d+)(,[0-9]*\.*[0-9]+)*\)/.exec(d.replace(/\s+/g,""));if(!g){throw new Error("given color ("+d+") isn't a valid rgb or rgba color")}var i=parseInt(g[3]);var f=parseInt(g[4]);var c=parseInt(g[5]);var h=g[6]?/([0-9\.]+)/.exec(g[6])[0]:"1";var e=((c|f<<8|i<<16)|1<<24).toString(16).slice(1);if(h.substr(0,1)==="."){h=parseFloat("0"+h,10)}if(h>1){h=1}h=parseFloat(Math.round(h*100),10)/100;return{hex:g[1]+"#"+e.toString(16),alpha:h}};if(typeof define==="function"&&define.amd){define("rgb2hex",function(){return a})}else{b.rgb2hex=a}}(window));