Functional Problem Solving (CSC 151 2015F) : Reference

Drawings


Constants

drawing-blank
MediaScheme Drawing Constant. An empty drawing. Included for the sake of completeness. Also provides a useful base case for recursion over grouped drawings.
drawing-unit-circle
MediaScheme Drawing Constant. A unit circle. That is, a circle with diameter 1, filled in black, centered at (0,0).
drawing-unit-square
MediaScheme Drawing Constant. A unit square. That is, a square with edge-length 1, filled in black, centered at (0,0).

Basic Transformations

(scale-drawing factorg drawing)
MediaScheme Drawing Procedure. Creates a new drawing by scaling drawing by factor. Note that every part of the drawing is scaled, including both the horizontal and vertical distance of each component of the drawing from the origin.
(hscale-drawing factor drawing)
MediaScheme Drawing Procedure. Creates a new drawing by horizontally scaling drawing by factor. Note that every part of the drawing is scaled horizontally, including the horizontal distance of each component of the drawing from the origin.
(vscale-drawing factor drawing)
MediaScheme Drawing Procedure. Creates a new drawing by vertically scaling drawing by factor. Note that every part of the drawing is scaled vertically, including the vertical distance of each component of the drawing from the origin.
(hshift-drawing amt drawing)
MediaScheme Drawing Procedure. Creates a new drawing by shifting drawing horizontally by factor. If factor is positive, the drawing is shifted to the right. If factor is negative, the drawing is shifted left by the absolute value of factor.
(vshift-drawing amt drawing)
MediaScheme Drawing Procedure. Creates a new drawing by shifting drawing vertically by factor. If factor is positive, the drawing is shifted downward. If factor is negative, the drawing is shifted upward by the absolute value of factor.
(recolor-drawing color drawing)
MediaScheme Drawing Procedure. Creates a new drawing by recoloring drawing in color. Note that even if drawing contained colors, the new drawing contains only a single color.

Grouping Drawings

(drawing-compose list-of-drawings)
MediaScheme Drawing Procedure. Create a new drawing by overlaying all of individual drawings in list-of-drawings. Note that the drawings are stacked first to last, so the first drawing in the list is at the bottom and the last in the list is at the top.
(drawing-group drawing1 drawing2 ... drawingn)
MediaScheme Drawing Procedure. Create a new drawing by overlaying all of the individual drawings. Note that the drawings are stacked first to last, so drawing1 is at the bottom and drawingn is at the top.

Getting Information About Drawings

(drawing-left drawing)
MediaScheme Drawing Procedure. Determine the column of the left edge of a drawing.
(drawing-top drawing)
MediaScheme Drawing Procedure. Determine the row of the top edge of a drawing.
(drawing-right drawing)
MediaScheme Drawing Procedure. Determine the column of the right edge of a drawing.
(drawing-bottom drawing)
MediaScheme Drawing Procedure. Determine the row of the bottom edge of a drawing.
(drawing-width drawing)
MediaScheme Drawing Procedure. Determine the width of a drawing.
(drawing-height drawing)
MediaScheme Drawing Procedure. Determine the approximate height of a drawing.
(drawing-type drawing)
MediaScheme Drawing Procedure. Determine the type of drawing represented. Returns a symbol: ellipse for ellipses and circles, rectangle for rectangles and squares, group for grouped drawings, and line for lines (not yet supported).

Getting Additional Information About Simple Drawings

(drawing-color drawing)
MediaScheme Drawing Procedure. Determine the color of a simple drawing. (Does not work for compound drawings.)

Rendering Drawings

(drawing->image drawing width height)
MediaScheme Drawing Procedure. Create a new image of the specified width and height that contains the portion of drawing that fits in the rectangular region bounded on the left by 0, on the top by 0, on the right by width-1 and on the bottom by height-1.
(drawing-render! drawing image)
MediaScheme Drawing Procedure. Render drawing on the specified image, thereby changing the image. Expects that at least part of the drawing fits within the confines of the image.

Drawing Predicates

(drawing? value)
MediaScheme Drawing Procedure. Determine if value can be interpreted as a drawing.
(drawing-blank? value)
MediaScheme Drawing Procedure. Determine if value can be interpreted as a blank drawing.

Alternate Versions of Transformations

These versions of the transformations reverse the order of the parameters. We originally developed these versions, but found that the versions above were clearer for most programmers, particularly novice programmers. The original versions are maintained to ensure that old code remains usable.

(drawing-scale drawing factor)
MediaScheme Drawing Procedure. Creates a new drawing by scaling drawing by factor. Note that every part of the drawing is scaled, including both the horizontal and vertical distance of each component of the drawing from the origin.
(drawing-hscale drawing factor)
MediaScheme Drawing Procedure. Creates a new drawing by horizontally scaling drawing by factor. Note that every part of the drawing is scaled horizontally, including the horizontal distance of each component of the drawing from the origin.
(drawing-vscale drawing factor)
MediaScheme Drawing Procedure. Creates a new drawing by vertically scaling drawing by factor. Note that every part of the drawing is scaled vertically, including the vertical distance of each component of the drawing from the origin.
(drawing-hshift drawing amt)
MediaScheme Drawing Procedure. Creates a new drawing by shifting drawing horizontally by factor. If factor is positive, the drawing is shifted to the right. If factor is negative, the drawing is shifted left by the absolute value of factor.
(drawing-vshift drawing amt)
MediaScheme Drawing Procedure. Creates a new drawing by shifting drawing vertically by factor. If factor is positive, the drawing is shifted downward. If factor is negative, the drawing is shifted upward by the absolute value of factor.
(drawing-recolor drawing color)
MediaScheme Drawing Procedure. Creates a new drawing by recoloring drawing in color. Note that even if drawing contained colors, the new drawing contains only a single color.