18. Background

So far we have learned how to create a lot of amazing shapes using the Logo's turtle, but sometimes in order to make the shape more vivid we would like to add some background color for it. In this lesson we will study how to fill the shape background with colors using the FILL and FILLED commands
Clear the screen
Fill command will create a background around the turtle current position , If the turtle is fully surrounded by a shape than only the shape background will be filled. In order to show the fill command we will do it in few steps , first we will create a shape (Square) and than we will Fill the background
Write down the command repeat 4 [fd 100 rt 90]
NIce !! , we have created a square , in order to create a background to the square we will have to put the turtle inside the square. So let's do it
Write down the command pu rt 45 fd 50 pd
Now everything ready for the fill command setcolor COLOR fill . While color can be any of the colors in the list ( see lesson "Colors"). setting the color can be done by specifying name or number , setcolor 4 = setcolor "red.
Use the fill command , set color to red by specifying name and fill
Filled command is as follow, filled COLOR [Commands] . Notice the filled command will fill the selected COLOR only after it's running the commands and will fill the area created by the sequence of commands
Create a blue square using the filled command. The same square we have created in step 2
Here we will show a big difference between the commands, Will the output of the following commands will be the same ? a) repeat 4 [fd 100 rt 88] pu rt 45 fd 50 pd setcolor "blue fill b) filled "blue [repeat 4 [fd 100 rt 88]] Try it yourself
After running the both commands please clear the screen
TurtleAcademy learn programming for freeYour browser is not supporting canvasWe recomand you to use Chrome or Firefox browsers