Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barrylachapelle/cdd166ec55d38eed8f3f194373e10800 to your computer and use it in GitHub Desktop.
Save barrylachapelle/cdd166ec55d38eed8f3f194373e10800 to your computer and use it in GitHub Desktop.
openframeworks > string to RGB
void ofApp::stringtocolor(string convertstring){
int hash = std::hash<std::string>()(convertstring);
int r = (hash & 0xFF0000) >> 16;
int g = (hash & 0x00FF00) >> 8;
int b = hash & 0x0000FF;
cout << r << "| "<< g << "| " << b << endl;
}
stringtocolor("thisstring");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment