More Drawing

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

void draw_shapes(Control *c, Graphics *g)
{
  Rect r = get_control_area(c);

  set_colour(g, RED);
  fill_rect(g, r);

  set_colour(g, BLUE);
  fill_ellipse(g, inset_rect(r,4));

  set_colour(g, GREEN);
  draw_line(g, pt(r.x,r.y),
           pt(r.x+r.width,r.y+r.height));
  draw_line(g, pt(r.x,r.y+r.height),
           pt(r.x+r.width,r.y));
}

int main(int argc, char *argv[])
{
  App *app;
  Window *w;
  Control *c;
  Rect r;

  app = new_app(argc, argv);
  w = new_window(app, rect(50,50,150,200),
                 "Rectangles", STANDARD_WINDOW);
  set_window_background(w, LIGHT_GREY);
  r = rect(10,10,100,100);
  c = new_control(w, r);
  on_control_redraw(c, draw_shapes);
  show_window(w);
  main_loop(app);
  return 0;
}

Notes: