ID:2026927
 
(See the best response by Lummox JR.)
Code:
var/matrix/colorMatrix=stuff
animate(src,color=colorMatrix.matrix,3,easing=SINE_EASING)
spawn(1)
//This code doesn't work because even though its animating correctly the color is set to its final destination
//Im asking how can I get the exact value of the colorMatrix 1 second into animation?
animate(src,color=color.0)


Problem description:
This code doesn't work because even though its animating correctly the color is set to its final destination
Im asking how can I get the exact value of the colorMatrix 1 second into animation?

So like lets say im transitioning from white to red, how can I get the color matrix of all the pink hues inbetween?
You don't. The transition is an interpolation between the two colors matrices entirely on the client side. You'd have to calculate what it should be one second in yourself, you can't "get" the value out of animate.
I figured as much.

I'm pretty bad at maths so its amazing I can even comprehend matricies. Could you show me an example of how to interpolate such a sceenario?

color="#FFF"
animate(src,color="#F00",10)
//say like the 3rd frame in here.
starting value is 255, ending value is 0.

Delta is 256.

Frame delta is unknown because I don't know your framerate.

Assuming 10fps, frame delta is 255/10. 25.5

So your approximate color offset is 256/10*3, or 76.5. So you will be at 255-77, or 255,178,178, or #FFB2B2.

It's probably best to avoid whatever you are doing that requires this calculation though.
Best response
Working with regular colors like that example is pretty easy if you have the rgb values. If t is the fraction of the animation step that's passed (a value from 0 to 1), then this is the formula:

r = r1 + (r2-r1)*t
g = g1 + (g2-g1)*t
b = b1 + (b2-b1)*t

If you're interpolating matrices, it's basically a lot more lines like that one. Each matrix is a 20-value list (you can set a matrix with fewer than that, but when you read it it's always 20). Each item in the list would be interpolated just like the values above:

var/list/colormatrix = new/list(20)
for(var/i in 1 to 20)
colormatrix[i] = m1[i] + (m2[i]-m1[i]) * t

And to convert a color into a matrix:

proc/ColorToMatrix(r, g, b, a=255)
return list(r/255,0,0,0,0,g/255,0,0,0,0,b/255,0,0,0,0,a/255,0,0,0,0)

Ter's right that you probably don't want to do the interpolation yourself, though.