User:FluffyDunlop/Networked Prototyping/Turtle: Difference between revisions
From XPUB & Lens-Based wiki
|
|
Line 1: |
Line 1: |
| _________ _______ _________ _ _______
| |
| \__ __/|\ /|( ____ )\__ __/( \ ( ____ \
| |
| ) ( | ) ( || ( )| ) ( | ( | ( \/
| |
| | | | | | || (____)| | | | | | (__
| |
| | | | | | || __) | | | | | __)
| |
| | | | | | || (\ ( | | | | | (
| |
| | | | (___) || ) \ \__ | | | (____/\| (____/\
| |
| )_( (_______)|/ \__/ )_( (_______/(_______/
| |
|
| |
|
| <gallery>
| |
| File:Turtle_01.png|Turtle Test 1
| |
| File:Turtle_02.png|Turtle Test 2
| |
| File:Turtle_03.png|Turtle Test 3
| |
| File:Turtle_04.png|Turtle Test 4
| |
| File:Turtle_05.png|Turtle Test 5
| |
| </gallery>
| |
|
| |
| EXAMPLE 1
| |
| <source lang="python">
| |
| import turtle
| |
| import random
| |
|
| |
| turtle.setx(0)
| |
| turtle.speed("fastest")
| |
| turtle.home()
| |
| turtle.setheading(0)
| |
| home = 50,50
| |
| fwd = 80
| |
| def once():
| |
| for i in range(1):
| |
| turtle.left(10)
| |
| turtle.forward(fwd)
| |
| turtle.dot(5)
| |
| turtle.right(20)
| |
| turtle.forward(fwd)
| |
| turtle.dot(4)
| |
| turtle.left(40)
| |
| turtle.forward(40)
| |
| turtle.dot(3)
| |
| turtle.right(80)
| |
| turtle.forward(20)
| |
| turtle.dot(2)
| |
| turtle.left(160)
| |
| turtle.forward(10)
| |
| turtle.dot(1)
| |
| def once1():
| |
| for i in range(1):
| |
| turtle.left(10)
| |
| turtle.forward(fwd)
| |
| turtle.dot(5)
| |
| turtle.right(20)
| |
| turtle.forward(fwd)
| |
| turtle.dot(4)
| |
| turtle.left(40)
| |
| turtle.forward(20)
| |
| turtle.dot(3)
| |
| turtle.right(80)
| |
| turtle.forward(10)
| |
| turtle.dot(2)
| |
| turtle.left(160)
| |
| turtle.forward(5)
| |
| turtle.dot(1)
| |
|
| |
| for i in range (30):
| |
| once()
| |
| fwd = fwd + 5
| |
| for i in range (30):
| |
| once()
| |
| fwd = fwd + 10
| |
| for i in range (30):
| |
| once()
| |
| for i in range (30):
| |
| once()
| |
| fwd = fwd + 15
| |
| for i in range (30):
| |
| once()
| |
| fwd = fwd + 20
| |
| for i in range (30):
| |
| once()
| |
| turtle.mainloop()
| |
| </source>
| |
|
| |
| EXAMPLE 2
| |
| <source lang="python">
| |
| import turtle
| |
| import random
| |
| turtle.speed("fastest")
| |
| turtle.penup()
| |
| home = 50,50
| |
| des = 0
| |
|
| |
| def method():
| |
| turtle.left(10)
| |
| turtle.forward(160)
| |
| turtle.dot(5)
| |
| turtle.right(20)
| |
| turtle.forward(80)
| |
| turtle.dot(4)
| |
| des = des + 1
| |
|
| |
| for i in range(1000):
| |
| method
| |
|
| |
| #turtle.mainloop()
| |
| </source>
| |
Latest revision as of 09:27, 8 September 2016