Types:
-
painter -- a procedure which takes a frame and draws an image in that frame.
-
frame -- a section of a window (called "viewport" in DrScheme) to draw in.
The section is a parallelogram
determined by a corner and two edges (a frame stores the corner and two edges).
-
viewport -- a window in the computer's desktop system on which lines can be drawn.
-
vect -- vector or point (a vect stores x and y coordinates).
-
segment -- a line segment (a segment stores 2 endpoints which are vects)
-
UPO -- a procedure which takes a painter as argument and returns a new painter as output.
-
BPO -- a procedure which takes two painters as arguments and returns a new painter as output.
-
Higher order operator -- a procedure which takes some of the above types as arguments and returns a UPO or BPO as output. Higher order operators could be
called POO's: painter operator operators.
Summary of the
procedures used in the painter module and defined (except where *starred) in the text.
- Painters:
- wave -- a specific painter. *used, but not defined.
- (segments->painter L:list-of-segments) -> p:painter
-- segments->painter is the most primitive painter constructor.
- Segment primitives:
- (make-segment x:vect y:vect) -> s:segment
- (start-segment v:segment) -> v:vect
- (end-segment v:segment) -> v:vect
- The basic painter transformer (a UPO with additional arguments):
- (transform-painter p:painter origin:vect corner1:vect corner2:vect) -> r:painter
-- Transform-painter is the most primitive UPO.
-- The coordinates of the origin and the two corners are in frame coordinates.
The expected use is that all 6 coordinates are in the range 0 to 1.
- Vect primitives ( make-vect, xcor-vect, ycor-vect):
- (make-vect x:number y:number) -> v:vect
- (xcor-vect v:vect) -> x:number
- (ycor-vect v:vect) -> y:number
- Vect operators:
- (add-vect a:vect b:vect) -> v:vect
- (sub-vect a:vect b:vect) -> v:vect
- (scale-vect s:number a:vect) -> v:vect
- UPO's:
- (flip-vert p:painter) -> r:painter
- (flipped-pairs p:painter) -> r:painter
- UPO's with additional argument(s):
- (right-split p:painter n:non-neg-int) -> r:painter
- (corner-split p:painter n:non-neg-int) -> r:painter
- (square-limit p:painter n:non-neg-int) -> r:painter
- BPO's:
- (beside p:painter q:painter) -> r:painter
- (below p:painter q:painter) -> r:painter
- Higher order painter operator makers (POO's - painter operator operators):
- (square-of-four a:UPO b:UPO c:UPO d:UPO) -> e:UPO
- (split a:BPO b:BPO) -> e:UPO-with-second-numeric-argument
-- *discussed but not defined (see exercise 2.45).
- Frames and viewports:
-- *These are not in the text. They are defined in the provided painter code.
- whole-viewport-frame aka wf.
-- If p is a painter (p wf) paints it on the viewport window.
- (erase) -- clears the viewport.
The rest is stuff you don't need!
- Frame primitives:
- (make-frame origin:vect edge1:vect edge2:vect) -> r:frame
-- The coordinates of the origin are in number of pixels from the upper left
corner of the viewport. The coordinates of the edges are in number of pixels from
the origin.
- (origin-frame f:frame) -> v:vect -- the origin corner of f.
- (edge1-frame f:frame) -> v:vect -- the edge1 of f.
- (edge2-frame f:frame) -> v:vect -- the edge2 of f.
- (frame-coord-map f:frame) -> p:procedure(vect to vect) -- output p is a
procedure to transform a point in frame coordinates to window coordinates.
- Viewport primitives: See Dr Scheme online help if interested in more features
of viewports (windows).