This week Eoin led the Advancers group, we looked at drawing in Scratch, using the Pen blocks and some simple maths to draw some patterns.
As always, we started with a Plan:
- A Button Sprite – to start the drawing.
- A Simple Sprite to do the drawing.
- Some maths to make it draw a Spiral
We started by drawing a square, to draw a square in Scratch we used the Pen down, Turn and Move blocks.
To get a spiral effect we had to make sure that we moved a little bit further each time we drew our square.
We also decided that we should be able to make spirals with different shape so we needed some variables to help:
- Shape – 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 3 and Max value was 100
- Degrees – 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
- Size – 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. To work out how far we should Turn each time, we divided 360 by the number of Sides, we then added the degrees value to get the strange effects working.
The code ended up looking like this:
The Button Sprite
We used this sprite to start drawing, we used a broadcast so out button sprite could “talk” to out drawing sprite.
Oliver will be back next Saturday.
See you all then Declan and Eoin