Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * hexToCGColor(hex) : takes hexadecimal string as input, like CSS/HTML color value #ffffff
- * and translate it to a ComputerGraphics color array [1,1,1] that is suitable
- * for managing materials from cg standard software (ie.Blender)
- *
- * no alpha channel parsing
- */
- function hexToCGColor(hex) {
- //cut out #
- splitted = hex.substr(1);
- //retrieving rgb values
- r = parseInt(splitted.slice(0, 2), 16) / 255;
- g = parseInt(splitted.slice(2, 4), 16) / 255;
- b = parseInt(splitted.slice(4, 6), 16) / 255;
- cgcolor = [r, g, b];
- return (cgcolor);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement