# Bergen's Grid Illusion - wonky order of execution

**URL:** <https://discourse.processing.org/t/bergens-grid-illusion-wonky-order-of-execution/40505>\
**Category:** Coding Questions\
**Created:** [January 8, 2023, 1:56am UTC](https://discourse.processing.org/t/bergens-grid-illusion-wonky-order-of-execution/40505 "2023-01-08T01:56:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JonnieNightTime](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@JonnieNightTime](https://discourse.processing.org/u/JonnieNightTime)\
**Post date:** [January 8, 2023, 1:56am UTC](https://discourse.processing.org/t/bergens-grid-illusion-wonky-order-of-execution/40505/1 "2023-01-08T01:56:22Z")

</div>

hi All, I’m doing something wrong here - the grey “axles” should be behind the white ellipses, not the other way around as they are here - I’ve spent a couple of hours moving around code, but just can’t fix it - duhh!

```auto
float MinRadius = 380;
float MaxRadius = 860;
int NumConcentricRings = 10;

void setup(){
  size(900,900);
  noLoop();
}

void draw(){
  background(0);
  rectMode(CENTER);
  
  translate(width/2, height/2);
  
  float rStep = 60;
  
  for( float r = MinRadius; r <= MaxRadius; r +=rStep){
    
    noFill();
    stroke(123);
    strokeWeight(NumConcentricRings *0.2);
    ellipse (0, 0, r, r); // concen rings

    NumConcentricRings +=1;

  for (float a = 0; a < 360; a+=15){
   
    pushMatrix();
    rotate(radians(a));
    strokeWeight(4);
    stroke(127);
    line (MinRadius *0.5, 0, MaxRadius *0.5, 0); // axles
  
    fill(255);
    noStroke();
    ellipse(r *0.5, 0, NumConcentricRings *1.3, NumConcentricRings *1.3); //white circles
    popMatrix();
    }
  } 
  }
```

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [January 8, 2023, 3:15am UTC](https://discourse.processing.org/t/bergens-grid-illusion-wonky-order-of-execution/40505/2 "2023-01-08T03:15:54Z")

</div>

It seems you are drawing the axles in the for loops so its overriding the data from the previous loop, i moved the axle drawings out of the loops by commenting them out and put them in their own for loop before the main loops, hope that helps

```auto
float MinRadius = 380;
float MaxRadius = 860;
int NumConcentricRings = 10;

void setup() {
  size(900, 900);
  noLoop();
}

void draw() {
  background(0);
  rectMode(CENTER);

  translate(width/2, height/2);

  float rStep = 60;

  //ADDED THE AXLES HERE INSTEAD
  for (float a = 0; a < 360; a+=15) {
    pushMatrix();
    rotate(radians(a));
    strokeWeight(4);
    stroke(127);
    line (MinRadius *0.5, 0, MaxRadius *0.5, 0); // axles
    popMatrix();
  }

  for ( float r = MinRadius; r <= MaxRadius; r +=rStep) {

    noFill();
    stroke(123);
    strokeWeight(NumConcentricRings *0.2);
    ellipse (0, 0, r, r); // concen rings

    NumConcentricRings +=1;

    for (float a = 0; a < 360; a+=15) {

      pushMatrix();
      rotate(radians(a));
      //strokeWeight(4);
      //stroke(127);
      //line (MinRadius *0.5, 0, MaxRadius *0.5, 0); // axles

      fill(255);
      noStroke();
      ellipse(r *0.5, 0, NumConcentricRings *1.3, NumConcentricRings *1.3); //white circles
      popMatrix();
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![JonnieNightTime](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@JonnieNightTime](https://discourse.processing.org/u/JonnieNightTime)\
**Post date:** [January 8, 2023, 12:03pm UTC](https://discourse.processing.org/t/bergens-grid-illusion-wonky-order-of-execution/40505/3 "2023-01-08T12:03:42Z")

</div>

Thanks Mikey83 - that’s it! Lovely, many thanks. I learned something there, cheers.

 ![BergensGrid](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/6/76e5dc04c6b9215559951df93ae46d58e71c3041.png)
