## bilinear interpolation of colors?

Nov 02 2013 | 3:12 am
This shouldn't be difficult but... :(
How do I create four-color gradient matrices of variable dimension with custom colors at each corner? I ideally I would like to use expressions to achieve this, though my understanding of jitter and jit.expr is limited.
At some point I would also like to apply curves to the gradients so I'm not limited to linear interpolation.. as well as selecting specific cells in the matrix as interpolation points (not just the corners).
Thoughts? This is kinda what I'm talking about...
-

• Nov 02 2013 | 4:35 am
I believe we have parallel lives--
here is something I did a little while back: save this as bilinear_interpolator
then use this parent patch:
note the args are col, row dim for target matrix.
for some reason it kludges out on my machine if the dims are more than about 15*15-- something to do with using the uzis I suspect. Anyway I've since done a much more efficient jit.pix version which I can post if you want.
• Nov 02 2013 | 4:47 am
In jit.expr I think the main factors you'll want to consider are norm[] which gives you a value from 0 to 1 across a particular dimension, and in[] which gives you the value of the cells of the matrix coming in each inlet.
• Nov 02 2013 | 7:05 am
something I prepared earlier....
this is about twenty times slower than my previous method using lists with uzi. the jit.gen method is another order of magnitude faster again.
• Nov 02 2013 | 7:23 am
and here is the most efficient using jit.gen
• Nov 03 2013 | 12:02 am
You guys are awesome. I need to get my head around jit.expr.. particularly the in[] operator. I have been going in and out of matrices with spill and fill to combine jitter expressions into a single matrix... :/ Good to know that there's an easier way. :)
I'm still looking for more control of the gradients. I'll post some examples in a bit.
And thanks!