Glimmr Drawing Commands

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next

  • Section: Short-form commands

    All commands have a short form that minimizes repetition when we are issuing multiple instructions. These short forms require that we set at least one, and possibly more, global variables before using them. The global variables implicated in short-form drawing are:

        current graphics window (a g-window)
        current foreground-color (a number)
        current background-color (a number)

    To use short form commands, we first set one or more of these variables, and then use as many short forms as we like. This bit of code draws two overlapping white rectangles with a horizontal red line in the center (approximating a traffic sign):

        change the current graphics window to the graphics-window;
        change the current foreground-color to (R 255 G 255 B 255);
        rect {10, 10} to {20, 23};
        rect {8, 12} to {22, 21};
        change the current foreground-color to (R 255 G 0 B 0);
        line {11, 15} to {19, 15} at 3 px.

    Short forms must use brace notation for specifying coordinate pairs, e.g. {10, 10}.