Skip to content

Instantly share code, notes, and snippets.

@paulhayes
Last active August 29, 2015 14:22
Show Gist options
  • Save paulhayes/9b817f142dbff4655c7b to your computer and use it in GitHub Desktop.
Save paulhayes/9b817f142dbff4655c7b to your computer and use it in GitHub Desktop.
Converts 24bit colour value to I Ching unicode representation ;)
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;
};
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