sojamo / controlp5

A gui library for processing.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integers and not Floats

luisarandas opened this issue · comments

Hi!
I have an issue that you might be able to fix
I am controlling an interface with the CP5.Slider and I get like 20.34872 Beats per minute
Is there a way to truncate this to integers? Or just one decimal case?
Here is the slider creation:

public void sliderBpm(){
CP5.addSlider("SLIDER_BPM")
.setValue(0)
.setSliderMode(0)
.setPosition(146,95)
.setMin(20)
.setMax(315)
.setColorActive(color(38, 160, 180))
.setColorBackground(color(157, 30, 139))
.setColorForeground(color(38, 160, 180))
.setSize(809, 20)
.setLabelVisible(false)
.setId(1)
}

public void SLIDER_BPM(int theValue) {
BPM = theValue;
}

[being BPM global]

Best regards Luis

Hi,
the following returns and displays the slider label as an integer for me:

// using ControlP5 library version  2.2.6
// installed via Library Manager 
// (Sketch → Import Library → Add Library ...) 

import controlP5.*;

int BPM;
ControlP5 cp5;

void setup() {
  size(1024,400);
  cp5 = new ControlP5(this);
  sliderBpm();
}

void draw(){
}

public void sliderBpm() {
  cp5.addSlider("SLIDER_BPM")
    .setValue(0)
    .setSliderMode(0)
    .setPosition(146, 95)
    .setMin(20)
    .setMax(315)
    .setColorActive(color(38, 160, 180))
    .setColorBackground(color(157, 30, 139))
    .setColorForeground(color(38, 160, 180))
    .setSize(809, 20)
    //.setLabelVisible(false)
    .setId(1);
}

public void SLIDER_BPM(int theValue) {
  BPM = theValue;
  println(theValue, BPM);
}

Thank you very much!