# Ghost Lines Appearing After some iterations

**URL:** <https://discourse.processing.org/t/ghost-lines-appearing-after-some-iterations/3450>\
**Category:** Coding Questions\
**Created:** [September 11, 2018, 2:46am UTC](https://discourse.processing.org/t/ghost-lines-appearing-after-some-iterations/3450 "2018-09-11T02:46:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeyj777](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mikeyj777](https://discourse.processing.org/u/mikeyj777)\
**Post date:** [September 11, 2018, 2:46am UTC](https://discourse.processing.org/t/ghost-lines-appearing-after-some-iterations/3450/1 "2018-09-11T02:46:58Z")

</div>

I’m new to Processing, and am trying a short script to become familiar with it. The script draws and bisects right triangles. It works ok, but after the 5th iteration, it starts to print an extra line, and I can’t seem to find any reason why in the code. The code will draw the new triangle and then a line to a distant point.

I understand there may be other shape functions. I just simply wanted to use the line function for this.

Here’s the code. Could someone tell me if I’m approaching this incorrectly:

```
float x1 = 0;
float y1 = 0;
float x2 = 500;
float y2 = 500;
float x3 = 0;
float y3 = 500;

int count = 0;

int mag = 2;

void setup() {
  size(600, 600);
  background(255);

}

void drawline() {

  line(x1,y1,x2,x2);
  line(x2,y2,x3,y3);
  line(x3,y3,x1,y1);
  
}

void nextpoints() {

  float x3new = (x2 + x1) / 2;
  float y3new = (y2 + y1) / 2;
  
  x1 = x2;
  y1 = y2;
  x2 = x3;
  y2 = y3;
  x3 = x3new;
  y3 = y3new;
  
}

void draw() {
  
  //float pwr = pow(10,mag);
   
  //int intpwr = (int) pwr;
   
  int ptsperframe = 1;
  
  count++;
  
  for (int i = 0; i < ptsperframe; i++) {
    
    drawline();
    nextpoints();
     
  }

}
```

---

<div class="post-metadata">

**Author:** ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)\
**Post date:** [September 11, 2018, 5:10am UTC](https://discourse.processing.org/t/ghost-lines-appearing-after-some-iterations/3450/2 "2018-09-11T05:10:14Z")

</div>

Could I get a screenshot?

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [September 11, 2018, 5:19am UTC](https://discourse.processing.org/t/ghost-lines-appearing-after-some-iterations/3450/3 "2018-09-11T05:19:14Z")

</div>

> [@mikeyj777](#):
>
> line(x1,y1,x2,x2);

A typo there. Fix this and it should work.

Kf
