Fundamentals of Computer Science I: Media Computing (CS151.01 2008S)

Drawings


Constants

drawing-unit-circle
DrFu Drawing Constant. A unit circle. That is, a circle with diameter 1, filled in black, centered at (0,0).
drawing-unit-square
DrFu Drawing Constant. A unit square. That is, a square with edge-length 1, filled in black, centered at (0,0).

Basic Transformations

(drawing-scale drawing factor)
DrFu 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)
DrFu 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)
DrFu 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)
DrFu 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)
DrFu 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.

Additional Transformations

(drawing-recolor drawing color)
DrFu 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.
(drawing-outline drawing brush)
DrFu Drawing Procedure. Creates a new drawing by outlining each element in drawing with brush. Element colors are preserved. After outlining, no elements of the resulting drawing are filled.
(drawing-fill drawing)
DrFu Drawing Procedure. Creates a new drawing by filling each element of drawing. Element colors are preserved. After filling, no elements of the resulting drawing are outlined.

Grouping Drawings

(drawing-join drawing1 drawing2)
DrFu Drawing Procedure. Create a new drawing by overlaying drawing2 on top of drawing1.
(drawing-group drawing1 drawing2 ... drawingn)
DrFu 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)
DrFu Drawing Procedure. Determine the column of the left edge of a drawing.
(drawing-top drawing)
DrFu Drawing Procedure. Determine the row of the top edge of a drawing.
(drawing-right drawing)
DrFu Drawing Procedure. Determine the column of the right edge of a drawing.
(drawing-bottom drawing)
DrFu Drawing Procedure. Determine the row of the bottom edge of a drawing.
(drawing-width drawing)
DrFu Drawing Procedure. Determine the width of a drawing.
(drawing-height drawing)
DrFu Drawing Procedure. Determine the approximate height of a drawing.
(drawing-type drawing)
DrFu 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 support).

Getting Additional Information About Simple Drawings

(drawing-color drawing)
DrFu Drawing Procedure. Determine the color of a simple drawing. (Does not work for compound drawings.)
(drawing-filled? drawing)
DrFu Drawing Procedure. Determine if a simple drawing is filled. (Does not work for compound drawings.)
(drawing-brush drawing)
DrFu Drawing Procedure. Determine the brush of an outlined simple drawing. (Does not work for compound drawings or filled simple drawings.)

Rendering Drawings

(drawing->image drawing width image)
DrFu 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.

Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-8 Janet Davis, Matthew Kluber, and Samuel A. Rebelsky. (Selected materials copyright by John David Stone and Henry Walker and used by permission.)

This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.