Nov 232021
Recap
- What is a procedure?
- How do we code a procedure?
- How do we make a new procedure?
New skill
Procedure with variables = procedures that can draw different sizes (or colours, shapes,…)
Here’s the original c procedure:
to c
fd 20 rt 90 fd 20 bk 20 lt 90 bk 20 rt 90 fd 20 lt 90
end
Here’s an example of a c procedure with variable. What is the difference?
to c :size
fd :size rt 90 fd :size bk :size lt 90 bk :size rt 90 fd :size lt 90
end
Tasks
- Open this fie c size procedure and save it as your onw
- Make it draw bigger and smaller Cs in different places (use pu setxy 100 100 pd between each c shape)
- Add another variable :pen that changes the pen size
- Add :pen to the “to” line after :size
- Inside the procedure add a line setpensize :pen
- When you type c, you now need two numbers – how big and how thick the pen is.
- Add a second number to your Cs to make 5 Cs with different sizes and thicknesses
- ** Write your own letter procedure with a variable :size instead of fd/bk numbers
- *** Can you include a :col variable to choose the colour?
See these posts for more ideas and techniques:
- Draw letter rainbows, flowers and shapes
- Stars and shapes 2
- Stars and shapes 1
- The power of procedures with variables
- Use variables to draw spirals
- Use variables to draw shapes
- Random
- Repeat, setxy, procedures
LOGO example files – can you work out how they work?