HEX to RGB?

pierrepblais's icon

So I'm back with a related question to my last post, thanks to your help I managed to extract the HEX values of colour swatches from the Kuler API rss feed, but now I need to convert it to rgb if I want to use this in my work... any thoughts? I thought for sure jitter or Max would have an object for that, but if it has I haven't found it yet... I'm sure I could create a little module to do the conversion manually, but sadly I learned Hex code a long time ago in my intro to music programming course, and I don't really remember that part of the course so well, plus I'm sure there's an easier way out there ;)

P

Rob Ramirez's icon

there is no object for this. like most things in max, there are several ways to achieve this with existing objects. javascript might be the cleanest solution.

Max Patch
Copy patch and select New From Clipboard in Max.

here is one that uses regexp to split up each of the hex characters, zl slice to group them into rgb, route to determine if it's an int or letter, atoi to convert letters to numbers, and simple math to do the rest.

pierrepblais's icon

Thanks, this as proved very useful! its good to know we can always turn to the max community for help.