diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-10 04:44:07 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-10 04:44:07 (GMT) |
commit | 97cf99fc7e8c56868711f7c91c3b1e37e4c66cba (patch) | |
tree | 6b43643ebc4dc74dd084df06e9163134818423bf /Demo/turtle/tdemo_chaos.py | |
parent | b38fea34bfc67ab5780804a511efe34f49d11e45 (diff) | |
download | cpython-97cf99fc7e8c56868711f7c91c3b1e37e4c66cba.zip cpython-97cf99fc7e8c56868711f7c91c3b1e37e4c66cba.tar.gz cpython-97cf99fc7e8c56868711f7c91c3b1e37e4c66cba.tar.bz2 |
Patch #3064: Port new turtle module and demos to 3.0.
Diffstat (limited to 'Demo/turtle/tdemo_chaos.py')
-rw-r--r-- | Demo/turtle/tdemo_chaos.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Demo/turtle/tdemo_chaos.py b/Demo/turtle/tdemo_chaos.py new file mode 100644 index 0000000..73a0453 --- /dev/null +++ b/Demo/turtle/tdemo_chaos.py @@ -0,0 +1,63 @@ +# Datei: chaosplotter.py +# Autor: Gregor Lingl +# Datum: 31. 5. 2008 + +# Ein einfaches Programm zur Demonstration von "chaotischem Verhalten". + +from tkinter.turtle import * + +def f(x): + return 3.9*x*(1-x) + +def g(x): + return 3.9*(x-x**2) + +def h(x): + return 3.9*x-3.9*x*x + +def coosys(): + penup() + goto(-1,0) + pendown() + goto(n+1,0) + penup() + goto(0, -0.1) + pendown() + goto(-0.1, 1.1) + +def plot(fun, start, farbe): + x = start + pencolor(farbe) + penup() + goto(0, x) + pendown() + dot(5) + for i in range(n): + x=fun(x) + goto(i+1,x) + dot(5) + +def main(): + global n + n = 80 + ox=-250.0 + oy=-150.0 + ex= -2.0*ox / n + ey=300.0 + + reset() + setworldcoordinates(-1.0,-0.1, n+1, 1.1) + speed(0) + hideturtle() + coosys() + plot(f, 0.35, "blue") + plot(g, 0.35, "green") + plot(h, 0.35, "red") + for s in range(100): + setworldcoordinates(0.5*s,-0.1, n+1, 1.1) + + return "Done!" + +if __name__ == "__main__": + main() + mainloop() |