processing / processing-docs

[Deprecated] Processing reference, examples, tutorials, and website
https://processing.org
371 stars 179 forks source link

blendMode(REPLACE): the new color alpha is in fact utilized #871

Open KrabCode opened 9 months ago

KrabCode commented 9 months ago

Issue description

The reference on blendMode() says:

REPLACE - the pixels entirely replace the others and don't utilize alpha (transparency) values

This is confusing to me, it feels like I cannot set alpha to 0 with it because the new alpha values would not be utilized according to the reference (?), but in fact I can set alpha to 0 with it. This is the desired REPLACE behavior in my opinion, it's only the reference that is confusing me. I can understand the original pixel alpha not being utilized when completely replaced, but the reference makes it seem the new alpha will not be used either.

This behavior is demonstrated here with fill(0,0) and stroke(0,0) on a foreground canvas to reveal an underlying image: https://gist.github.com/KrabCode/0335de613bbef231e7ec95ac6b60bf8f

URL(s) of affected page(s)

https://processing.org/reference/blendMode_.html

Proposed fix

REPLACE - the pixels entirely replace the others and don't utilize alpha (transparency) values of the original

KrabCode commented 9 months ago

On second thought, alpha is used as a percentage of the new color that should overwrite the old one (as the original's alpha is always 100% for the purposes of blending), so maybe a clearer way to put it would be:

REPLACE - the new pixels entirely replace the old ones, including the new alpha (transparency)