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:rgbwuerfel-und-sierpinski-farbig [2022/03/09 10:47] Olaf Schnürer [Einige Lösungsvorschläge] |
lehrkraefte:snr:informatik:rgbwuerfel-und-sierpinski-farbig [2022/03/27 20:44] (current) Olaf Schnürer [Einige Lösungsvorschläge] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~NOTOC~~ | ||
+ | |||
====== Mit Python Bild-Dateien erzeugen: RGB-Würfel (als ppm) und farbiges Sierpinski-Dreieck (als SVG) ====== | ====== Mit Python Bild-Dateien erzeugen: RGB-Würfel (als ppm) und farbiges Sierpinski-Dreieck (als SVG) ====== | ||
Line 143: | Line 145: | ||
from gpanel import * | from gpanel import * | ||
- | MAX_TIEFE = 6 | + | MAX_TIEFE = 3 |
# Tiefe 12 schafft Inkscape noch mit Mühe, ab 13 weigert es sich | # Tiefe 12 schafft Inkscape noch mit Mühe, ab 13 weigert es sich | ||
# Tiefe 8 für dokuwiki svg | # Tiefe 8 für dokuwiki svg | ||
Line 158: | Line 160: | ||
| | ||
return int(rot), int(blau), int(gruen) | return int(rot), int(blau), int(gruen) | ||
- | |||
- | def hexadezimalZweistellig(zahl): | ||
- | s = hex(zahl)[2: | ||
- | if len(s) < 2: | ||
- | s = " | ||
- | return s | ||
| | ||
def sierpinskiDreieck(x1, | def sierpinskiDreieck(x1, | ||
Line 195: | Line 191: | ||
Rx, Ry = 128, 222 | Rx, Ry = 128, 222 | ||
- | # auf Schulcomputer | + | # auf Schulcomputern mit Windows |
ausgabe = open(" | ausgabe = open(" | ||
# Unter Linux (und wohl auch macOS): | # Unter Linux (und wohl auch macOS): | ||
# ausgabe = open(" | # ausgabe = open(" | ||
- | # Wenn man auf Dateien in einem anderen Verzeichnis zugreifen will, | ||
- | # muss man unter Windows den Pfad sinngemaess wie folgt angeben. | ||
- | # ausgabe = open(" | ||
ausgabe.write("< | ausgabe.write("< | ||
Line 350: | Line 343: | ||
</ | </ | ||
- | <hidden Farbiges Sierpinski-Dreieck, | + | <hidden Farbiges Sierpinski-Dreieck, |
<code python> | <code python> | ||
from gpanel import * | from gpanel import * | ||
Line 388: | Line 381: | ||
point(int(x1), | point(int(x1), | ||
| | ||
- | ausgabe.write("< | + | ausgabe.write("< |
+ str(x1) + ", " + str(222-y1) + " " | + str(x1) + ", " + str(222-y1) + " " | ||
+ str(x2) + ", " + str(222-y2) + " " | + str(x2) + ", " + str(222-y2) + " " | ||
+ str(x3) + ", " + str(222-y3) + " " | + str(x3) + ", " + str(222-y3) + " " | ||
- | | + | + " ' style=' |
+ hexadezimalZweistellig(r) | + hexadezimalZweistellig(r) | ||
+ hexadezimalZweistellig(g) | + hexadezimalZweistellig(g) |