# Problem with this triangle that keeps randomly changing size

I’m only guessing that it has something to do with the fact that the moving circles are changing size, that it somehow makes the triangle do so as well.
How would I go about keeping the triangle at a fixed size? (917, y, 950, y-15, 950, y+15)

``````flake[] flake = new flake;

float speed = 10;
int x, y;

void setup(){
size(1000,800);
for(int i = 0; i < flake.length; i++){
flake[i] = new flake();
}
}

void draw(){
background(50);
x = mouseX;
y = mouseY;

display();

for(int i = 0; i < flake.length; i++){
flake[i].show();
flake[i].update();
}

}

void display() {
fill(0,255,0);
triangle(917, y, 950, y-15, 950, y+15);

}
``````
``````class flake{
float y=random(height);
float x=random(-width);

float z = random(20, 100);
float size=map(z, 1, 30, 3, 20);
float speed=map(z, 1, 30, 0.1, 1);

void show(){
stroke(255);
strokeWeight(size);
point(x,y);
}

void update() {
x+=speed;

if(x>width) reset();
}

void reset(){
y = random(height);
x = random(-width,0);
z = random(20,100);
size=map(z,1,29,3,30);
speed=map(z,1,29,0.1,1);
}

}
``````
2 Likes

In the `show()` method of the flake class you set the size of the flake using `strokeWeight()`. So it’s still using whatever the previous stroke weight was when you draw the triangle. Try including `noStroke()` before drawing the triangle and it should fix the problem.

As a side note it’s generally good practice to use capital letters at the beginning of your class name to make it clear what is a class and what is a variable. It also makes for more readable code. Like:

``````Flake[] flake = new Flakes;
``````
3 Likes