HELLO

WELCOME TO AHMED PAGE

HI GUYS I WILL TEACH HOW TO USE LOGO

I will first show how to Use logo:

Command what it does

FD 100 Move the turtle forward 100 steps.

RT 90 Turn the turtle to the right 90º.

LT 90 Turn the turtle to the left 90º.

BK 100 Move the turtle backwards 100 steps.

PU Pick the turtle's pen up off the paper.

PD Put the turtles pen back down on the paper.

CS Clear the screen and start over.

HT Hide the turtle (triangle).

ST Show the turtle (triangle).

REPEAT 3 [...] repeat the commands 3 times.








Turtle Basics



The turtle looks like a little triangle in the middle of the screen. The head shows you which direction he is facing. When the turtle moves he draws a line behind him.




You can turn the turtle by telling him to turn RIGHT or LEFT. This pictures shows how to make the turtle turn in different directions. Instead of typing out RIGHT and LEFT I use the smaller words RT and LT, which mean the same thing to the turtle.

FD 100

To get the turtle to draw a line, just tell him to move FORWARD a number of steps (turtles take small steps, so you need to tell him to move FORWARD many steps, like 100, to get him to move enough to see). I like to use the smaller word FD instead of typing FORWARD. Both work the same way.





To get the turtle to draw a shape, like a square, you can give him the instructions he needs to "walk" around the shape of a square.













Polygons

One of the easiest things to do in logo is use the turtle to draw various polygons. You can notice that in order to draw a closed polygon, the turtle has to walk around the edges, eventually turning through 360 degrees before coming back home. Since the turtle makes N turns for an N-sided polygon, the size of each turns in 360/N degrees.

Triangle (3 sides)
Turtle Turns 120º

REPEAT 3 [FD 100 RT 120]

Square (4 sides)
Turtle Turns 90º

REPEAT 4 [FD 100 RT 90]

Pentagon (5 sides)
Turtle Turns 72º

REPEAT 5 [FD 100 RT 72]

Hexagon (6 sides)
Turtle Turns 60º

REPEAT 6 [FD 100 RT 60]

Septagon (7 sides)
Turtle Turns 51º

REPEAT 7 [FD 100 RT 51]

Octagon (8 sides)
Turtle Turns 45º

REPEAT 8 [FD 100 RT 45]







Fun with Repeat

You can have fun with the REPEAT command just by changing three numbers!

Which three numbers make your favorite drawing?

CS REPEAT __ [FD ___ RT ___]

Try this! What does it draw?

CS REPEAT 100 [FD 10 RT REPCOUNT]



Make Your Own Words

One of the coolest things about Logo is that you can make your own words that do whatever you want them to do. When you make a word, you can use it in other commands and programs just as if it was part of Logo to begin with.

What if we want to draw a lot of squares. Each time we have to type in:

REPEAT 4 [FD 100 RT 90]

That's not a whole lot of typing, but wouldn't it be nice if we could just type:

SQUARE

You can teach LOGO what a "SQUARE" is like this:

TO SQUARE
    REPEAT 4 [FD 100 RT 90]
END

Now we can use our new word to make cool new programs. Can you figure out what this does?

REPEAT 36 [SQUARE RT 10]







Words that Use Numbers or make it larger:

The words we know in LOGO can do something different if you type different numbers after them. FD 100 draws a line with 100 steps in it, and FD 50 draws a line with only 50 steps in it.

We can make our new words use numbers too. Let's change our SQUARE word to draw squares of different sizes:

TO SQUARE :SIZE
    REPEAT 4 [FD :SIZE RT 90]
END

Now you can tell logo to:

SQUARE 50

Or

SQUARE 100

Here's another cool program. What does it do?

REPEAT 100 [SQUARE REPCOUNT RT 10]



















Now I will give you some think from my cool designs

The Grand Prize (the Golden Turtle)


Five Rose or Starfish

repeat 1800 [fd 10 rt repcount + .1]

The "Pure Logo" Prize


Dahlia

repeat 8 [rt 45 repeat 6 [repeat 90 [fd 2 rt 2] rt 90]]

The 6 can be replaced with 1 to 7 for other flowers.
For numbers greater than 7, the patterns repeat.
This will work without modification in absolutely all Logo implementations.


The "Complexity" Prize


Layers

for [i 0 420] [seth :i repeat :i [fd 2 rt 1] pu home pd]
dotimes [i 420] [seth :i repeat :i [fd 2 rt 1] pu home pd]
(MicroWorlds)

This is slow, but it has very beautiful and complex moire patterns. If your screen is small, let it wrap. The moire effect isn't as strong if you try to shrink it.


The "Classic Math" Prize

Lissajous variations

repeat 360 [setxy (sin(2 * repcount)) * 150 (sin(3 * repcount)) * 150]
repeat 360 [setxy (sin(89 * repcount)) * 150 (sin(179 * repcount)) * 150]
repeat 360 [setxy (sin(254 * repcount)) * 150 (sin(201 * repcount)) * 150]
repeat 360 [setxy (sin(327 * repcount)) * 150 (sin(66 * repcount)) * 150]

dotimes [i 360] [setpos list (sin(254 * :i)) * 150 (sin(201 * :i)) * 150] (MicroWorlds)

Change the factors to get lots of different designs.


The "Random" Prize


Pencil Sketch

repeat 5000 [run list item sum 1 random 4 [fd bk rt lt] random 10]

This looks remarkably like a person is sketching with a pencil. It looks even more like a pencil sketch if you use PENREVERSE (PX) mode.


The "Polygon" Prize


Penta-octagon

for [l 10 80 5] [repeat 5 [repeat 8 [fd :l rt 45] rt 72]
dotimes [i 15] [repeat 5 [repeat 8 [fd (10 + (:i * 5)) rt 45] rt 72]
(MicroWorlds)

Beautiful "telescoping" polygons. Change the numbers to get more designs.
(See the "octa-octagon" below.)


The "Animation" Prize


Circus (Ring variation 2

px setpensize [100 100] repeat 1000 [repeat 72 [fd 20 rt 10] rt 90]

This requires PENREVERSE (PX) and a big pen.
This cheerful entry reminds me of circus jugglers and clowns doing cartwheels.

Other ring variations


The "Subtle Effects" Prize


Radar

px repeat 1000000 [fd 40 fd 40 bk 80 rt 1]

This requires PENREVERSE (PX).
It looks like a weather radar. [It is in constant motion.]
The really interesting part is that the effect is entirely destroyed
if you replace "fd 40 fd 40" by "fd 80".

Note: The first four "entries" shown here were among some samples provided by Keith Enevoldsen in announcing the Logo 15-word challenge.


Slalom Scrolls

for [i 0 2000] [fd 5 rt (90 * sin :i)]


Hairy Star

for [i 0 4700] [fd 10 rt (180 * sin (:i * :i))]

index



Jaggy Star

for [i 0 2200] [fd (25 * sin :i) rt (:i * :i)]

index



Bullring

for [i 0 1002] [fd 8 seth (360 * (power :i 3) / 1002)]

REFERENCES
"Another Fine Math You've Got Me Into..." by Ian Stewart contains an interesting chapter about curves like these. The "bullring" is from Ian Stewart's book.

index



Random Lines

repeat random 1000 [fd random 1000 rt random 360]

(This usually produces Jackson Pollacks, but there is a chance that it will produce a Michelangelo.) Depending on what random numbers the computer chooses, you may get something like one of the three images above.

index



Square Spiral variation 1

px for[x 1 1000000] [fd :x rt 89.99]


Square Spiral variation 2

make "x 1 repeat 150 [fd :x rt 89 make "x :x + 1]
for [x 1 150] [fd :x rt 89]




Sine Wave

sety 1000 home setx 1000 for [x -180 180] [setxy :x 70 * sin :x]




Radar variation 1

repeat 3600 [px fd 80 fd 0 bk 80 lt random 360]


Radar variation 2

px repeat 10000 [fd 200 rt 179]



Brownian Motion

repeat 10000 [fd 3 * (-1 + random 2) rt 90 * random 4]

(Maybe it should be named urban sprawl.)



Feathers

repeat 12 [repeat random 50 [fd 100 bk 95 rt 2] rt 180]


Feathers variation 1

repeat 50 [repeat random 100 [fd 300 bk 295 rt 2] rt 180]



Spiral

reset for [i 0.01 4 0.05] [repeat 180 [fd :i rt 1]]



Ring

px setpensize [20 20] repeat 100000 [fd 2 rt 2]

(Looks like a caterpillar in motion.)


Ring variation 1

px setpensize [200 200] repeat 36 [fd 20 rt 10]



Cubism (Ring variation 3)

px for [x 10 200] [setpensize se :x :x repeat 36 [fd 20 rt 15]]




Milky Way

setsc [0 0 0] px setpensize [10 10] repeat 100000 [fd 10 rt random 360]




Inky Dots

setpensize [10 10] repeat 10000 [pu fd 15 pd fd 0 rt random 360]


Inky Dots variation 1

px setpensize [10 10] repeat 10000 [pu fd 15 pd fd 0 rt random 360]




Rose, by M.H. Elhefni

for [t 0 180 3] [seth :t fd 200 * sin :t home]


Rose variation 1

for [t 0 180] [seth :t fd 200 * sin :t*7 home]


Rose variation 2

repeat 9 [for [i 10 200 10] [fd :i bk :i rt 2]]




Lissajous, by M.H. Elhefni, Egypt (15 words)

for [t 0 360] [setxy 200 * sin :t 200 * cos :t * 5]




Times

for [i 1 10] [repeat 10 [type form repcount * :i 4 0] pr[]]

(This one uses the text screen.)



Shell

for [scr .2 1.75 .05] [setscrunch 1 :scr repeat 360 [fd :scr rt 1]]



Hypercube

repeat 8 [repeat 4 [rt 90 fd 100] bk 100 lt 45]



Scribble

repeat 1000 [fd 3 rt random int 20 * (1 + sin (10 * repcount))]



Fan Flower

repeat 12 [repeat 75 [fd 100 bk 100 rt 2] fd 250]



Current

repeat 5100 [fd 10 rt arctan (remainder repcount 100) / 100]



Elliptical Spiral

reset repeat 3600 [setxy repcount / 10 * sin repcount repcount/20 * cos repcount]



Tree Growth Rings

repeat 36000 [setxy (sqrt repcount) * sin repcount (sqrt repcount) * cos repcount]



Cloudy Night

repeat 6000 [fd repcount rt remainder repcount 360]



Simple Flower

repeat 11 [for [i 0 359] [fd 1 rt (sin :i / 2)]]

(Why does the line match up exactly after drawing 11 petals?)



Seconds

px st setpensize [5 5] repeat 1000 [fd 100 wait 40 bk 100 rt 6]

(Clever use of the triangular turtle. The second hand continually moves as it is drawn, erased, and repositioned.)

Face

pu rt 30 repeat 12 [fd 110 pd label repcount pu bk 110 rt 30]

(Try this: first run Face, then, without clearing the screen, run Seconds.)


Self-Replicating

invoke [[x] print (list "invoke :x :x)] [[x] print (list "invoke :x :x)]

(This non-graphics one-liner prints itself.)



Basic Spinning Wheel variations 1-3, by Greg Simkins' 6th grade class, U.S. (15 words)

define "spin [[ ][repeat 15 [fd 100 bk 100 rt 5]]] repeat 25 [spin fd 100]
define "spin [[ ][repeat 15 [fd 100 bk 95 rt 10]]] repeat 12 [spin fd 100]
pu setpos [-400 0] pd
define "spin [[ ][repeat 25 [fd 100 bk 100 rt 15]]] repeat 24 [spin fd 100]

Basic Spinning Wheel variations 1-3

repeat 25 [repeat 15 [fd 100 bk 100 rt 5] fd 100]
repeat 12 [repeat 15 [fd 100 bk 95 rt 10] fd 100]
pu setpos [-400 0] pd
repeat 24 [repeat 25 [fd 100 bk 100 rt 15] fd 100]



Low

pu setx -100 pd
for [i 0 32] [repeat :i [fd :i rt 358 / :i] bk sqrt :i]



Sun

repeat 2000 [pu home seth random 361 fd 40 pd fd random 200]



Hexagon

for [i 100 30 -50] [repeat 6 [repeat 6 [fd :i lt 60] lt 60]]

(Quasi-fractal.)


Hexagon variation 1

for [size 20 80 20] [repeat 6 [repeat 6 [fd :size rt 60] rt 60]]


Hexagon variation 2, by M.H. Elhefni, Egypt (15 words)

for [i 100 10 -5] [repeat 6 [repeat 6 [fd :i lt 60] lt 60]]



Pentahexagon

repeat 5 [repeat 6 [fd 100 lt 72] lt 144]


Pentahexagon variation 1, by M.H. Elhefni, Egypt (15 words)

for [i 100 10 -5] [repeat 5 [repeat 6 [fd :i lt 72] lt 144]]



Pentagon,

for [i 100 10 -10] [repeat 5 [repeat 5 [fd :i lt 72] lt 72]]



Moire

window repeat 180 [fd 500 bk 500 rt 2]



Fireworks

for [i 0 220 0.0001*sin :i] [fd :i bk :i rt 10]



Peltonwheel, by M.H. Elhefni, Egypt (14 words)

for [i 0 220 sin :i/1000] [fd :i bk :i rt 51]



Spirals

for [i 0 220 sin :i/1000] [fd :i bk :i rt 41]



Gillyflower

repeat 450 [make "a 73 * sin repcount fd :a rt 88 * cos :a]



Growing Scrolls variation 1

for [i -1 4] [repeat 720 [fd power 2 :i rt repcount]]


Growing Scrolls variation 2

for [i -1 15] [repeat 720 [fd power 1.2 :i rt repcount] lt 45]


Growing Scrolls variation 3

for [i 1 14 6] [repeat 720 [fd :i rt repcount]]


Growing Scrolls variation 4

for [i 1 18 2] [repeat 720 [fd :i rt repcount] lt 45]



Mountains

repeat 2000 [setxy (repcount * 2) (ycor - 2 + random 5)]




Eye

repeat 1800 [fd ln repcount bk 10*sin repcount rt 10]



Growing

repeat 360 [repeat repcount [repeat repcount [fd repcount lt 15] home] lt 1]

(You may want to stop it before it is done.)



Don Quixote

px repeat 360 [repeat repcount [repeat repcount [fd repcount lt 15] home] lt 1]

(Read the book.)




Ellipse

repeat 360 [rt repcount fd 1 lt repcount * 2 fd 0.5 rt repcount]

(The eccentricity is e=0.5. If e=0, you have a circle and if e < 0 or e > 0 you have an ellipse, horizontal or vertical.
See Abelson-Di Sessa: "Turtle geometry".)



Polygon variations 1-3

repeat 4 [repeat 30 [lt 90 fd 4 rt 90 fd 4] rt 90]

repeat 4 [repeat 20 [lt 160 fd 20 rt 160 fd 20] rt 90]

repeat 8 [repeat 20 [lt 170 fd 20 rt 170 fd 20] rt 45]



Rotating Circle, by M.H. Elhefni, Egypt (11 words)

px repeat 4000 [repeat 34 [fd 12 rt 10] rt 90]



Smiling Fish

pu setx -157 pd
for [t -315 315] [setxy :t * sin :t :t * cos 2 * :t]

(It looks better like this:
for [t -315 315] [setxy :t * sin :t .5 * :t * cos 2 * :t]
as pictured above, but then it is too many words.)



Bird's Wings

repeat 360 [setx 200 * (sin repcount) sety xcor * (cos 2 * repcount) home]



Butterfly

repeat 360 [setx 200 * (sin 2 * repcount) sety xcor * (cos repcount) home]



Fish

repeat 360 [setx 200 * (cos 2 * repcount) sety xcor * (cos repcount) home]



Block

repeat 25726 [setpos se (50 - random 100) (50 - random 100)]



Octa-star Spiral

for [l 0 120 4] [repeat 8 [fd :l rt 135] fd :l rt 30]



Penta-star Spiral

for [l 0 95 3] [repeat 5 [fd :l rt 144] fd :l rt 30]



Designs 1-5, by Alex Mylonas' class, Greece (12 - 14 words)

repeat 36 [fd 60 rt 61 bk 80 lt 41 fd 85 rt 41]
repeat 16 [fd 85 lt 60 fd 107 bk 72 lt 53 fd 74]
repeat 100 [fd 5 + repcount rt 45 fd 10 + repcount rt 60]

repeat 36 [repeat 36 [fd 10 rt 10] fd repcount rt 90 fd repcount]

repeat 18 [repeat 5 [rt 40 fd 100 rt 120] rt 20]

















Now I will give you some places of logo on the internet

  1. math cat

Logo Programming

  1. Learning logo

  2. Logo (programming language)

  3. logo