Sign in to follow this  

programming layer blend modes

Recommended Posts

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 scalars This is the algorithm: A - foreground RGB B - background RGB C - composite RGB vectors tonal values are normalized as such 1 = 255/255 ...scalar There are three conditional statements in the algorithm if(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 help Nikos

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this