Hi, i want to make a code that allows me to control the number of lines, the width, and other parameters beacuse im planing to import this code to resolume arena later. This is what i have so far. I made an animation of what i want to achive. Thanks in anvance!
Linea[] lineas = new Linea[100];
int posX;
int limiteUp;
int limiteDown;
int separacionLineas;
int i;
int var1;
void setup() {
size (1080, 720);
for ( int i =0; i<29; i++) {
lineas[i] = new Linea();
}
posX = 0;
limiteUp = height*50/100;
limiteDown = height;
separacionLineas = 38;
var1 =0;
}
void draw() {
background(0);
stroke(255);
strokeWeight(3);
// float posY = ;
for ( i =1; i<29; i++) {
lineas[i].display(posX+i*separacionLineas, limiteUp, limiteDown-i*var1);
}
var1++;
delay(50);
}
i have achived what i wanted but now i have another problem. I want variable “vara1” to control the speed of the lines. but if i change it to 2, for example, every other lines gets out of fase. if i change it to 3, one every 3 lines gets out of fase, etc. i have no idea how to fix this problem. ill upload the code and an image of this out of fase problem
I got it to work with this modification to your code:
void display()
{
//stroke(255);
//strokeWeight(3);
float offset = 0 ; // <-- Do some math here with vara1 and diff1 to make this work
if (state)
line (posXa, posYa, posXa, posYb - offset);
else
line (posXa, posYa, posXa, posYb);
}
void move()
{
if (posYb <= 0)
{
vara1 = -vara1;
//println("1", posYb);
diff1 = abs(posYb);
println("1", diff1);
state = true;
}
if (posYb > height)
{
vara1 = -vara1;
//println("2 ", posYb);
diff2 = abs(height-posYb);
println("2 ", diff2);
state = false;
}
posYb = posYb - vara1;
}
This is only an exploration into your code; I saw patterns and was able to modify it to work.
I set the offset to 0; you will have to modify this yourself.
Take a look at the outputs of the print and see if you can determine why it is behaving as it does and determine an offset that works.
I would rework this from a fresh perspective; the above works and is over complicated. I saw patterns right away and did this as an exercise only.