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 18:42] 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 (xA, yA, xB, yB) | ||
Line 66: | Line 68: | ||
x = randint(0, breite) | x = randint(0, breite) | ||
y = randint(0, hoehe) | y = randint(0, hoehe) | ||
+ | |||
+ | point(int(x), | ||
iterationen = 1000000 | iterationen = 1000000 | ||
Line 74: | Line 78: | ||
x = (x + xA) / 2 | x = (x + xA) / 2 | ||
y = (y + yA) / 2 | y = (y + yA) / 2 | ||
- | | ||
if zufall == 2: | if zufall == 2: | ||
x = (x + xB) / 2 | x = (x + xB) / 2 | ||
Line 87: | Line 90: | ||
</ | </ | ||
- | === Derselbe Python-Code sehr ausführlich kommentiert === | + | ==== Derselbe Python-Code sehr ausführlich kommentiert |
< | < | ||
<code python> | <code python> | ||
- | m# Sierpinski-Dreieck per Chaos-Spiel | + | # Sierpinski-Dreieck per Chaos-Spiel |
# Alle Zeilen, die mit dem Hash- oder Doppelkreuz-Symbol # beginnen, sind Kommentare | # Alle Zeilen, die mit dem Hash- oder Doppelkreuz-Symbol # beginnen, sind Kommentare | ||
# und werden vom Computer beim Ausführen des Programms ignoriert. | # und werden vom Computer beim Ausführen des Programms ignoriert. | ||
Line 139: | Line 142: | ||
# Die Funktion " | # Die Funktion " | ||
- | # Wer die Dicke des Stifts bzw. " | + | # Zum Ändern der Dicke des Stifts bzw. für " |
# lineWidth(2) | # lineWidth(2) | ||
Line 150: | Line 153: | ||
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 193: | 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 239: | 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: | |
- | | + | |