Comp 151 Project 4
Draw me a picture from a file while you work
with data
Summary:
In this second project you will read data in from a file, interpret it using
strings and lists and draw me the picture specified in the file using the
Zelle graphics library. Lets put a little bit more together because the
projects so far have been really easy. We are only adding if statements new
here, but we will put together everything from projects 1-3.
Due:
Saturday Oct 15th at 11:59pm. (this is a little longer than recent
projects because there is a little more to it.)
Description:
First create a new project (which creates a new project folder)
Then get
the Zelle graphics library and put it in your project folder
Then write a program which will
- put up one of the Zelle graphics windows (make it at least 500x500
pixals)
- read from a file you can grab my Demo.txt file
for a first pass.
- The file has the following format
- each line in the file represents a shape
- if the line begins with the character 'R' then the line
represents a rectangle, there should be four integers after the R
representing the upperLeftX upperLeftY lowerRightX and lowerRightY
respectively
- If the line begins with the character 'O' then the line
represents and Oval; there should be four integers after the O
representing the upperLeftX upperLeftY lowerRightX and lowerRightY
respectively
- If the line begins with 'L' then the line from the file
represents a graphics. Line; there should be four integers after
the L representing firstX firstY SecondX and secondY respectively.
Make the line 2 pixels thick
- If the line begins with 'T' then the line represents a
graphics.Text. The next two items on the should be the X and Y
position of the text. The last thing on the should be the actual
text to be displayed
- If the line begins with 'P' then the line represents a
graphics.Point the next two things on the line will be the X and Y
position of the point.
- If the line begins with a 'C' then the line represents a
graphics.Circle. There must be three numbers after the C which
represent the centerX centerY and Radius of the circle in that
order.
- Draw the graphics element with the following requirements
- each item should be given a random color from a list of at least 10
colors
- Fill color in the case of Rectangles, Ovals and Circles,
- Outline Color in the case of lines and points
- text Color (use setTextColor)for Text objects
- You can go here to get a list
of color names
(please use the ones without spaces - sometimes the ones with spaces cause trouble on some systems
- Do this for each of the lines in the text file, how ever many there
are. For example when I ran my sample solution on the Demo.txt file that
I provided you, my solution showed this:
Your program must be able to handle any
legitimate contents of demo.txt (I will add additional lines - possibly
to the top of the file, when I grade this.)
Additional requirements:
Your code must be commented
Your function must contain all of your code except the one line
invoking the function
To help me identify your work, make the name of your program file
yourFirstInitialLastNameLab4.py
(so mine would be JSantoreLab4.py)
And put the following at the beginning of the program as a comment:
- Your name
- anything that was left undone
- anything that I need to know to run the program correctly.
Project Submission
Zip up your project folder. Find the project folder and right click on it
and choose the <send to> option and send to a zip file.
Submit your zipped project as usual via blackboard.