# Help creating simple animation

**URL:** <https://discourse.processing.org/t/help-creating-simple-animation/14089>\
**Category:** Beginners\
**Created:** [September 21, 2019, 12:31am UTC](https://discourse.processing.org/t/help-creating-simple-animation/14089 "2019-09-21T00:31:38Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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:** [September 24, 2019, 8:48pm UTC](https://discourse.processing.org/t/help-creating-simple-animation/14089/14 "2019-09-24T20:48:34Z")

</div>

here is another way of achieving this using an explicit timer and a boolean variable `isSmallRect` that is set by the timer.

`isSmallRect` gets then evaluated to decide which rectangle to draw

```auto

int timer; 
boolean isSmallRect = true; 

void setup() {
  size(640, 360);
  // start timer
  timer = millis();
}

void draw() {
  background(0); // create black background
  fill(102); //set color to gray

  // timer to control isSmallRect 
  if ( millis() - timer > 3000 ) {
    // start timer  
    timer = millis(); 
    // toggle isSmallRect 
    isSmallRect = 
      ! isSmallRect; // the ! means not, so inverses the value of isSmallRect
  }

  // evaluate isSmallRect
  if (isSmallRect) {
    rect(81, 81, 63, 63); // draw a small rectangle
  } else {
    rect(81, 81, 150, 150); // draw slightly larger rectangle
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/help-creating-simple-animation/14089)._
