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
controlP5 sliders (Read 1009 times)
controlP5 sliders
Sep 15th, 2008, 6:35am
 
Hi,

Is there any way I can read the values from multiple sliders
and use those values in different ways? For example taking
the value from slider A to make different different pictures
appear at certain value ranges, while also taking the value
from slider B and doing something completely different?
Re: controlP5 sliders
Reply #1 - Sep 15th, 2008, 8:08am
 
yes. each one can have it's own callback function, named just as the slider itself and set to receive a float value, see:

Code:

import controlP5.*;

ControlP5 cp5;

void setup ()
{
size( 300, 300 );
cp5 = new ControlP5( this );
cp5.addSlider( "slider1", 0, 100, 50, 0, 0, width, 20 );
cp5.addSlider( "slider2", 0, 100, 50, 0, 20, width, 20 );
}

void draw ()
{

}

void slider1 ( float value )
{
// put code for slider 1 here
println( "1 " + value );
}

void slider2 ( float value )
{
// put code for slider 2 here ..
println( "2 " + value );
}


F
Re: controlP5 sliders
Reply #2 - Sep 15th, 2008, 8:50am
 
Thank you! This will most certainly solve a lot of headache(hopefully Wink )!


Edit: When I move the slider up and down, the values that are shown on the side of each slider don't disappear...?
Page Index Toggle Pages: 1