# How do you make a function run the same way as draw()?

**URL:** <https://discourse.processing.org/t/how-do-you-make-a-function-run-the-same-way-as-draw/15373>\
**Category:** Beginners\
**Created:** [November 10, 2019, 10:32am UTC](https://discourse.processing.org/t/how-do-you-make-a-function-run-the-same-way-as-draw/15373 "2019-11-10T10:32:00Z")\
**Posts on this page:** 1\
**Showing post:** 10

<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:** [November 10, 2019, 6:27pm UTC](https://discourse.processing.org/t/how-do-you-make-a-function-run-the-same-way-as-draw/15373/10 "2019-11-10T18:27:11Z")

</div>

Hello,

Something like the transitions in this?  
[https://www.youtube.com/watch?v=BZNEagMBy60](https://www.youtube.com/watch?v=BZNEagMBy60) (this is my work)

I posted a simple example of this in the Gallery that uses frameCount:

> [@Animation that transitions using frameCount](https://discourse.processing.org/t/animation-that-transitions-using-framecount/15378):
>
> A very simple example that transitions through scenes over time: // Author: GLV // Date: 2019-11-10 // Description: // Animate over time using frameCount // A very simple example that: // Uses frameCount to keep track of time // Fades in and out by modifying alpha component of HSB color // Cycles through HSB colors int scene = 0; int sec = 60; float alpha = 0; void setup() { size(500, 500); textSize(36); textAlign(CENTER, CENTER); colorMode(HSB, 360, 100, 100, 100); } void draw()…

References:

> **[frameCount / Reference](https://processing.org/reference/framecount)**
>
> The system variable frameCount contains the number o frames displayed since the program started. Inside setup() the value is 0 and during the first iteration of draw it is 1, etc.

> **[switch / Reference](https://processing.org/reference/switch.html)**
>
> Works like an if else structure, but switch is more convenient when you need to select between three or more alternatives. Program controls jumps to the case with the same value as the e…

> **[case / Reference](https://processing.org/reference/case.html)**
>
> Denotes the different names to be evaluated with the parameter in the switch structure.

> **[colorMode() / Reference](https://processing.org/reference/colormode_)**
>
> Changes the way Processing interprets color data. By default, the parameters for fill(), stroke(), background(), and color() are defined by values between 0 and 255 using t…

My example on YouTube is much more complex code and I have a framework I wrote for my personal use. I use millis() and not frameCount.

I use frameCount for quick examples; the sketch in gallery took less than an hour.

This is also available to you:

> **[millis() / Reference](https://processing.org/reference/millis_.html)**
>
> Returns the number of milliseconds (thousandths of a second) since starting the sketch. This information is often used for timing animation sequences.

I look forward to seeing some pictures of your final project!

🙂

---

_[View the full topic](https://discourse.processing.org/t/how-do-you-make-a-function-run-the-same-way-as-draw/15373)._
