The Art
of the
lynxcoding.club
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Introduction!
You will learn about:
2
Use these cards to explore some simple geometric and coding ideas!
Check out the Getting Started Guide before you try these cards.
Or...jump right in!
View it in the User Guides under the Help Menu at lynxcoding.org
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Get a Lynx Account
Details at lynxcoding.club
3
NO Account
You can try Lynx for free without an account, by clicking on Create a Lynx Project on the home page at lynxcoding.club.
FREE TRIAL Account
For full access, register (click Login/Register located at the top, right side of the Lynx web page).
INDIVIDUAL Account
Convert your trial account to a permanent individual account before end of trial period.
Accounts are free for Canadians thanks to a subsidy by the Government of Canada.
We suggest:
• teacher gets a School Administrator Account
• students get permanent Individual Accounts
• teacher creates a ‘club’ and invites all students
SCHOOL ADMINISTRATOR Account
Convert your trial account to a School Administrator account before end of trial period.
Layout of Lynx
4
Save
Add Objects
Files
Procedures
Clipart
Commands
Help
Share
Procedure Pane
Name your Project
Turtle
Work Area (Page)
Command Centre
Clipart Pane
My Projects
Settings
Project Tree
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Start Drawing
In the Command Centre, type:
pd Press Return
fd 100 Press Return
pd puts the pen down. The number is an input. fd 100 is a command telling the turtle to move forward 100 turtle steps (pixels).
Try these:
rt 60 (turn right 60 degrees)
bk 150 (move back 150 steps)
lt 145 (turn left 145 degrees)
Type many commands on one line, then press Return. ‘Arrow up’ to the same line and press Return again!
Experiment with putting the turtle’s penup and pendown before you use forward or back commands.
pu (pen up)
pd (pen down)
Can you:
5
pd (pendown)
pu (penup)
pe (penerase)
fd (forward) bk (back)
rt (right) lt (left)
wait (wait)
e.g., fd 100 wait 2 rt 50
cg (Clears Graphics and puts the turtle in the centre of the page)
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Repeat & [ ]
Type the following in the Command Centre and press Return:
pd
repeat 10 [fd 100 bk 90 rt 3]
This means, “Do this ten times: go forward 10, go back 90, turn right 3.”
Try these. (Use cg to clear graphics—if desired!)
repeat 20 [fd 100 rt 165]
repeat 8 [fd 70 bk 60 rt 45]
repeat 10 [fd 100 rt 140 bk 100 rt 45]
repeat 6 [fd 80 rt 60 bk 80 lt 120 wait 2]
repeat 20 [fd 80 rt 18 wait 2 bk 80 fd 10 wait 2]
LOOK! A repeat inside a repeat!
repeat 10 [repeat 15 [fd 4 rt 15] rt 120]
repeat 9 [repeat 10 [fd 4 rt 20] rt 120]
Add wait commands to slow some of them down a bit.
Try changing one input at a time in some of those examples.
Try putting pu and pd in various spots inside some of those examples.
Try doing the same line over and over again. Pretty cool, eh! Can you write a repeat command to do that automatically?
6
Repeat is a command that saves you lots of work!
Square Brackets [ ]
Square brackets are used to contain a set of instructions—in this case to be ‘repeated’.
You will find the square brackets on your keyboard up near the Return key.
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Make Procedures
A procedure is a group of LYNX instructions with a name you choose. It becomes a new command. Note: it only works inside the project you are working on now!
PARTS OF A PROCEDURE
A procedure has three parts:
Click in the Procedure Pane.
Type something like:
to wiggle
fd 80 rt 60 bk 80 lt 120
end
Type wiggle in the Command Centre.
Change the inputs (values) in the procedure. Try it again.
Can you write a procedure
to make this?
7
You write procedures in the Procedure Pane.
You will have many procedures. Make sure each procedure ends with the word end on a separate line!
If you don’t, you’ll get this error message:
I don’t know how to ‘procedurename’
to wiggle | title line: to — then a space, then a single word for the name of the procedure |
fd 80 rt 60 | body: instructions for the turtle and other objects like text boxes and buttons |
end | last line: this must ONLY be the word end |
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Simple SquARES
Larger or smaller?
If you want to make a larger or smaller square, which number would you change?
Yes. the forward command.
-----------------------------------------------
If you want to draw the square on the other side, what command do you need to change?
Yes. Change right to left. Or use back instead of forward.
Make the smallest square you can.
Make the largest square you can.
Can you make this pattern?
(Hint: Make a square.
Change the fd or rt.
And so on.)
Or this one…
(Hint: Make a square,
then add a command in
Command Centre,
then make square again.)
Make other patterns that you dream up! :-)
8
to square
repeat 4 [forward 100 right 90 wait 2]
end
Total Turtle Trip
When a turtle takes a trip and ends up with the same heading, it has completed a Total Turtle Trip — 360 degrees.
In this case, there are 4 turns. Each turn is 90 degrees.
4 X 90 = 360
Art of the Lynx
An Intro
lynxcoding.club
V1.0
COlour and Size
to squareright
setc 'violet'
setpensize 5
repeat 4 [fd 100 rt 90 wait 2]
end
to squareleft
setc 'orange'
setpensize 5
repeat 4 [fd 100 lt 90 wait 2]
end
Modify the following wiggle procedure by adding setpensize and setc
to wiggle
fd 80 rt 60 bk 80 lt 120
end
Can you make this pattern?
Can you change the background colour using setbg?
Experiment!
9
to bluesquare
setc 'blue'
setpensize 8
repeat 4 [forward 100 right 90 wait 2]
;setc 'blue' makes the square blue
end
setc or setcolour
setbg set background
setc 'red' makes the turtle red
setbg 49 makes the background olive
You don’t need the ' '
There are 140 colours 0 - 139!
setpensize 10 will make a thicker line
Minimum size is 1.
Maximum size is 30.
Art of the Lynx
An Intro
lynxcoding.club
V1.0
TRIANGLES
Making Triangles!
So, you now know the Total Turtle Trip Theorem! You know that the number of the repeats times the angle = 360!
Think about the procedure below - what inputs would you add to create an equilateral triangle? Ready to try it?
to triangle
repeat ? [ fd 100 rt ? ]
end
10
Total Turtle Trip (again!)
When a turtle takes a trip and ends up with the same heading, it has completed a Total Turtle Trip — 360 degrees.
An equilateral triangle is a triangle that has 3 sides of equal length.
Can you make an equilateral triangle that goes to the left? Or an equilateral triangle with shorter (or longer) sides?.
Can you make a pattern similar to this.
Make a triangle pattern of your choice.
Think about using pu, pd, setc, setpensize
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Other Polygons!
Let’s Make Some Polygons!
to pentagon
repeat 5 [fd 100 rt ??]
end
to hexagon
repeat ?? [fd 100 rt 60]
end
What is the rt angle for each of these?
Remember the Total Turtle Trip!
11
The word polygon comes from two Greek words.
The word ‘poly’ means ‘many’ and ‘gon’ means ‘angle’.
The word ‘polygon’ means ‘many angles’.
Make an octagon.
Make a decagon.
Make a polygon with as many sides as you can!
Make a polygon but have the computer do the arithmetic for you to figure out the angle!
Note: You may have to make your sides shorter!!
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Circles!
Think about the circle procedure below - what inputs would you add to create an circle? Ready to try it?
to circle
;remember the Total Turtle Trip
repeat ?? [fd ?? rt ??]
end
What is a circle after all?
Once you discover it—you can have all sorts of fun!
12
Don’t forget about the Total Turtle Trip!
You may have discovered the circle as you played with Other Polygons!
Don’t forget about setc and setpensize.
Can you make:
Create other shapes!
Share them with your friends!
Art of the Lynx
An Intro
lynxcoding.club
V1.0
More Circles!
Try these.
to circle1
repeat 360 [fd 1 rt 1]
end
to circle2
repeat 180 [fd .5 rt 2]
end
to circle3
repeat 720 [fd 1 rt .5]
end
to circle4
repeat 720 [fd .5 rt .5]
end
Why do circle1 and circle4 look the same? Ask your friends to explain it!
13
You can often make the same pattern in different ways!
Be careful with the next examples.
Watch out for those decimal points!
Make the same size circle several different ways!
Make a semicircle.
Make several different size semicircles.
Try to make a pattern like the one below.
Hint:
You’ll have to turn your turtle between semicircles. Or find another solution! :-)
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Subprocedures!
Remember this challenge from the Simple Squares card?
It is much easier with a superprocedure and a subprocedure!
to square
pd
repeat 4 [fd 100 rt 90 wait 2]
pu
end
to 4square
repeat 4 [square rt 90]
end
square is now a subprocedure inside 4square.
14
A subprocedure is a procedure that is used inside another procedure.
A superprocedure is a procedure that contains a subprocedure.
This allows you to make complex programs out of simpler bits!
Write a procedure to make these patterns.
Compare your solutions with your friends!
Is one solution more efficient than another? Why?
Art of the Lynx
An Intro
lynxcoding.club
V1.0
SQUARES - REPEATED!
to square
pd
repeat 4 [fd 100 rt 90 wait 1]
pu
end
to squaremore1
repeat 36 [square rt 10 wait 2 ]
end
to squaremore2
repeat 18 [square rt 20 wait 2 ]
end
15
Can you modify the squaremore3 procedure to create this picture?
to squaremore3
repeat 9 [square rt ?? wait 2 ]
end
What would the angle be if you change the repeats as follows? Try them!
Can you make the computer calculate the angle to turn?
Square is a subprocedure inside squaremore1
Total Turtle Trip
When a turtle takes a trip and ends up with the same heading, it has completed a Total Turtle Trip — 360 degrees.
36 X 10 = 360
18 X 20 = 360
9 X ?? = 360
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Colour & Size
Experiment with Colour and Pensize!
And Random!
Let’s use our squaremore1 procedure.
Add in a random colour change.
to squaremore1
repeat 36 [square rt 10 wait 2 setc random 140 ]
end
Then add in a random pensize too!
to squaremore1
repeat 36 [square rt 10 wait 2 setc random 100 setpensize 1 + random 30 ]
end
16
setc = setcolour
setc random 140 picks a random colour between 0 and 139 — which is 140 colours!
setpensize 1 + random 30 picks a random pensize between 1 and 30.
Note: you need the ‘1 + random 30’ because pensize cannot be zero
Random is useful in games, simulations, math, etc.
Use some of your other polygon procedures to make colourful patterns!
Share your artwork with your friends!
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Colour & Size (Again!)
to square
repeat 4 [fd 100 rt 90 wait 2]
end
to move
pu
rt random 360
fd random 300
pd
end
to squaredance
repeat 50 [move setc random 140 setpensize 1 + random 30 square]
end
Move is a subprocedure inside squaredance.
17
Decomposition
It is good practice to create small procedures (mind-sized bites)!
Breaking down a complex problem into smaller, more manageable parts is decomposition.
It is a cornerstone of computational thinking.
Make some changes to the move procedure.
Make similar changes to the squaredance procedure.
Advice: Just make one change at a time so you can see the effects.
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Fun with Fill!
to square
repeat 4 [fd 100 rt 90 wait 2]
end
to paint
pu rt 20 fd 20 pd
setc random 140
fill
end
to move
pu rt random 360
fd random 300 pd
end
to pattern
setpensize 4
forever [square paint move]
end
18
fill = fill with colour!
setpensize 4 makes a solid square so the fill won’t leak!
forever Do what’s inside the brackets until stopped.
To stop, click the
In move, change:
Make similar changes to the paint procedure.
Try this with other polygons!
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Experiment! Make Art!
19
Make Art
Although there is much more to learn, you are well prepared to experiment with what you know!
You can make wonderful art now.
Revisit all the cards to help you think about how you might make some art.
Your art might be ‘static’ — a lovely picture.
Or, your art might be ‘dynamic’ — with wait commands so you can enjoy the creation!
Reflect on
Your Learning!
You have learned:
• pu, pd, fd, bk, rt, lt
• cg, wait, repeat, [ ]
• setc, setpensize, fill
• setbg, random
• forever, stop
• to, end, procedures & subprocedures
• Total Turtle Trip
You might want to create a setup procedure — similar to this one. Then write a procedure such as art.
to setup
setc random 140
pu
rt random 360
fd random 200
pd
end
to art
setup
;your lines of commands and subprocedures go here!
end
Art of the Lynx
An Intro
lynxcoding.club
V1.0
Credits
Principal Writer……….. Peter Skillen
Contributors………....... Michael Quinn
Brenda Sherry
Translator.. …………….. Alain Tougas
20
Geometric Fun by Code To Learn is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Art of the Lynx
An Intro
lynxcoding.club
V1.0