コード例 #1
0
ファイル: polygon.py プロジェクト: peterfuchs1/Bruch
from myworld.TurtleWorld import TurtleWorld
from myworld.World import wait_for_user
from myworld.MyTurtle import MyTurtle

# the following condition checks whether we are
# running as a script, in which case run the test code,
# or being imported, in which case don't.

if __name__ == '__main__':
    world=TurtleWorld()    
    bob=MyTurtle()
    bob.delay = 0.001

    # draw a circle centered on the origin
    radius = 100
    #bob.pu()
    bob.fd(radius)
    bob.lt()
    #bob.pd
    bob.square(radius)
    bob.circle(radius)
    bob.die()
    wait_for_user()
    

コード例 #2
0
ファイル: markus.py プロジェクト: peterfuchs1/Bruch
from myworld.TurtleWorld import TurtleWorld
from myworld.World import wait_for_user
from myworld.MyTurtle import MyTurtle

import math

# the following condition checks whether we are
# running as a script, in which case run the test code,
# or being imported, in which case don't.

if __name__ == '__main__':
    world=TurtleWorld()
# Wir erzeugen einen Turtle
    turty=MyTurtle()
# Der Turtle wartet auf uns
    turty.delay = 0.4

# Die Laenge betraegt 100 Punkte
    laenge = 100
    baum=laenge/2
# Wir drehen turty um 90
    turty.lt(90)
# Wir zeichen ein Quadrat
    turty.square(laenge)
# Wir gehen auf das Quadrat hinauf    
    turty.move(laenge)
# Der linke Giebel    
    turty.lt(45)
    turty.fd(laenge/2*math.sqrt(2))
# und nun der rechte Giebel    
    turty.lt(90)
コード例 #3
0
ファイル: flower.py プロジェクト: peterfuchs1/Bruch
from myworld.TurtleWorld import TurtleWorld
from myworld.World import wait_for_user
from myworld.MyTurtle import MyTurtle

# the following condition checks whether we are
# running as a script, in which case run the test code,
# or being imported, in which case don't.

if __name__ == '__main__':
    world=TurtleWorld()    
    bob=MyTurtle()
    bob.delay = 0



# draw a sequence of three flowers, as shown in the book.
    bob.move( -100)
    bob.draw_flower( 7, 60.0, 60.0)

    bob.move(100)
    bob.draw_flower(10, 40.0, 80.0)

    bob.move(100)
    bob.draw_flower(20, 140.0, 20.0)

    bob.die()
    wait_for_user()

コード例 #4
0
ファイル: pie.py プロジェクト: peterfuchs1/Bruch
from myworld.TurtleWorld import TurtleWorld
from myworld.World import wait_for_user
from myworld.MyTurtle import MyTurtle

# the following condition checks whether we are
# running as a script, in which case run the test code,
# or being imported, in which case don't.

if __name__ == '__main__':
    world=TurtleWorld()    
    bob=MyTurtle()
    bob.delay = 0



# draw a sequence of three flowers, as shown in the book.
    bob.move( -130)

# draw polypies with various number of sides
    size = 40
    bob.draw_pie(5, size)
    bob.draw_pie(6, size)
    bob.draw_pie(7, size)
    bob.draw_pie(8, size)
    bob.die()
    wait_for_user()