That’s what i needed !!!
Thanks a lot.
Now if I just could have “accents” on the words/labels (Òrbita, etc…)
I paste the updated code, just to see if the button thing can work from the start…
For better “smoothness” what do you reccomend me: smooth() or hint(ENABLE_STROKE_PURE)
I really can’t see the difference
Also tell me what do you think about the experiment.
The video that inspired me to do it is this one:
import controlP5.*;
ControlP5 cp5;
Textlabel titol01;
int myColor = color(0,0,0);
Slider abc;
PVector center;
float as, bs, ax, ay, bx, by, ra, rb, sa, sb, in, velg;
color BGcolor; // the background color
boolean ClearBG; // clear the background on each frame?
void setup() {
size(900, 900);
center = new PVector(width/2, (height/2)+50);
ra = dist(15, 15, 250, 250);
rb = dist(15, 15, 150, 150);
sa = 7; // speed planet A
sb = 12; // speed planet B
BGcolor = color(10, 10, 10); // background color
ClearBG = true; // don't clear background on each frame
background(BGcolor);
cp5 = new ControlP5(this);
// change the original colors
cp5.setColorForeground(#006000);
cp5.setColorBackground(#002000);
cp5.setColorActive(#00AA00);
titol01 = cp5.addTextlabel("titol01")
.setText("Dibuixos Orbitals")
.setPosition(400,10)
.setColorValue(#00dd00)
;
cp5.addSlider("velg")
.setPosition(50,30)
.setSize(200,20)
.setRange(1,50)
.setNumberOfTickMarks(50)
.setValue(25)
.setLabel("Velocitat Global")
;
cp5.addSlider("sa")
.setPosition(50,70)
.setSize(200,20)
.setRange(1,25)
.setNumberOfTickMarks(25)
.setValue(7)
.setLabel("Velocitat Planeta A")
;
cp5.addSlider("sb")
.setPosition(50,110)
.setSize(200,20)
.setRange(1,25)
.setNumberOfTickMarks(25)
.setValue(12)
.setLabel("Velocitat Planeta B")
;
cp5.addButton("PremB")
.setValue(0)
.setPosition(50, 150)
.setSize(200, 20)
.setLabel("Prem B per netejar el dibuix")
;
cp5.addSlider("in")
.setPosition(550,30)
.setSize(200,20)
.setRange(1,100)
.setValue(50)
.setLabel("Intensitat dibuix")
;
cp5.addSlider("ra")
.setPosition(550,70)
.setSize(200,20)
.setRange(5,350)
.setValue(250)
.setLabel("Orbita Planeta A")
;
cp5.addSlider("rb")
.setPosition(550,110)
.setSize(200,20)
.setRange(5,250)
.setValue(150)
.setLabel("Orbita Planeta B")
;
ellipseMode(RADIUS);
}
void draw() {
if (ClearBG) background(BGcolor);
//hint(ENABLE_STROKE_PURE);
smooth();
stroke(0, 120, 0, in);
float ax = center.x + cos(as)*ra;
float ay = center.y + sin(as)*ra;
float bx = center.x + cos(bs)*rb;
float by = center.y + sin(bs)*rb;
//draw the traveling planets
// ellipse(ax, ay, 1, 1);
// ellipse(bx, by, 1, 1);
line (ax, ay, bx, by);
as += PI/(sa*(51-velg));
bs += PI/(sb*(51-velg));
}
void PremB() {
ClearBG = !ClearBG; // toggle clearing the background
}
Thanks a lot again !!