We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I was wondering if there was an alternative to what seems to be an old function called blendColor() that was available in processsing 1. If there isn't, how can I replicate it's function of blending two colors together with a blendmode parameter? Thanks for any advice!
Answers
https://processing.org/reference/blend_.html
https://processing.org/reference/tint_.html
Previous posts:
https://forum.processing.org/two/search?Search=blend
Kf
@kfrajer these two functions are fine for blending pixels, but I need to blend colors before they are drawn.
@Graywolf --
If you only need to blend two colors, you could blend() two 1x1 pixel images.
If you need to blend a small array of colors pairs (eg 5 color pairs, 10 color pairs) then store them in two 1xn color images.
If you need to blend pairs at different times and and you need a lot of them it probably doesn't make sense to create 2xn number of 1x1 pixel PImages -- at that point you would need a different solution.
You can try https://processing.org/reference/lerpColor_.html and don't forget to keep in mind what color mode you are using (and which one could be more convenient in your situatiuon.... https://processing.org/reference/colorMode_.html ) However, I think what you want is eactly what @jeremydouglass suggested and you have different blending modes available.
Kf
@jeremydouglass Thanks for the answer, it's a kind of hacky solution but I guess that's what happens when the remove a good feature. Thank you!
Glad it helped.
I'm not sure whether the old blendColor code can be found in previous github release versions, or if it is still available but undocumented, or only accessible through a PImage instance...? Possibly relevant:
https://github.com/processing/processing/search?utf8=✓&q=blendColor
@Graywolf --
Out of curiousity, I just tried using
blendColor()
in a sketch, and it works just fine -- even if it isn't in the reference.Here it is in the source code:
Here is a one-line sketch that sets the background to the EXCLUSION of red and blue:
Here's a full demo sketch that cycles through all the modes.
@jeremydouglass hmm, it didn't seem to work when I tried it but I'll try again, thanks for noticing!
Also note that my example was tested on Processing 3.2.3 -- if it doesn't work, check your version. The one-liner should be a good simple test sketch.