Tv PixelMatrix

From TVPaintWiki
Jump to: navigation, search

<<<George<<<Command Reference<<<<Drawing Functions


tv_pixelmatrix  r1 g1 b1 a1 k1   r2 g2 b2 a2 k2    r3 g3 b3 a3 k3    r4 g4 b4 a4 k4 [unmultiply mode]

if(unmultiply Mode)r = R/A*255, g = G/A*255, b=B/A*255, a=A -> r = r*r1 + g*g1 + b*b1 + a*a1 + k1 -> g = r*r2 + g*g2 + b*b2 + a*a2 + k2 -> b = r*r3 + g*g3 + b*b3 + a*a3 + k3 -> a = r*r4 + g*g4 + b*b4 + a*a4 + k4

if(unmultiply mode)r = R*A/255, g = G*A/255, b=B*A/255, a = A

Eric Scholl Explains

Here is how it basically works :

you have 4 groups : R G B A

In each group, you have 5 numbers : r g b a k

The 4 firsts numbers are factors which determines how much the channel of the current color will impact on the final channel.

For example, if in my pixel I want to use the value of the blue channel as the value of the red, I'll do this in the first group (R):


    R
r g b a k
0 0 1 0 0


If I want a channel to keep the same value, I'll do this :

    R
r g b a k
1 0 0 0 0


So in my example, if I only want to change the red value, I need to do this:

    R              G              B             A
r g b a k      r g b a k      r g b a k     r g b a k
0 0 1 0 0      0 1 0 0 0      0 0 1 0 0     0 0 0 1 0



The 'k' value is constant which is added to the result. Second example, let's say I have these color values :

R = 255    G = 100   B = 255    A = 255


I want the red to have the green value + 50, so I do this :


    R
r g b a k
0 1 0 0 50


And if I want the red to have the green value - 50, I do this :

    R
r g b a k
0 1 0 0 -50


Here's my complete sequence for the second example :

CODE: SELECT ALL

    R            G              B             A
r g b a k    r g b a k      r g b a k     r g b a k
0 1 0 0 50   0 1 0 0 0      0 0 1 0 0     0 0 0 1 0


The result will be :

R = 150    G = 100   B = 255    A = 255