~tony-badwolf/python-snippets/patterns-snippets

« back to all changes in this revision

Viewing changes to pyturtle/tdemo_I_dontlike_tiltdemo.py

  • Committer: Jono Bacon
  • Date: 2010-04-24 18:14:20 UTC
  • mfrom: (93.3.2 python-snippets-bzr)
  • Revision ID: jono@system76-pc-20100424181420-hup208wuekhvr1qc
A bunch of PyTurtle snippets. Thanks, Grant!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# [SNIPPET_NAME: Elipses]
 
4
# [SNIPPET_CATEGORIES: PyTurtle]
 
5
# [SNIPPET_DESCRIPTION: Use turtle to draw elipses.]
 
6
# [SNIPPET_DOCS: http://docs.python.org/library/turtle.html]
 
7
# [SNIPPET_AUTHOR: Grant Bowman <grantbow@ubuntu.com>]
 
8
# [SNIPPET_LICENSE: PSF]
 
9
# Code authorship from http://python.org/download/releases/2.6.4/
 
10
 
 
11
 
 
12
"""       turtle-example-suite:
 
13
 
 
14
     tdemo-I_dont_like_tiltdemo.py
 
15
 
 
16
Demostrates
 
17
  (a) use of a tilted ellipse as
 
18
      turtle shape
 
19
  (b) stamping that shape
 
20
 
 
21
We can remove it, if you don't like it.
 
22
      Without using reset() ;-)
 
23
 ---------------------------------------
 
24
"""
 
25
from turtle import *
 
26
import time
 
27
 
 
28
def main():
 
29
    reset()
 
30
    shape("circle")
 
31
    resizemode("user")
 
32
 
 
33
    pu(); bk(24*18/6.283); rt(90); pd()
 
34
    tilt(45)
 
35
 
 
36
    pu()
 
37
 
 
38
    turtlesize(16,10,5)
 
39
    color("red", "violet")
 
40
    for i in range(18):
 
41
        fd(24)
 
42
        lt(20)
 
43
        stamp()
 
44
    color("red", "")
 
45
    for i in range(18):
 
46
        fd(24)
 
47
        lt(20)
 
48
        stamp()
 
49
 
 
50
    tilt(-15)
 
51
    turtlesize(3, 1, 4)
 
52
    color("blue", "yellow")
 
53
    for i in range(17):
 
54
        fd(24)
 
55
        lt(20)
 
56
        if i%2 == 0:
 
57
            stamp()
 
58
    time.sleep(1)
 
59
    while undobufferentries():
 
60
        undo()
 
61
    ht()
 
62
    write("OK, OVER!", align="center", font=("Courier", 18, "bold"))
 
63
    return "Done!"
 
64
 
 
65
if __name__=="__main__":
 
66
    msg = main()
 
67
    print msg
 
68
    mainloop()