# Problem with this triangle that keeps randomly changing size

**URL:** <https://discourse.processing.org/t/problem-with-this-triangle-that-keeps-randomly-changing-size/7232>\
**Category:** Coding Questions\
**Created:** [January 5, 2019, 9:15pm UTC](https://discourse.processing.org/t/problem-with-this-triangle-that-keeps-randomly-changing-size/7232 "2019-01-05T21:15:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![francium401](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@francium401](https://discourse.processing.org/u/francium401)\
**Post date:** [January 5, 2019, 9:15pm UTC](https://discourse.processing.org/t/problem-with-this-triangle-that-keeps-randomly-changing-size/7232/1 "2019-01-05T21:15:36Z")

</div>

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)

```auto
flake[] flake = new flake[30];

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);
 
}

```

```auto
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);
  }
  
}

```

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [January 5, 2019, 9:48pm UTC](https://discourse.processing.org/t/problem-with-this-triangle-that-keeps-randomly-changing-size/7232/3 "2019-01-05T21:48:39Z")

</div>

> [@francium401](#):
>
> strokeWeight(size);

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:

```auto
Flake[] flake = new Flakes[30];

```
