# The Timer

    #include <stdio.h>
    #include "graphapp.h"

    Rect r;
    Window *w;

    void draw_something(Timer *t)
    {
      Graphics *g = get_window_graphics(w);
      draw_ellipse(g, r);
      r.x += 10;
      r.y += 10;
      del_graphics(g);
    }

    int main(int argc, char *argv[])
    {
      App *app;
      Timer *t;

      app = new_app(argc, argv);
      w = new_window(app, rect(20,20,400,300), "Timer", STANDARD_WINDOW);
      show_window(w);

      r = rect(10,10,30,15);

      t = new_timer(app, draw_something, 2000);
      draw_something(t);
      main_loop(app);
      return 0;
    }

Notes:

- Use `new_timer` to create a timer.
- The last parameter is a time interval in milliseconds. In the example, the timer will activate every 2 seconds (2000 milliseconds).
- The timer's call-back function is passed a pointer to the timer.
- To draw to a window or control, you must first obtain a `Graphics` object. In the example, the `get_window_graphics` function is used, and the object is later destroyed by `del_graphics`. Normally this is not necessary, since a window or control's redraw call-back is passed a `Graphics` object.