# Lines spin animation

hi! who knows why my lines are distorted after a few seconds after running, even if from the beginning everything works correctly? Thank you in advance

``````float a,b;
void setup() {
size(100,100);
frameRate= 30;
}

void draw() {
background(255);
line(0, a, width, a); //sus orizontal
a = a+1;
if (a>height) {
a = 0; }

line(0,b,width,b);//jos orizontal
b=b-1;
if(b<0){
b=100;}

line (a,0,a,height);//st
a=a+1;
if(a>width){
a=0;
}
line(b,0,b,height);//dr
b=b-1;
if(b>width){
b=100;}

line(a,0,width,a);
line(width,a,b,height);
line(b,height,0,b);
line(0,b,a,0);

}
``````

a and b are both duplicates.

Maybe this is distorting things?

1 Like

This will not change the frameRate:

Try using 4 variables for each side; you may then see opportunities to simplify such as common variables (counters).

One you have progressed consider just one variable:

``````int a;

void setup()
{
size(300, 300);
}

void draw()
{
background(255);

if (a>height)
{
a = 0;
}

strokeWeight(20);
stroke(255, 0, 0);

// 4 points
point(a, 0);
point(width-a, height);  // Goes the other way!

// 4 lines `:)`