CSC111 Lab 11 2014
--D. Thiebaut (talk) 17:42, 13 April 2014 (EDT)
Download
Simple Test
from graphicsH import GraphicsWindow
MAXWIDTH = 800
MAXHEIGHT = 600
def main():
win = GraphicsWindow(MAXWIDTH, MAXHEIGHT)
canvas = win.canvas()
canvas.setFill( 255, 0, 0 ) # full red
canvas.drawRect( 100, 100, 300, 200 )
win.wait()
main()
Improve on it
- Try with different colors by picking a different combination of the three ints in setFill()
- Try a random color. Hints: to generate a random number between 0 and 255, you can do this:
# at the top of the program from random import seed from random import randrange def main(): seed() ... x = randrange( 256 ):
Challenge
Generate 1000 random rects of random colors at random locations