Next: , Previous: , Up: Graphics   [Contents][Index]


17.3 Drawing Graphics

The procedures in this section provide the basic drawing capabilities of Scheme’s graphics system.

procedure: graphics-clear graphics-device

Clears the display of graphics-device. Unaffected by the current drawing mode.

procedure: graphics-draw-point graphics-device x y

Draws a single point on graphics-device at the virtual coordinates given by x and y, using the current drawing mode.

procedure: graphics-erase-point graphics-device x y

Erases a single point on graphics-device at the virtual coordinates given by x and y. This procedure is unaffected by the current drawing mode.

This is equivalent to

(lambda (device x y)
  (graphics-bind-drawing-mode device 0
    (lambda ()
      (graphics-draw-point device x y))))
procedure: graphics-draw-line graphics-device x-start y-start x-end y-end

X-start, y-start, x-end, and y-end must be real numbers. Draws a line on graphics-device that connects the points (x-start, y-start) and (x-end, y-end). The line is drawn using the current drawing mode and line style.

procedure: graphics-draw-text graphics-device x y string

Draws the characters of string at the point (x, y) on graphics-device, using the current drawing mode. The characteristics of the characters drawn are device-dependent, but all devices are initialized so that the characters are drawn upright, from left to right, with the leftmost edge of the leftmost character at x, and the baseline of the characters at y.

The following two procedures provide an alternate mechanism for drawing lines, which is more akin to using a plotter. They maintain a cursor, which can be positioned to a particular point and then dragged to another point, producing a line. Sequences of connected line segments can be drawn by dragging the cursor from point to point.

Many graphics operations have an unspecified effect on the cursor. The following exceptions are guaranteed to leave the cursor unaffected:

graphics-device-coordinate-limits
graphics-coordinate-limits
graphics-enable-buffering
graphics-disable-buffering
graphics-flush
graphics-bind-drawing-mode
graphics-set-drawing-mode
graphics-bind-line-style
graphics-set-line-style

The initial state of the cursor is unspecified.

procedure: graphics-move-cursor graphics-device x y

Moves the cursor for graphics-device to the point (x, y). The contents of the device’s display are unchanged.

procedure: graphics-drag-cursor graphics-device x y

Draws a line from graphics-device’s cursor to the point (x, y), simultaneously moving the cursor to that point. The line is drawn using the current drawing mode and line style.


Next: Characteristics of Graphics Output, Previous: Coordinates for Graphics, Up: Graphics   [Contents][Index]