Ciao a tutti, ho un problema con il movimento di una linea: non capisco perchè se io voglio una linea che si muova a dx e a sin nel mio sketch questa si muove creando dello spazio bianco?
color red = #FF0004;
color yellow = #F2F700;
color blue = #0A30FF;
color black = #000000;
color white = #FFFFFF;
float x = 300;
float y1 = 300;
float y2 = 500;
float new_x= x;
float new_y1 = y1;
float new_y2 = y2;
int w = 600;
int h = 600;
float actualLinePosition = 0;
float newLinesPosition = 0;
float speed = 2.5;
int min = 0+200;
int max = w-100;
float latoArancio = x;
float latoRosso = y1;
float latoMagenta = y2;
float latoGiallo = h-latoRosso;
float latoAzzurro = h-latoMagenta;
float latoBlu = w-latoArancio;
void settings() {
size(w, h);
}
void setup() {
background(black);
frameRate(30);
actualLinePosition = random (min, max);
newLinesPosition = random(min, max);
surface.setTitle("Mondrian");
}
void draw() {
if (actualLinePosition < newLinesPosition) {
actualLinePosition += speed;
if (actualLinePosition >= newLinesPosition) {
actualLinePosition = newLinesPosition;
newLinesPosition = random(min,max);
}
}
if (actualLinePosition > newLinesPosition) {
actualLinePosition -= speed;
if (actualLinePosition <= newLinesPosition) {
actualLinePosition = newLinesPosition;
newLinesPosition = random(min,max);
}
}
//if (new_y1 < y1) y1 = y1-speed;
//if (new_y1 > y1) y1 = y1+speed;
//if (new_y2 < y2) y2 = y2-speed;
//if (new_y2 > y2) y2 = y2+speed;
strokeWeight(13);
stroke(white);
//line(0, latoRosso, latoArancio, latoRosso);
//line(latoArancio, latoMagenta, w, latoMagenta );
line(actualLinePosition, 0, actualLinePosition, h);
}