# Resetting animation

**URL:** <https://discourse.processing.org/t/resetting-animation/18785>\
**Category:** Coding Questions\
**Created:** [March 19, 2020, 7:53am UTC](https://discourse.processing.org/t/resetting-animation/18785 "2020-03-19T07:53:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![v177](https://avatars.discourse-cdn.com/v4/letter/v/59ef9b/32.png) [@v177](https://discourse.processing.org/u/v177)\
**Post date:** [March 19, 2020, 7:53am UTC](https://discourse.processing.org/t/resetting-animation/18785/1 "2020-03-19T07:53:29Z")

</div>

Hello, I am new to p5.js. I am trying to reset the animation based on an event. Running into an issue where every tie my label value is 2, it just shows the same animation.

```auto
function draw() {
  background(255, 120, 120);
  // Draw the video
  image(flippedVideo, 0, 0);

  // Draw the label
  fill(255);
  textSize(16);
  textAlign(CENTER);
  text(label, width / 2, height - 4);
  var row = 0;
  var col = 0;
  var squareSize = 0;
  var speed = 0.03;
  phase = frameCount*speed;

  for(col = 0; col<numCols; col+=1) {
      for (row = 0; row < numRows; row += 1) {
        var pos_y = height / 3.5 + row * 20;
        var pos_x = width / 3.5 + col * 20;

        var sizeOffset = sin(col / (phase*row));

        // This label is from a class label generated in tensorflow
        if(label == "Class 2"){
          squareSize = sizeOffset * maxSquareSize;
        }else{
          squareSize = maxSquareSize;
        }
        square(pos_x, pos_y, squareSize);
      }
  }
}

```

---

<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:** [March 27, 2020, 10:16am UTC](https://discourse.processing.org/t/resetting-animation/18785/2 "2020-03-27T10:16:36Z")

</div>

Hello and welcome to the forum!

Great to have you here!

> [@v177](#):
>
> label == “Class 2”

I don’t think == works well with String

instead try

```auto
label.equals( "Class 2" )

```

Chrisir
