We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
blend modes request (Read 473 times)
blend modes request
Dec 17th, 2006, 10:22pm
 
This is sort of re: bug 132 finish blending modes, but would be an addition, so posted here instead.

How about a user-defined blending mode?  Apologies if you've already considered this and ruled it out. (I searched the forum but didn't find anything)

You'd need to put a stub for it in PApplet so users could override it

public int blend_user(color c1, color c2) {
 // just REPLACE or some other simple default behavior
 return c2;
}

and add a constant for it, and all the relevant switch cases in PImage.

The next question would be:  Is one user-specified mode enough?  I think it should be.  The clever user would implement their own blend sub-mode variable and put a switch inside their own blend_user() routine if they wanted multiple user-defined modes.

I'd even offer to write a sample for example/reference docs, if that'd help.

I guess the alternative implementation would be an interface (PBlendFunction or something with only "int blend(int a, int b)") and a reference to the user's class in PApplet, then they could swap classes as desired for multiple modes -- but that's probably a bit hairy for the intended audience?

Anyway, thanks for reading.  Smiley
Page Index Toggle Pages: 1