Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
fuellen [2010/05/09 21:46] 127.0.0.1 Externe Bearbeitung |
fuellen [2013/04/08 21:26] (aktuell) admin |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== Polygone füllen ====== | ====== Polygone füllen ====== | ||
| - | |||
| <code python> | <code python> | ||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
| # Python für Kids (4. Auflage) - Kapitel 13 | # Python für Kids (4. Auflage) - Kapitel 13 | ||
| # Ereignisgesteuerte Programme | # Ereignisgesteuerte Programme | ||
| - | |||
| # Autor: Gregor Lingl | # Autor: Gregor Lingl | ||
| # Datum 16. 8. 2009 | # Datum 16. 8. 2009 | ||
| - | |||
| # scribble - ein einfaches Zeichenprogramm | # scribble - ein einfaches Zeichenprogramm | ||
| - | |||
| # (1) Stift zeichnet eine Linie zur (links) angeklickten Stelle | # (1) Stift zeichnet eine Linie zur (links) angeklickten Stelle | ||
| # (2) Stift springt (ohne Zeichnen) zur mit mittlerer Taste | # (2) Stift springt (ohne Zeichnen) zur mit mittlerer Taste | ||
| Zeile 20: | Zeile 16: | ||
| import sys | import sys | ||
| sys.setrecursionlimit(20000) | sys.setrecursionlimit(20000) | ||
| - | |||
| def jump(x, y): | def jump(x, y): | ||
| stift.penup() | stift.penup() | ||
| stift.goto(x, y) | stift.goto(x, y) | ||
| stift.pendown() | stift.pendown() | ||
| - | |||
| def fuellenumschalten(xdummy, ydummy): | def fuellenumschalten(xdummy, ydummy): | ||
| if stift.fill(): | if stift.fill(): | ||
| Zeile 33: | Zeile 27: | ||
| stift.begin_fill() | stift.begin_fill() | ||
| stift.fillcolor("black") | stift.fillcolor("black") | ||
| - | |||
| stift = Turtle() | stift = Turtle() | ||
| stift.speed(0) | stift.speed(0) | ||
| Zeile 39: | Zeile 32: | ||
| stift.shapesize(0.4, 0.4, 3) | stift.shapesize(0.4, 0.4, 3) | ||
| stift.pensize(3) | stift.pensize(3) | ||
| - | |||
| onscreenclick(stift.goto) | onscreenclick(stift.goto) | ||
| onscreenclick(jump, 2) | onscreenclick(jump, 2) | ||
| Zeile 45: | Zeile 37: | ||
| stift.ondrag(stift.goto) | stift.ondrag(stift.goto) | ||
| mainloop() | mainloop() | ||
| - | |||
| </code> | </code> | ||