Hello community
I want to increase the slider movements in variable steps und schau/see also this increments. For example from start-position 0 to end-position 60, the slider should move in one steps: 0, 0+1, 2…59, 60. The is what i want to achieve:
- The movement of the sliders should be updated after every step (show/see the increments)
- The sliders should move simultaneously
Well im new in Processing and i have basic programming knowledge, but please don t be afraid to suggest advanced solutions so that i can learn more :-).
With a for loop i made the sliders move in +1 steps but i can NOT make them move simultaneously. that s why i tried to solve this with a Class. But now nothing work.This is the part of the code with the described probleb:
import g4p_controls.*;
SdrDance Dance1;
SdrDance Dance2;
GCustomSlider sdr1,sdr2;
GButton Dance;
int StartPos, EndPos, EndPos1, EndPos2, speed1, speed2;
void setup(){
size(400,200);
GUI();
}
void draw(){
background (180);
}
public void Dance_click1(GButton source, GEvent event) {
speed1 = 1;
speed2 = 2;
EndPos1 = 60;
EndPos2 = 60;
Dance1 = new SdrDance(sdr1.getValueI(),EndPos1, speed1);
Dance2 = new SdrDance(sdr2.getValueI(),EndPos2, speed2);
Dance1.move(); // i can t see the increment of the slider --> just jumping from startposition to the endposition
Dance2.move(); // Slider should move also simultaneously --> is it not possible to check it at the moment becouse no increment
}
//*****Class
class SdrDance {
int StartPos;
int EndPos;
int speed;
SdrDance (int x_, int y_, int z_) {
StartPos= x_;
EndPos =y_;
speed = z_;
}
void move(){
while (StartPos <= EndPos) {
sdr1.setValue(StartPos);
sdr2.setValue(StartPos);
println(StartPos);
StartPos = StartPos + speed;
}
while (StartPos >= EndPos) {
sdr1.setValue(StartPos);
sdr2.setValue(StartPos);
println(StartPos);
StartPos = StartPos - speed;
}
}
}
//******GUI
void GUI(){
sdr1 = new GCustomSlider(this, 100, 60, 200, 33);
sdr1.setShowValue(true);
sdr1.setLimits(5, 0, 180);
sdr1.addEventHandler(this, "sdr1_change1");
sdr2 = new GCustomSlider(this, 100, 120, 200, 33);
sdr2.setShowValue(true);
sdr2.setLimits(5, 0, 180);
sdr2.addEventHandler(this, "sdr2_change1");
Dance = new GButton(this, 175,15, 55, 25);
Dance.setText("Dance");
Dance.addEventHandler(this, "Dance_click1");
}
public void sdr1_change1(GCustomSlider source, GEvent event) {
}
public void sdr2_change1(GCustomSlider source, GEvent event) {
}
public void handleSliderEvents(GValueControl slider, GEvent event) {
}
as you can see, the sliders just jump from start position to the end and the don t move simultaneously. How wold you solve this? is there already an example in the forum?
Thank you so much for any help