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.
IndexProcessing DevelopmentCore,  Processing Development Environment (PDE) › add an "exclude" method to PApplet
Page Index Toggle Pages: 1
add an "exclude" method to PApplet? (Read 1398 times)
add an "exclude" method to PApplet?
Jan 6th, 2007, 8:13pm
 
perhaps these methods would be useful in PApplet? they do the inverse of the existing "constrain" method.

static public final float exclude(float amt, float low, float high){
 return ((amt < low) || (amt > high)) ? amt : (((amt - low) < (high - amt)) ? low : high);
}

static public final int exclude(int amt, int low, int high){
 return ((amt < low) || (amt > high)) ? amt : (((amt - low) < (high - amt)) ? low : high);
}
Page Index Toggle Pages: 1