CS-511 - Assignment 1 (5%)
2D Paint Program
Due by: September 9, 2008
In this assignment you have to write a 2D Paint program. The program
reads an input file in which geometric objects and associated attributes
are described, and draws it on the screen. The objects are layered
based on the order of their specification (the latest being drawn on
top). Modified attributes affect only objects which are specified after
their modification. The program should satisfy the following:
- Supported objects: Objects that may be drawn by the program include:
- Rectangle - specified by two 2D points describing its lower
left and upper right corners.
- Circle - specified by a 2D point describing its center and a radius.
- Polyline - specified by a list of up to ten 2D points
- Polygon - specified by a list of up to ten 2D points. The
last point is assumed to be connected to the first one.
- Supported attributes: Attributes of objects include the following:
- Color - the color of the object to be drawn specified as three RGB
components (each in the range [0..1]).
- Fill mode - a flag indicating whether the object should be
drawn filled or not (1 indicates that the object should be filled).
- Translation - specified by a 2D vector with respect to the origin.
- Rotation - specified by an angle in degrees. Rotation is
assumed to be about the origin.
- Scale - specified by two scale factors in the X and Y
directions. Scaling is assumed to be about the origin.
- Input file format: The input file describing the objects
is a text file in which each line describes the addition of an object or
the modification of the current attributes. Empty lines, and lines
beginning with a # should be ignored. All the numbers in the file are
considered to be real numbers. The following are possible lines in the
input file:
# Add a rectangle:
ar <ll-corner-x> <ll-corner-y> <ur-corner-x> <ur-corner-y>
# Add a circle:
ac <center-x> <center-y> <radius>
# Add a polyline:
al <num-vertices> <v1-x> <v1-y> <v2-x> <v2-y> ...
# Add a polygon:
ap <num-vertices> <v1-x> <v1-y> <v2-x> <v2-y> ...
# Set color:
sc <R> <G> <B>
# Set fill mode:
sf <0.0|1.0>
# Set translation:
st <trans-x> <trans-y>
# Set rotation:
sr <deg-angle>
# Set scale:
ss <scale-x> <scale-y>
- Applying the attributes:
Whenever an object is drawn it should be drawn with the currently set
attributes. Changed attributes remain in effect until modified
again. Transformations are considered in this program as attributes and
should always be applied in a fixed order regardless of the order of
their specification. Transformations should be applied in the following
order: first the object should be scaled, then rotated, and finally
translated. The initial attributes are:
- Color: 1.0 1.0 1.0 (white)
- Fill mode: 1.0 (filled)
- Translation: 0.0 0.0 (none)
- Rotation: 0.0 (none)
- Scale: 1.0 1.0 (none)
- Modifying the coordinate system: By default the displayed
part of the coordinate system is a range of in both the
and directions. By pressing 'i' on the keyboard a ``zoom-in''
effect should be obtained by modifying the displayed range of the
coordinate system to be half of its previous value in both the and
directions. By pressing 'o' on the keyboard a ``zoom-out'' effect
should be obtained by modifying the displayed range of the coordinate
system to be double of its previous value in both the and
directions.
The following are required implementation notes:
- All the drawing should occur in the ``display handler''.
- A circle should be drawn as a GL_POLYGON object.
- Sample input files are available on the course's website.
- A sample program demonstrating how to read the input file will be
provided.
Please follow the following submission procedure:
- Use OpenGL, C/C++, and GLUT. Do not use any Microsoft specific
classes (MFC). Use SVL/VL for matrix and vector operations.
- Direct all questions/comments regarding the assignment to:
- On or before the due date send an email to
with
a subject line stating ``assignment submission'', and attach to it a ZIP
file containing the following:
- Report: prepared as a PDF or PS file. The report should contain a
summary of program design issues, description of specific problems you
faced and the way in which you solved them, and sample input/output
results (text/graphic). The report needs to be sufficiently detailed.
Please do not submit MS-Word DOC files.
- Source code: all the source code files and the project file (or
a make file) that are necessary in order to compile your program.
- Executable: the executable file of your program. Please do not
submit intermediate object files and/or workspace files.
Note: we must be able to view your report, compile your code, and
execute your program in order to grade it
- The organization of the submitted material should be as follows:
- Create a directory called:
first_last_ass#
where
``first''/``last'' is your name and ``#'' is the assignment number.
- Inside this directory create four sub-directories called:
code
, report
, exe
, data
. Place in these
directories the files you need to submit.
- Please do not use space inside file/directory names.
- Do not submit a paper copy of your report. You will be contacted
by email if some material is missing or if you will need to meet with
the TA.
- If you are late in the submission, send it by email as soon as you
have it to
.
``late days'' will be determined by your email date.
Gady Agam
2008-09-02