Write a function doGraphics that will take a list as input. The function doGraphics will start by creating a canvas from the 640x480.jpg file in the mediasources folder. You will draw on the canvas according to the commands in the input list. Each element of the list will be a string. There will be two kinds of strings in the list:
• “b 200 120” means to draw a black dot at x position 200 and y position 120–(200,120).
The numbers, of course, will change, but the command will always be a “b.” You can assume that the input numbers will always have three digits.
• “l 000 010 100 200” means to draw a line from position (0,10) to position (100,200).
So an input list might look like: ["b 100 200","b 101 200","b 102 200","l 102 200 102 300"] (but have any number of elements).
Note: The important thing here is to iterate through the list’s items and handle each case with the “split” method.
```
def doGraphics (list):
canvas = makePicture("640x480.jpg")
for item in list:
if item[0]=="b":
parts = item.split(" ")
px = getPixel(canvas, int(parts[1]), int(parts[2]))
setColor(px, makeColor(0,0,0))
elif item[0]=="l":
parts = item.split(" ")
x1 = int(parts[1])
y1 = int(parts[2])
x2 = int(parts[3])
y2 = int(parts[4])
addLine(canvas, x1, y1, x2, y2)
return canvas
```
You might also like to view...
MC SQL is an acronym for_________ .
a) Standard Query Language. b) Standard Question Language. c) Structured Query Language. d) None of the above.
To help prevent computer performance problems, you need to periodically delete the Internet files and information.
Answer the following statement true (T) or false (F)
Which button do you use to complete an action query?
A. View B. Select C. Show D. Run
The ____ command-line utility is used to trace the route a packet of information takes to get to its target.
A. ping B. ping -a 192.168.1.1 C. tracert D. tracepath