It’s a little more tricky to write a function that draws a diagonal from lower-left to upper-right for a square picture. Note that the sum of the x and the y should be equal to the number of pixels in the line.

What will be an ideal response?


```
def drawDiagonal2(picture, lineColor):
width = getWidth(picture)
for p in getPixels(picture):
x = width-getX(p)
y = getY(p)

if x==y:
setColor(p,lineColor)
```

Note: The question does not specify that a line color should be passed in, so one can just write a function that always uses the same color.

Computer Science & Information Technology

You might also like to view...

How many finalizers can a class have?

A. zero B. one C. two D. Any number

Computer Science & Information Technology

Explain the connection between role-based access control (RBAC) and groups.

What will be an ideal response?

Computer Science & Information Technology

MC Items are______ on and______ off a stack.

a) pushed, topped. b) placed, knocked. c) pushed, popped. d) None of the above.

Computer Science & Information Technology

What does the following code print out?

dim example As String = “VB_Programming” Console.Write(example.Substring( 3, 5 ) a) _Pr b) _Prog c) Pro d) Progr

Computer Science & Information Technology