Last active
August 29, 2015 14:22
-
-
Save paulhayes/9b817f142dbff4655c7b to your computer and use it in GitHub Desktop.
Converts 24bit colour value to I Ching unicode representation ;)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colorToIChing = function(value){ | |
r=function(n,r,i){for(;3-i++;r=r*2|n&1,n>>=1);return r;}; | |
var s=''; | |
for(var i=0;i<8;i++){ | |
s=String.fromCharCode(9776+r(7&(value>>(i*3)),0,0))+s; | |
} | |
return s; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colorToIChing = function(value){ var s=''; for(var i=0;i<8;i++) s=String.fromCharCode(9776+(function(n,r,i){for(;3-i++;r=r*2|n&1,n>>=1);return r;})(7&(value>>(i*3)),0,0))+s; return s; }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment