4 Draw, Clear, and Flip Operations
The following are the basic graphics operations for drawing to a viewport. Each function takes a viewport as its argument and returns a function operating within that viewport. Further arguments, if any, are curried. For example, (draw-line viewport) returns a function, that can then be applied to the proper arguments to draw a line in the viewport corresponding to viewport descriptor viewport.
In general, draw- functions make pixels black or colored, clear- functions make them white, and flip- commands invert pixels (which makes black white, white black, and is otherwise ill-defined).
4.1 Viewports
procedure
((draw-viewport viewport) [color]) → void?
viewport : viewport?
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-viewport viewport)) → void?
viewport : viewport?
procedure
((flip-viewport viewport)) → void?
viewport : viewport?
procedure
(copy-viewport source dest) → void?
source : viewport? dest : viewport?
4.2 Pixels
procedure
((draw-pixel viewport) p [color]) → void?
viewport : viewport? p : posn?
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-pixel viewport) p) → void?
viewport : viewport? p : posn?
procedure
((flip-pixel viewport) p) → void?
viewport : viewport? p : posn?
4.3 Lines
procedure
viewport : viewport? p1 : posn? p2 : posn?
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-line viewport) p1 p2) → void?
viewport : viewport? p1 : posn? p2 : posn?
4.4 Rectangles
procedure
((draw-rectangle viewport) p width height [ color]) → void? viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-rectangle viewport) p width height) → void?
viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
procedure
((flip-rectangle viewport) p width height) → void?
viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
procedure
((draw-solid-rectangle viewport) p width height [ color]) → void? viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-solid-rectangle viewport) p width height) → void? viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
procedure
((flip-solid-rectangle viewport) p width height) → void? viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
4.5 Ellipses
procedure
((draw-ellipse viewport) p width height [color]) → void?
viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-ellipse viewport) p width height) → void?
viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
procedure
((flip-ellipse viewport) p width height) → void?
viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
procedure
((draw-solid-ellipse viewport) p width height [ color]) → void? viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-solid-ellipse viewport) p width height) → void? viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
procedure
((flip-solid-ellipse viewport) p width height) → void? viewport : viewport? p : posn? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?))
4.6 Polygons
procedure
((draw-polygon viewport) points offset [color]) → void?
viewport : viewport? points : (listof posn?) offset : posn?
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-polygon viewport) points offset) → void?
viewport : viewport? points : (listof posn?) offset : posn?
procedure
((flip-polygon viewport) points offset) → void?
viewport : viewport? points : (listof posn?) offset : posn?
procedure
((draw-solid-polygon viewport) points offset [ color]) → void? viewport : viewport? points : (listof posn?) offset : posn?
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-solid-polygon viewport) points offset) → void? viewport : viewport? points : (listof posn?) offset : posn?
procedure
((flip-solid-polygon viewport) points offset) → void? viewport : viewport? points : (listof posn?) offset : posn?
4.7 Strings
procedure
((draw-string viewport) p str [color]) → void?
viewport : viewport? p : posn? str : string?
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((clear-string viewport) p str) → void?
viewport : viewport? p : posn? str : string?
procedure
((flip-string viewport) p str) → void?
viewport : viewport? p : posn? str : string?
4.8 Pixmaps
procedure
(((draw-pixmap-posn file [ type])) viewport) p [ color]) → void? file : path-string?
type :
(one-of/c 'unknown 'unknown/mask 'gif 'gif/mask 'jpeg 'png 'png/mask 'xbm 'xpm 'bmp) = 'unknown/mask viewport : viewport? p : posn?
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
The argument color is only used when the loaded pixmap is monochrome. In that case, the color is used instead of black in the drawn image.
procedure
((draw-pixmap viewport) file p [color]) → void?
viewport : viewport? file : path-string? p : posn?
color :
(or/c (integer-in 0 299) string? rgb?) = "black"
procedure
((save-pixmap viewport) file [type]) → void?
viewport : viewport? file : path-string? type : (one-of/c 'gif 'jpeg 'png 'xbm 'xpm 'bmp) = 'xpm