lehrkraefte:snr:informatik:rgbwuerfel-und-sierpinski-farbig

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lehrkraefte:snr:informatik:rgbwuerfel-und-sierpinski-farbig [2022/03/23 12:47]
Olaf Schnürer [Code 4: Vorlage für farbiges Sierpinski-Dreieck samt SVG-Ausgabe]
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 = "0" + s 
-    return s 
                          
 def sierpinskiDreieck(x1, y1, x2, y2, x3, y3, tiefe): def sierpinskiDreieck(x1, y1, x2, y2, x3, y3, tiefe):
Line 347: Line 343:
 </hidden> </hidden>
  
-<hidden Farbiges Sierpinski-Dreieck, Ausgabe auch als SVG-Datei>+<hidden Farbiges Sierpinski-Dreieck, Ausgabe auch als SVG-Datei; ACHTUNG, DAS GEHT EINFACHER MIT FORMATIERTER AUSGABE: %02x für hexadezimal mit führenden Nullen und mindestens zweistellig; STATT FUNKTION hexadezimalZweistellig>
 <code python> <code python>
 from gpanel import * from gpanel import *
Line 385: Line 381:
             point(int(x1), int(y1))             point(int(x1), int(y1))
                  
-        ausgabe.write("<polyline points='"\+        ausgabe.write("<polygon points='"\
             + 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) + " "
-            + str(x1) + ", " + str(222-y1) + " ' style='fill:#"\+            + " ' style='fill:#"\
             + hexadezimalZweistellig(r)             + hexadezimalZweistellig(r)
             + hexadezimalZweistellig(g)             + hexadezimalZweistellig(g)
  • lehrkraefte/snr/informatik/rgbwuerfel-und-sierpinski-farbig.1648036047.txt.gz
  • Last modified: 2022/03/23 12:47
  • by Olaf Schnürer