HEX to RGB?

May 26, 2010 at 2:55am

HEX to RGB?

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

#50561
May 26, 2010 at 5:18pm

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.

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.

– Pasted Max Patch, click to expand. –
#181389
May 28, 2010 at 2:03am

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

#181390

You must be logged in to reply to this topic.