diff options
Diffstat (limited to 'dist/js/colors.js')
-rwxr-xr-x | dist/js/colors.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/dist/js/colors.js b/dist/js/colors.js new file mode 100755 index 0000000..057b0c9 --- /dev/null +++ b/dist/js/colors.js @@ -0,0 +1,10 @@ + +function linMap(c,mn,mx){return c*(mx-mn)+mn;} +function getDecimal(n){return(n-Math.floor(n));} +function mapColorPalete(c,palete){let poz=c*(palete.length-1);let col1=palete[Math.floor(poz)];let col2=palete[Math.ceil(poz)];return(Math.floor(linMap(getDecimal(poz),col1[0],col2[0])).toString(16).padStart(2,0)+ +Math.floor(linMap(getDecimal(poz),col1[1],col2[1])).toString(16).padStart(2,0)+ +Math.floor(linMap(getDecimal(poz),col1[2],col2[2])).toString(16).padStart(2,0)).toUpperCase();} +function intToRGB(i,palete=null){if(palete==null){var c=(i&0x00FFFFFF).toString(16).toUpperCase();return"00000".substring(0,6-c.length)+c;}else return mapColorPalete((i&0xFF)/0xFF,palete);} +function getHexColorFromString(str){if(urnikTheme=="privzeta") +return"#"+intToRGB(hashCode(str));else +return"#"+intToRGB(hashCode(str),[[38,70,83],[42,157,143],[233,196,106],[244,162,97],[231,111,81]]);}
\ No newline at end of file |