# programming layer blend modes

This topic is 3968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633294
• Total Posts
3011241
• ### Who's Online (See full list)

There are no registered users currently online

×