# Text() overlaps itself every time draw() is called no matter what

**URL:** <https://discourse.processing.org/t/text-overlaps-itself-every-time-draw-is-called-no-matter-what/23298>\
**Category:** Coding Questions\
**Created:** [August 16, 2020, 8:53pm UTC](https://discourse.processing.org/t/text-overlaps-itself-every-time-draw-is-called-no-matter-what/23298 "2020-08-16T20:53:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crysp](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Crysp](https://discourse.processing.org/u/Crysp)\
**Post date:** [August 16, 2020, 8:53pm UTC](https://discourse.processing.org/t/text-overlaps-itself-every-time-draw-is-called-no-matter-what/23298/1 "2020-08-16T20:53:37Z")

</div>

I am trying to make Conway’s Game Of Life in Processing and everything works, but I want to have a textbox that shows how many generations have passed. I opted to use the `text()` command, which looks as follows:

```auto
fill(255);
textSize(16);
text("Generation " + generations, 20, height - 15);
fill(0);

```

This does make the “Generations: x” text, but it doesn’t dissapear frame to frame, making it look like this by the ~10th frame:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8005354c3f3035232ad68d0d8485062a6b0f9ec8.png)

I tried `clear()` and setting the background to 0 at the start of each frame and that didn’t work. I even tried to draw a black rectangle over it before drawing the most recent text and that also didn’t work. I was thinking maybe it’s a text object, but that also doesn’t make sense. Any suggestions?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [August 16, 2020, 9:11pm UTC](https://discourse.processing.org/t/text-overlaps-itself-every-time-draw-is-called-no-matter-what/23298/2 "2020-08-16T21:11:39Z")

</div>

> [@Crysp](#):
>
> background to 0 at the start

when you have background to 0 at the start of draw() we shouldn’t see this.

Only when you have a **for loop** inside draw in which the text() statement appears?

---

<div class="post-metadata">

**Author:** ![Crysp](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Crysp](https://discourse.processing.org/u/Crysp)\
**Post date:** [August 16, 2020, 9:26pm UTC](https://discourse.processing.org/t/text-overlaps-itself-every-time-draw-is-called-no-matter-what/23298/3 "2020-08-16T21:26:06Z")

</div>

I honestly don’t know what quirk of code made that happen but moving it to right before the background command fixed it.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 17, 2020, 1:59am UTC](https://discourse.processing.org/t/text-overlaps-itself-every-time-draw-is-called-no-matter-what/23298/4 "2020-08-17T01:59:44Z")

</div>

Growing pains… I have gone through all of this with Processing and coding in general.

I keep notes now and have a personal repository of simple, working examples.

Another tip for future reference (it may come up one day):  
[Blurry Text Solution](https://discourse.processing.org/t/blurry-text-solution/11293)

`:)`
