The process we used to draw borders could actually be used to draw lines as well. For example, if you have a square picture, every pixel whose x value equals its y value lies on the diagonal from upper-left to lower-right corners. Write a function that inputs a square picture (you can assume square) and an input color, and draws a diagonal line from upper-left to lower-right using the input color for the line color.

What will be an ideal response?


```
def drawDiagonal(picture, lineColor):
for p in getPixels(picture):
x = getX(p)
y = getY(p)

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

Computer Science & Information Technology

You might also like to view...

Answer the following statements true (T) or false (F)

1. When choosing a sentinel value, you should choose a value that would never be encountered in the input of the program. 2. An algorithm is a step-by-step method of solution. 3. The three expressions at the start of a for statement are separated by two commas. 4. An empty statement is defined as a loop that runs forever.

Computer Science & Information Technology

What is the output of the following code?

``` string s("abc"); s.append("welcome", 3); cout << s << endl; ``` A. abc B. abcwelcome C. welcomeabc D. abcwel

Computer Science & Information Technology

When multiple criteria must ALL be matched in the query results, a user should use the ________ condition

A) OR B) Is Not Null C) IF D) AND

Computer Science & Information Technology

A ________ area defines the range of data to print

Fill in the blank(s) with correct word

Computer Science & Information Technology