Starting from:

$25

CS2261-LAB 1 Drawing Shapes Solved

In this lab, you will be completing TODOs to finish writing three functions:

●      TODO 1.0-1.1

void setPixel(int col, int row, unsigned short color)

○      Fills the pixel at the specified col and row with the specified color

●      TODO 2.0-2.1 

 void drawRect(int col, int row)

○      Draws a rectangle at the specified column and row

○ MUST BE FILLED IN (i.e. a solid rectangle, not just lines)

○ May be any color

○ May be any (GBA appropriate) size

○ May NOT be hardcoded. You may not just call setPixel for every colored-in dot on your rectangle. You must use iteration to do so! 

●      TODO 3.0-3.1 

void drawTriangle(int col, int row)

○      Draws a triangle at the specified column and row

○ May be any color, either filled in or not (your choice)

○ May be any (GBA appropriate) size

○ May NOT be hardcoded. You may not just call setPixel for every colored-in

                              dot on your triangle. You must use iteration to do so!                               

After writing the two functions, ​call the ​drawTriangle ​function two times and call the drawRect function one time in your main function,​ with different parameters. The output of your program should look something like the following.  

  

 

Your triangles and your rectangle may be any size, shape, color, rotation, or position you want, as long as we can see that you drew two triangles and one filled-in rectangle. If you want, you can add parameters to the function to control color, size, or shape. After you have completed all the TODOs and your output looks correct

More products