November 25, 2024

Week 14 - Lines and flood filling

 CLASS OBJECTIVE

Create a given figure in the graph window by using the Draw_line and the Flood_fill calls, to ensure the understanding of coordinates in the Cartesian plane


INTRODUCTION

It seemed necessary to teach you how to create lines in the graph window and how to fill closed areas with color, like in Paint, before we combine them with loops. Take a look at the next Raptor calls.

draw_line(x1,y1,x2,y2,color)

  • x1,y1 are the coordinates for the starting point of the line
  • x2,y2  are the coordinate for the ending point of the line

For example, in a 500x500 graph windows we can use the draw_line Call like this:

draw_line(100,50,450,350,blue)

and the result should look like:



flood_fill(x1,y1,color)

  • x1,y1 are the coordinates to flood fill the closed areas.
  • Color: Here you have the color list you can use: Black, Blue, Green, Cyan, Red, Magenta, Brown, Light_Gray, Dark_Gray, Light_Blue, Light_Green, Light_Cyan, Light_Red, Light_Magenta, Yellow, White

I'm sure you'll get the point in the next activity



ACTIVITY

You'll star the activity in a grid sheet of paper. 

  • Draw a box of 10 by 10 squares
  • Every square represent 50 pixels
  • As always, the starting point is the left lower corner.
  • Now, try to determine the coordinates for every point in the next figure.
    • Write down every coordinate either in the plane or beside it.



Now, you will create a program in Raptor to create this figure, using the coordinate you obtained in your grid sheet of paper.
  • Don't forget to use the flood_fill call to apply colors. You'll have to determine a point inside the closed areas using coordinates.
  • Once you finish, turn in the outcome file using the Classroom post.



CLASS NOTES

Write down in your notebook the title of the class, the objective and follow the instructions.

  • Explain the draw_line and the flood fill calls, and their parameters