Forums > MaxMSP

What number is red?

March 3, 2014 | 4:00 am

Hi,

I’m trying to design a patch where the colour swatch position assigns a number. I’ve attached the patch, and would love some help with it please.

cheers,

J

 

<code>

– Pasted Max Patch, click to expand. –

</code>

 


March 4, 2014 | 1:12 am

bump :)


March 4, 2014 | 1:46 am

have a look at jit.colorspace, after doing the conversion from rgb to hls, you’ll need to unpack and then scale the h value to the range you want


March 4, 2014 | 6:35 am

could I get an example please? Finding it complex to get head ’round.


March 4, 2014 | 2:56 pm

examples are in the relevant help files:
jit.colorspace
unpack
scale


March 5, 2014 | 1:27 am

Hi,

Thanks for pointing me to the helpfiles. Though. having trouble adapting them to my patch idea.. its a little beyond my grasp. Any examples or tweaks of my original patch would be really appreciated.


March 6, 2014 | 12:54 am

The number of red? That depends on the flavor of Thursday and the time of corduroy. But if you’re just looking for the broad stroke, red primary is the first value of RGB of which the purest expression is 255 0 0, normalized as 1 0 0. But if you want just a number, then it would be 16,711,680 or 111111110000000000000000 binary. Unless you stick with hue, in which case it’s 0.

Here is the simplest way I know to get your patching going…

– Pasted Max Patch, click to expand. –

March 6, 2014 | 1:18 am

If you have to use the actual output of swatch, you can convert RGB to hue and scale it to your index range. But the standard color conversion objects in max kinda suck (with the glorious exception of rgb2hsl and hsl2rgb in jit.pix). Here’s an rgb to hue patch that uses standard max objects and outputs accurate values.

– Pasted Max Patch, click to expand. –

March 10, 2014 | 5:46 am

Cool thanks for the examples metamix- Really useful!


Viewing 9 posts - 1 through 9 (of 9 total)