# Spirals

This week we looked at drawing in Scratch, using the Pen blocks and some simple maths to draw some crazy Spiral patterns.

As always, we started with a Plan:

## A Plan

1. A Button Sprite – to start the drawing.
2. A Simple Sprite to do the drawing.
3. Some maths to make it draw a Spiral

To draw a spiral in Scratch we used the Pen down, Turn and Move blocks. We had to make sure that we moved a little bit further after each turn. We also decided that we should be able to make spirals with different shapes.

We needed some variables to help:

• Sides – This would tell us how many sides the Spiral should have
• We made this in to a Slider on the screen so it was adjustable.
• Min value was 2 and Max value was 100
• Extra – This would tell us how much “Extra” to turn, this made the patterns a lot more interesting.
• Again, we made this one into a Slider so we could adjust it.
• Min value was 0 and Max value was 360
• Steps – This was an internal variable, which we used to keep track of how many Steps to move each turn, we also added a little bit to it each turn to make the Spiral pattern.

## The drawing Sprite

This was the Sprite that did all the work. As we had some Data variables and we wanted a blank screen to start drawing on, we had some code that would run on the Green Flag to set everything to where it should start from:

We then did the code that would draw the Spiral. First it reset everything again, then it would repeat until the Sprite touched the edge, we did this differently in class, but both ways will work.

To work out how many Steps to take each time, we added (1/Sides) before each Turn, this gave us a nice slow increase in the number of Steps to Move each time.

To work out how far we should Turn each time, we divided 360 by the number of Sides, we then added the Extra value to get the strange effects working.

The code ended up looking like this:

Note: I noticed afterwards that the repeat Sides, was not necessary, but never mind.

## The Button – to start the drawing.

This was just a simple Sprite, with 2 costumes, when it was clicked we just changed the costume to show that it had been clicked and then Broadcast “Start” to let the other Sprite know it was time to start drawing.

The code that we used for the button was quite simple:

## The Stage

Some people changed the Stage to a dark colour which helped make the Patterns stand out a lot more.

This is a sample of one of the Spirals that was drawn.

# Notes:

The project that we built is available on the Scratch Web Site:

Remember, you can put your own projects up there as well if you want.