# Why is my rect leaving a trail behind it when I move it?

**URL:** <https://discourse.processing.org/t/why-is-my-rect-leaving-a-trail-behind-it-when-i-move-it/4440>\
**Category:** Coding Questions\
**Created:** [October 13, 2018, 9:07pm UTC](https://discourse.processing.org/t/why-is-my-rect-leaving-a-trail-behind-it-when-i-move-it/4440 "2018-10-13T21:07:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![swood](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@swood](https://discourse.processing.org/u/swood)\
**Post date:** [October 13, 2018, 9:07pm UTC](https://discourse.processing.org/t/why-is-my-rect-leaving-a-trail-behind-it-when-i-move-it/4440/1 "2018-10-13T21:07:12Z")

</div>

Hi all,

new to p5 and am a bit confused. I am trying to make a rectangle move on a horizontal plane. To do this I am adding two vectors when the user presses the left arrow or right arrow.

The paddle is moving as intended, however, my rect is drawn with a trail behind it. Im not sure how or why this trail is being drawn. Could someone explain this?

My code for this example can be found here - you’ll have to click on the black background area before you press the arrow keys to move the paddle

[https://editor.p5js.org/swood/sketches/S1kU6R1om](https://editor.p5js.org/swood/sketches/S1kU6R1om)

thanks!

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [October 13, 2018, 10:07pm UTC](https://discourse.processing.org/t/why-is-my-rect-leaving-a-trail-behind-it-when-i-move-it/4440/2 "2018-10-13T22:07:15Z")

</div>

Your sketch is redrawing the current frame on top of the previous one.

You probably want to add a call to `background()` inside your `draw()` function:

```auto
// ...
function draw() {
  background(0); // <-- HERE
  if(keyIsDown(LEFT_ARROW)){
    // ...

```
