# Smiley Example

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

    void draw_smile(Control *c, Graphics *g)
    {
      Rect r;
      Rect r1, r2;
      Point p;

      r = get_control_area(c);
      r1 = inset_rect(r, 10);      /* inset from edge */

      set_colour(g, LIGHT_BLUE);   /* blue face */
      fill_ellipse(g, r1);         /* draw face */

      set_colour(g, RED);          /* red lips */
      set_line_width(g, 2); /* thicker lips */
      r2 = inset_rect(r1, 30);     /* inset from face */
      draw_arc(g, r2, 270-60, 270+60); /* smile arc */

      set_colour(g, BROWN);        /* brown eyes */
      p.x = r1.x + r1.width  * 1/2;
      p.y = r1.y + r1.height * 1/4;

      r2 = rect(p.x - 30, p.y, 20,20);
      fill_ellipse(g, r2);         /* draw left eye */

      r2 = rect(p.x + 10, p.y, 20,20);
      fill_ellipse(g, r2);         /* draw right eye */
    }

    void resize_smile(Window w)
    {
      /* retrieve remembered drawing */
      Rect r = get_window_area(w);
      Control *c = get_window_data(w);
      set_control_area(d, r);
    }

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

      app = new_app(argc, argv);
      w = newwindow(app, rect(50,50,120,120),
                    "Smile!", STANDARD_WINDOW);
      c = new_control(w, rect(0,0,120,120));
      on_control_redraw(c, draw_smile);
      set_window_data(w, d); /* store control pointer */
      on_window_resize(w, resize_smile);
      show_window(w);
      main_loop(app);
      return 0;
    }

Notes:

- `set_line_width` changes the thickness of all lines drawn.
- The `draw_arc` function draws an arc inside a bounding rectangle, between two angles.
- Source code: smiley.c