Scientific Computing
Complete the setup to install the cImage
module and read some key differences based on the latest updates to the module.
Create a file called line.py
and save it to your cs100/ch6
folder.
from image import *
myWin = ImageWin(300, 300, "Class image")
# create a new image which we modify
img = EmptyImage(300,300)
blackPixel = Pixel(0,0,0)
# diagonal pixels are colored black
for i in range(300):
img.setPixel(i,i,blackPixel)
# YOUR CODE HERE (change image before it is displayed & saved)
# displays the image
img.draw(myWin)
# saves image to the given file name
img.save("classImg.gif")
# when you click anywhere on the window, it closes
myWin.exitOnClick()
Run the program. Inspect the code to understand what each line does.
Create a red square in the upper left corner which has width 100 pixels and height 100 pixels.
Submit your working line.py
file to Moodle.