Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
lehrkraefte:snr:informatik:glf21:python:chaos-game [2021/08/17 17:58] Olaf Schnürer |
lehrkraefte:snr:informatik:glf21:python:chaos-game [2021/09/15 17:26] (current) Olaf Schnürer [Derselbe Python-Code sehr ausführlich kommentiert] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Chaos-Spiel − der springende Punkt ==== | + | ===== Chaos-Spiel − der springende Punkt ===== |
Das Chaos-Spiel geht wie folgt: | Das Chaos-Spiel geht wie folgt: | ||
Line 34: | Line 34: | ||
</ | </ | ||
- | === Python-Programm zum Chaos-Spiel === | + | ==== Python-Programm zum Chaos-Spiel ==== |
<code python> | <code python> | ||
# Sierpinski-Dreieck per Chaos-Spiel | # Sierpinski-Dreieck per Chaos-Spiel | ||
Line 58: | Line 57: | ||
xC = int(breite / 2) | xC = int(breite / 2) | ||
yC = hoehe | yC = hoehe | ||
+ | |||
+ | # Zum Ändern der Dicke des Stifts bzw. für " | ||
+ | # lineWidth(2) | ||
+ | |||
+ | line (xA, yA, xB, yB) | ||
+ | line (xB, yB, xC, yC) | ||
+ | line (xC, yC, xA, yA) | ||
# zufaellige Startkoordinaten des springenden Punktes | # zufaellige Startkoordinaten des springenden Punktes | ||
x = randint(0, breite) | x = randint(0, breite) | ||
y = randint(0, hoehe) | y = randint(0, hoehe) | ||
+ | |||
+ | point(int(x), | ||
iterationen = 1000000 | iterationen = 1000000 | ||
Line 76: | Line 84: | ||
x = (x + xC) / 2 | x = (x + xC) / 2 | ||
y = (y + yC) / 2 | y = (y + yC) / 2 | ||
- | point(int(x), | ||
| | ||
+ | point(int(x), | ||
+ | |||
print(iterationen, | print(iterationen, | ||
</ | </ | ||
- | === Python-Code kommentiert === | + | ==== Derselbe |
< | < | ||
<code python> | <code python> | ||
Line 132: | Line 141: | ||
yC = hoehe | yC = hoehe | ||
# Die Funktion " | # Die Funktion " | ||
+ | |||
+ | # Zum Ändern der Dicke des Stifts bzw. für " | ||
+ | # lineWidth(2) | ||
+ | |||
+ | # Zeichnet gerade Linien zwischen den angegebenen Punkten | ||
+ | line (xA, yA, xB, yB) | ||
+ | line (xB, yB, xC, yC) | ||
+ | line (xC, yC, xA, yA) | ||
# zufaellige Startkoordinaten des springenden Punktes | # zufaellige Startkoordinaten des springenden Punktes | ||
x = randint(0, breite) | x = randint(0, breite) | ||
y = randint(0, hoehe) | y = randint(0, hoehe) | ||
+ | |||
+ | # Markiere das Pixel mit Koordinaten (x,y) oder genauer (int(x), int(y)). | ||
+ | # Die Funktion " | ||
+ | # Koordinaten in der aktuellen Zeichenfarbe (schwarz) an. | ||
+ | point(int(x), | ||
# Anzahl der Iterationen. Eigentlich ist es guter Programmierstil, | # Anzahl der Iterationen. Eigentlich ist es guter Programmierstil, | ||
Line 179: | Line 201: | ||
y = (y + yC) / 2 | y = (y + yC) / 2 | ||
| | ||
- | # Markiere das Pixel mit Koordinaten (x,y) oder genauer (int(x), int(y)). | ||
- | # Die Funktion " | ||
- | # Koordinaten in der aktuellen Zeichenfarbe (schwarz) an. | ||
point(int(x), | point(int(x), | ||
Line 212: | Line 231: | ||
Richte das Browser-Fenster links ein und das Tigerjython-Fenster rechts, so dass sie jeweils die halbe Bildschirmbreite einnehmen - dies ermöglicht effektives Arbeiten. | Richte das Browser-Fenster links ein und das Tigerjython-Fenster rechts, so dass sie jeweils die halbe Bildschirmbreite einnehmen - dies ermöglicht effektives Arbeiten. | ||
| | ||
- | Kopiere das obige Programm (sind Ctrl-c, Ctrl-v bekannt? | + | Kopiere das obige Programm |
+ | (Sind Ctrl-c, Ctrl-v | ||
+ | |||
+ | Bringe | ||
{{: | {{: | ||
Line 222: | Line 244: | ||
Wer selbst etwas experimentieren und das Programm verändern möchte, findet Anregungen auf [[https:// | Wer selbst etwas experimentieren und das Programm verändern möchte, findet Anregungen auf [[https:// | ||
- | Wer mag, darf natürlich auch gerne die Einführung [[https:// | + | Wer mag, darf natürlich auch gerne die Einführung [[https:// |
</ | </ | ||
- | |||
- | |||
| | ||
+ | ===== Link zur Kursseite ===== | ||
+ | |||
+ | [[lehrkraefte: | ||