P5 "constrain" equivalent in ofx

What is the constrain in Processing equivalent in Openframeworks…???



I’m not sure if there is a built-in constrain method in OF, but you could easily write your own with just a few if statements like so:

float myApp::constrain(float val, float min, float max){
if(val < min){
return min;
else if(val > max){
return max
return val;

The function is called ofClamp

1 Like

Hey, thanks a lot for the reply!

Just wanted to ask if there is some equivalent table for people who are moving from p5 to ofx…

thanks in advance :slight_smile:

This might be a good place to get started.

Most of the core functions in ofx don’t carry any docs or explanation, for eg., I was trying to lookout for the explanation of ofSetVerticalSync.

Please do guide me!

Thanks in advance…