Drawing shapes

For the end, let's code something more complicated. 

The matrix board can be used to draw a variety of shapes. 

To draw shapes, we'll make two functions. We'll name one of them "drawBG" and use it to clear the background and draw two crossing lines in the middle of the matrix. 

The other one will be called "showRect" and will be used to draw a rectangle. 

Let's play with the first one for a second. 

First, we want to clear the background, or turn off anything on the matrix. 

We'll need the "fill frame with 0" block for this. 

Let's start with the first line. 

The block for doing so can be found in the "Matrix" block section

Check the coordinates we put. The intensity level is set to 100. 

Let's draw the second line now. By right-clicking on this block, you can duplicate it. 

Make sure the coordinates for the second line are changed. 

Don't forget to include the "push frame to matrix" block at the end, or your code will fail. 

Good job!

Now, inside the "showRect" function, write the code. 

In the "Matrix" block section, look for the "draw outlined rectangle" block. 

Feel free to play about with the coordinates and rectangle size.

Remember to include the "push frame to matrix" block once more. 

Let's make those shapes appear in loops one after the other. 

Find the "loop forever" block in the "Loops" block section to do so. 

Put both functions within the blue block.

To create a one-second delay, add the "sleep 1 second" block. 

Now, add another "drawBG" and "sleep 1 second" blocks at the end. 

That's it. 

Great job! 

Click on the Run button and check your code.