Difference between revisions of "CSC111 Homework 11 2014"
(→Requirements) |
(→Hints) |
||
Line 40: | Line 40: | ||
==Hints== | ==Hints== | ||
<br /> | <br /> | ||
− | + | * To set the color of the background, you can use the '''setBackground()''' canvas method: | |
<br /> | <br /> | ||
− | <source lang="python"> | + | :::<source lang="python"> |
win = GraphicsWindow(MAXWIDTH, MAXHEIGHT) | win = GraphicsWindow(MAXWIDTH, MAXHEIGHT) | ||
canvas = win.canvas() | canvas = win.canvas() | ||
Line 49: | Line 49: | ||
</source> | </source> | ||
<br /> | <br /> | ||
− | + | * Printing text can be used using two other canvas methods: '''setTextFont()''' and '''drawText()''': | |
<br /> | <br /> | ||
− | <source lang="Python"> | + | :::<source lang="Python"> |
canvas.setTextFont( 'arial', 40, 'bold' ) | canvas.setTextFont( 'arial', 40, 'bold' ) | ||
Line 58: | Line 58: | ||
</source> | </source> | ||
<br /> | <br /> | ||
+ | |||
=Submission= | =Submission= | ||
<br /> | <br /> |
Revision as of 07:30, 17 April 2014
--D. Thiebaut (talk) 21:28, 15 April 2014 (EDT)
Contents
Problem 1
You have been hired for the summer by a company that makes wrapping paper. The company has a Web form where customers can pick different colors, a general theme, and a message to print in the middle of the page. Then a Python program generates an image that is printed by a large format printer.
The image above shows one particular output, for somebody who has selected Cars as the theme, Yellow as the background, and "Happy Easter" as the message.
Your assignment
You must write a program that generates a sample output, with a predefined color, a predefined scheme, and a predefined message. Your program will NOT ask the user for any information.
Submission
You must submit 2 files:
- Your program, which should be called hw11a.py
- An image of the output generated by your program. It should be called sheet.png or sheet.jpg
Requirements
- Your program should print rows of cars. The color of the cars should be randomly generated.
- Your program uses the same car for each row (the image above shows an output of the optional and extra-credit program)
- You are free to pick the shape of your car. It must have at least 2 rectangles and at least two wheels. You pick the shape that you like.
- A given car can have differently colored rectangles, or the same color for all its rectangles. You decide.
- Cars are allowed to extend past the boundaries of the window.
- The message in the middle should appear inside a rectangle that hides the cars underneath it
- The message should be as centered in the rectangle as possible.
- The message should be large enough to be easily readable
Hints
- To set the color of the background, you can use the setBackground() canvas method:
win = GraphicsWindow(MAXWIDTH, MAXHEIGHT) canvas = win.canvas() canvas.setBackground( 0, 250, 250 )
- Printing text can be used using two other canvas methods: setTextFont() and drawText():
canvas.setTextFont( 'arial', 40, 'bold' ) canvas.drawText( 100, 100, "CSC111 Homework 11" )
Submission
Remember that you must submit 2 files, the program and a screen capture of your window.
The submission URL is http://cs.smith.edu/~thiebaut/111b/submit11.php
Optional and Extra-Credits: Problem 2