Spagettimonster von Kevin
Statt die beiden Augen einzeln zu programmieren könnte man eine Funktion Auge definieren, die ein Auge (inklusive Stiel) zeichnet und diese Funktion öfters aufrufen, um z.B. ein 3-äugiges Spagettimonster zu erschaffen.
| Kevins's Spagettimonster | Spagettimonster im Internet (Wikipedia): |
| |
import turtle as t import random as r """create a big brain, beginning from the center. with tentacles. needs turtle 2.6 or better. license: public domain (do whatever you want) author: Kevin Sidak, gecko7@gmx.at""" t.colormode(255) # color as rgb tuple t.tracer(False) t.bgcolor(220,220,220) for arm in xrange(50): #xrange is faster than range t.penup() #no drawing t.goto(0,0) t.pendown() #draw t.setheading(0) t.left(arm * 36) rot = r.randint(255,255) gruen = r.randint(255,255) for step in xrange(25): t.pensize(50-step) t.color(rot,gruen,step*10) t.fd(10 + step) t.left(r.randint(-step, step*2)) # center t.speed(1) # slow ! 10 = fast for step in xrange(50,0,-2): t.penup() t.goto(100,0) t.pendown() t.color(step*5,0,0) t.setheading(0) t.fd(50+step) t.left(90) t.begin_fill() t.circle(20+step) t.end_fill() for step in xrange(50,0,-2): t.penup() t.goto(-150,0) t.pendown() t.color(step*5,0,0) t.setheading(0) t.fd(50+step) t.left(90) t.begin_fill() t.circle(20+step) t.end_fill() t.tracer(True) t.speed(10) #Auge1(rechts)# t.color(rot,gruen,0) t.penup() t.goto(100,90) t.pendown() t.setheading(0) t.forward(240) t.color(rot,gruen,0) t.begin_fill() t.circle(60) t.end_fill() t.goto(100,90) t.pendown() t.setheading(0) t.forward(240) t.color(255,255,255)#weiss t.begin_fill() t.circle(50) t.end_fill() t.penup t.setheading(0) t.forward(20) t.left(90) t.forward(50) t.pendown() t.color(0,0,0) t.begin_fill() t.circle(20) t.end_fill() #Auge2(links)# t.color(rot,gruen,0) t.penup() t.goto(-100,90) t.pendown() t.setheading(0) t.forward(-240) t.color(rot,gruen,0)#gelb t.begin_fill() t.circle(60) t.end_fill() t.goto(-100,90) t.pendown() t.setheading(0) t.forward(-240) t.color(255,255,255)#weiss t.begin_fill() t.circle(50) t.end_fill() t.penup t.setheading(0) t.forward(-20) t.left(270) t.forward(-50) t.pendown() t.color(0,0,0) t.begin_fill() t.circle(20) t.end_fill() for x in range(100): t.penup() t.left(200)
|
Der Quellcode in den Code-Beispielen auf der gesamten Website www.spielend-programmieren.at ist lizensiert mit CC-GNU GPL v2.0+. |
|
Alle Inhalte (Texte, Bilder) in diesem spielend-programmieren Wiki von Horst JENS sind lizensiert unter der Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License Bei Lizenzfragen wenden Sie sich an : Horst JENS möglichst per e-mail: horst.jens@spielend-programmieren.at |