From 891a1f86d415779cf67ca23e626a868e586feb05 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 29 Jun 2018 01:10:05 -0400 Subject: bpo-14117: Make minor tweaks to turtledemo (GH-8002) The 'wikipedia' example is now 'rosette', describing what it draws. The 'penrose' print output is reduced. The 'tree' '1024' output is eliminated. --- Lib/turtledemo/penrose.py | 3 - Lib/turtledemo/rosette.py | 65 ++++++++++++++++++++++ Lib/turtledemo/tree.py | 1 - Lib/turtledemo/wikipedia.py | 65 ---------------------- .../2018-06-29-00-31-36.bpo-14117.3nvDuR.rst | 3 + 5 files changed, 68 insertions(+), 69 deletions(-) create mode 100644 Lib/turtledemo/rosette.py delete mode 100644 Lib/turtledemo/wikipedia.py create mode 100644 Misc/NEWS.d/next/Library/2018-06-29-00-31-36.bpo-14117.3nvDuR.rst diff --git a/Lib/turtledemo/penrose.py b/Lib/turtledemo/penrose.py index b2a5813..e118d6a 100755 --- a/Lib/turtledemo/penrose.py +++ b/Lib/turtledemo/penrose.py @@ -144,9 +144,6 @@ def test(l=200, n=4, fun=sun, startpos=(0,0), th=2): draw(l, n, th) tracer(1) c = clock() - print("Calculation: %7.4f s" % (b - a)) - print("Drawing: %7.4f s" % (c - b)) - print("Together: %7.4f s" % (c - a)) nk = len([x for x in tiledict if tiledict[x]]) nd = len([x for x in tiledict if not tiledict[x]]) print("%d kites and %d darts = %d pieces." % (nk, nd, nk+nd)) diff --git a/Lib/turtledemo/rosette.py b/Lib/turtledemo/rosette.py new file mode 100644 index 0000000..47d0f00 --- /dev/null +++ b/Lib/turtledemo/rosette.py @@ -0,0 +1,65 @@ +""" turtle-example-suite: + + tdemo_wikipedia3.py + +This example is +inspired by the Wikipedia article on turtle +graphics. (See example wikipedia1 for URLs) + +First we create (ne-1) (i.e. 35 in this +example) copies of our first turtle p. +Then we let them perform their steps in +parallel. + +Followed by a complete undo(). +""" +from turtle import Screen, Turtle, mainloop +from time import perf_counter as clock, sleep + +def mn_eck(p, ne,sz): + turtlelist = [p] + #create ne-1 additional turtles + for i in range(1,ne): + q = p.clone() + q.rt(360.0/ne) + turtlelist.append(q) + p = q + for i in range(ne): + c = abs(ne/2.0-i)/(ne*.7) + # let those ne turtles make a step + # in parallel: + for t in turtlelist: + t.rt(360./ne) + t.pencolor(1-c,0,c) + t.fd(sz) + +def main(): + s = Screen() + s.bgcolor("black") + p=Turtle() + p.speed(0) + p.hideturtle() + p.pencolor("red") + p.pensize(3) + + s.tracer(36,0) + + at = clock() + mn_eck(p, 36, 19) + et = clock() + z1 = et-at + + sleep(1) + + at = clock() + while any(t.undobufferentries() for t in s.turtles()): + for t in s.turtles(): + t.undo() + et = clock() + return "runtime: %.3f sec" % (z1+et-at) + + +if __name__ == '__main__': + msg = main() + print(msg) + mainloop() diff --git a/Lib/turtledemo/tree.py b/Lib/turtledemo/tree.py index 9998fa8..98a20da 100755 --- a/Lib/turtledemo/tree.py +++ b/Lib/turtledemo/tree.py @@ -49,7 +49,6 @@ def maketree(): t = tree([p], 200, 65, 0.6375) for x in t: pass - print(len(p.getscreen().turtles())) def main(): a=clock() diff --git a/Lib/turtledemo/wikipedia.py b/Lib/turtledemo/wikipedia.py deleted file mode 100644 index 47d0f00..0000000 --- a/Lib/turtledemo/wikipedia.py +++ /dev/null @@ -1,65 +0,0 @@ -""" turtle-example-suite: - - tdemo_wikipedia3.py - -This example is -inspired by the Wikipedia article on turtle -graphics. (See example wikipedia1 for URLs) - -First we create (ne-1) (i.e. 35 in this -example) copies of our first turtle p. -Then we let them perform their steps in -parallel. - -Followed by a complete undo(). -""" -from turtle import Screen, Turtle, mainloop -from time import perf_counter as clock, sleep - -def mn_eck(p, ne,sz): - turtlelist = [p] - #create ne-1 additional turtles - for i in range(1,ne): - q = p.clone() - q.rt(360.0/ne) - turtlelist.append(q) - p = q - for i in range(ne): - c = abs(ne/2.0-i)/(ne*.7) - # let those ne turtles make a step - # in parallel: - for t in turtlelist: - t.rt(360./ne) - t.pencolor(1-c,0,c) - t.fd(sz) - -def main(): - s = Screen() - s.bgcolor("black") - p=Turtle() - p.speed(0) - p.hideturtle() - p.pencolor("red") - p.pensize(3) - - s.tracer(36,0) - - at = clock() - mn_eck(p, 36, 19) - et = clock() - z1 = et-at - - sleep(1) - - at = clock() - while any(t.undobufferentries() for t in s.turtles()): - for t in s.turtles(): - t.undo() - et = clock() - return "runtime: %.3f sec" % (z1+et-at) - - -if __name__ == '__main__': - msg = main() - print(msg) - mainloop() diff --git a/Misc/NEWS.d/next/Library/2018-06-29-00-31-36.bpo-14117.3nvDuR.rst b/Misc/NEWS.d/next/Library/2018-06-29-00-31-36.bpo-14117.3nvDuR.rst new file mode 100644 index 0000000..eee55f2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-06-29-00-31-36.bpo-14117.3nvDuR.rst @@ -0,0 +1,3 @@ +Make minor tweaks to turtledemo. The 'wikipedia' example is now 'rosette', +decribing what it draws. The 'penrose' print output is reduced. The'1024' +output of 'tree' is eliminated. -- cgit v0.12