Slider
- description
- a slider is either used horizontally or vertically. when adding a slider to controlP5, the width is compared versus the height. width is bigger, you get a horizontal slider, height is bigger, you get a vertical slider. a slider can have a fixed slide controller (one end of the slider is fixed to the left or bottom side of the controller), or a flexible slide control (a knob that you can drag).
- +Example
import controlP5.*; ControlP5 controlP5; int myColorBackground = color(0,0,0); int sliderValue = 100; void setup() { size(400,400); controlP5 = new ControlP5(this); Slider s = controlP5.addSlider("slider",100,167,128,100,160,10,100); s = controlP5.addSlider("sliderValue",0,255,128,200,200,10,100); } void draw() { background(myColorBackground); fill(sliderValue); rect(0,0,width,100); } void slider(float theColor) { myColorBackground = color(theColor); println("a slider event. setting background to "+theColor); }
- constructors
- Methods
- setHeight ( )
- set the height of the slider.
- setMax ( )
- set the maximum value of the slider.
- setMin ( )
- set the minimum value of the slider.
- setSliderMode ( )
- use the slider mode to set the mode of the slider bar, which can be Slider.FLEXIBLE or Slider.FIX
- setValue ( )
- set the value of the slider.
- setWidth ( )
- set the width of the slider.
- usage
- Web & Application
- related