   programming layer blend modes
  Hi I am programming the pin light blend mode found in photoshop.  What the transfer mode does is pretty much compare 2 pixels and keep the darker one.Im not sure how to convert and compare vectors with scalarsThis is the algorithm:A - foreground RGBB - background RGBC - composite RGB vectorstonal values are normalized as such1 = 255/255 ...scalarThere are three conditional statements in the algorithmif(B < 2 * A - 1){C = 2 * A - 1;// the 1 in the equation is throwing me off}else if (  ( B > 2 * A - 1 )    &&    ( B < 2 * A )  ){C = B;}else if ( B > 2 * A ){C = 2 * A;}How do I convert RGB values, which are vectors, to tonal values which are scalars?  2 * vector gives you a result vector.  How do I subtract 1 from a result vector?  Do I subtract 1 from each element or from the magnitude of the result vector?... I'm not sure.  or is 1 the magnitude of the vector which has to be subtracted from the result vector.The second statement compares which vector is greater ( B < 2*A ).  Is it comparing the magnitudes of the vectors?Please helpNikos   