- Open this LOGO file: Rainbow
- Look at the code carefully
- Can you put in the rest of the code to draw a rainbow?
- Save your work
- j2launch –
- Click on Level 3
- Type these two instructions:
reset
setpensize 5
- Can you draw a letter?
- Use these commands:
- fd 30 (or other numbers)
- bk 30 (or other numbers)
- lt 90
- rt 90
- (Diagonal letters will need rt 45 or lt 45)
- Press play each time to see if it works – don’t carry on until you are happy with each instruction.
- If you finish one letter, type
- pu (pen up)
- move to a new place using fd, lt, rt…
- pd (pen down)
- Try another letter
Challenges
- Change the pensize to 30
- Could you make different letters different pensizes?
- For a letter that contains a square, use this square code
- repeat 4 [fd 80 rt 90]
- Change the colour of each letter by putting this code before the letter code:
- colour “blue
- Start a new project in LOGO
- Copy this code (copy and paste)
reset
setpensize 5
to rect :h :w :x :y
pu setxy :x :y pd
repeat 2 [fd :h rt 90 fd :w rt 90]
end
- Now you can draw any size rectangle anywhere on the page by typing:
- rect 30 60 100 -50
- The first two numbers and the height and width
- The second two numbers are the x-coordinate and y-coordinate
- The page goes from
- -250 to 250 left to right
- -250 to 250 bottom to top
- The page goes from
- MAke a picture out of rectnangles
- ** Add a colour variable to the procedure
- ** Add another variable, eg
- pensize
- angle (dn’t forget to change the angle back again)
- make it a parallelogram (one angle :ang, other angle (180 – :ang) )
Think of all the things you can draw in LOGO:
- Lines = fd 50 or bk 50
- Turns = rt 90 or lt 90 (or other angles)
- Circles = circle 50
- Squares = repeat 4 [fd 50 rt 90]
- Shapes = repeat ? [fd 50 rt 360/?] (/ means divide; ? means number of sides)
- Stars = repeat ? [fd 50 rt 360 /? -180] same as shapes but change the angles; ? bigger than 8
- Spirals = see last post for Y5
- Colours = colour “blue
- Moving without drawing = pu setxy 100 100 pd
- Shading = fill (fills the area you are in with the current colour)
- Pen thickness = setpensize 5
- Procedures = to newthing …instructions… end
- Procedures with variables = to newthing :size :col …. end
- Call procedure with variables = newthing 50 “blue
- Make/change variables = make “length 50
- Use variables = fd :length
- Increase variables = make “length :length + 1
Your task
- Design and draw a picture with different elements (could doa uick sketch in j2e5).
- Use as many skills from the list above as you can
- You can copy and paste code from your previous projects
- Lavel your code with comment lines starting with semi colon ; ,eg
- ;———-Wheel———–
Ideas
- A car or vehicle
- A robot
- A house or building
Think of all the things you can draw in LOGO:
- Lines = fd 50 or bk 50
- Turns = rt 90 or lt 90 (or other angles)
- Circles = circle 50
- Squares = repeat 4 [fd 50 rt 90]
- Shapes = repeat ? [fd 50 rt 360/?] (/ means divide; ? means number of sides)
- Stars = repeat ? [fd 50 rt 360 /? -180] same as shapes but change the angles; ? bigger than 8
- Spirals = see last post
- Colours = colour “blue
- Moving without drawing = pu setxy 100 100 pd
- Shading = fill (fills the area you are in with the current colour)
- Pen thickness = setpensize 5
- Procedures = to newthing …instructions… end
- Make/change variables = make “length 50
- Use variables = fd :length
- Increase variables = make “length :length + 1
Your task
- Design and draw a picture with different elements (could doa uick sketch in j2e5).
- Use as many skills from the list above as you can
- You can copy and paste code from your previous projects
- Lavel your code with comment lines starting with semi colon ; ,eg
- ;———-Wheel———–
Ideas
- A car or vehicle
- A robot
- A house or building
Warm up
- Read learning conversations, correct code
- Typing
Recap
- Following instructions….
- Variables
- 360/:sides
- setxy
- Efficient code
Success steps
- Follow instructions
- Try to understand why it works
- Debug by yourself
- Tinker with your code
- Copy and paste images to a j2e5 page
Let’s go: What is a spiral?
- Start a new LOGO file
- Type: reset setpensize 5
- Save it as spiral
- Lets set up two variables:
- make “sides 4
- make “length 30
- Copy this code:
- repeat 10
- [
- fd :length rt 360/:sides
- ]
- Play – it should just draw a square over itself a few times
- To make it a spiral, we need to make the length longer each time.
- Put the following code at the end but before the ] bracket:
- make “length :length + 10
- This should draw a spiral…if not, debug
- Tinker: Try:
- different values of “sides at the start
- increase the repeat number
- changing how much you add to “length in step 5.3
- adding a new variable called “pen (make “pen 3) then add these lines in the repeat brackets:
- setpensize :pen
- make “pen :pen + 1
- Right hand click each spiral and copy and paste it into a j2e5 page to show what spirals you have made.
- Create a page with at least 6 spirals on
Finished?
In a new LOGO file, type this simple code, play it then tinker with it…
reset
repeat 250 [forward repcount rt 89]
You may copy and paste code from these instructions to save time typing.
Start a new LOGO file
Type:
reset
setpensize 5
Copy the following PROCEDURE:
to snowflake
repeat 6 [fd 20 bk 20 rt 60]
end
Now whenever you want to draw a snowflake, you just have to write snowflake rather than typing all of the code for a snowflake. The code above is called a PREOCEDURE – it teaches the computer a new word and what it means.
Try this
snowflake
repeat 10 [snowflake fd 20 rt 36]
Why did we use the numbers 10 (for repeat) and 36 (for the right turn)?
You can also add a VARIABLE to a procedure. Change the snowflake procedure to this:
to snowflake :size
repeat 6 [fd :size bk :size rt 60]
end
Now when you call snowflake, you need to put a number with it, which will be how big it is.
Try this:
snowflake 50
snowflake 100
You can add other variables to the snowflake too. Change the procedure to this:
to snowflake :size :col :pensize
colour :col
setpensize :pensize
repeat 6 [fd :size bk :size rt 60]
end
Then type for example: snowflake 60 “blue 10
Let’s make a snowstorm…
Copy this code:
repeat 100
[
pu setxy (250 – random 500) (250 – random 500) pd
snowflake random 50 “blue random 15
]
Now tinker, play, experiment…
You could add this after the reset: colour “blue fill then make your snowflakes white