Schülerarbeit: Flamingo

Turtle Graphics

Delia Cellas Programm zeichnet einen Flamingo als Neon-Leuchtschild.

Der Programm-Code

#
# (c) 2014, Delia Cella
#
from gturtle import*

def Knopf():
    penDown()
    setPenColor("grey")
    setFillColor("grey")
    setPos(-380,-260)
    forward(150)
    right(90)
    forward(90)
    right(90)
    forward(150)
    right(90)
    forward(90)
    setPos(-375,-255)
    fill() 
    setPos(-335,-160)
    setPenColor("red")
    dot(50)
    right(90)

def Schatten():
    i=0
    repeat 100: 
        setPenColor(makeColor(1.0,0.0,i/100))
        forward(0.015)
        i+=1
        
def Flamingo(x,y,z):
    repeat x:
        forward(y*2)
        setLineWidth(3)
        right(90)
        penUp()
        forward(2)
        penDown()
        Schatten()
        right(180)
        penUp()
        forward(7)
        right(180)
        penDown()
        forward(1.5)
        penUp()
        forward(2)
        penDown()
        setPenColor("pink")
        left(90)
        setLineWidth(3) 
        right(z)
        
def Flamingo_2(u,v,w):
    repeat u:
        forward(v*2)
        setLineWidth(3)
        right(90)
        penUp()
        forward(2)
        penDown()
        Schatten()
        right(180)
        penUp()
        forward(7)
        right(180)
        forward(1.5)
        forward(2)
        penDown()
        setPenColor("pink")
        left(90)
        setLineWidth(3) 
        right(w)

def Bild():
    setPos(0,-100)
    setPenColor("pink")
    setLineWidth(4)
    Flamingo(60,1,0)
    Flamingo(18,1,5)
    Flamingo(15,1,0)
    Flamingo(63,1,358)
    Flamingo(3,1,0)
    Flamingo(30,1,0.5)
    Flamingo(16,1,10)
    Flamingo(14,1,0)
    Flamingo(14,0,14.8)
    Flamingo(10,1,0)
    Flamingo(18,0.05,355)
    Flamingo(25,0.05,5)
    Flamingo(60,1,356.68)
    Flamingo(12,1,357)
    Flamingo(12,1,359.27)
    Flamingo(24,1,0.33333)
    Flamingo(16,1,10)
    Flamingo(24,1,359.5)
    Flamingo(40,1,358.5)
    Flamingo(60,1,359.6666666)
    Flamingo(1,0,200)
    Flamingo(20,1,0)
    Flamingo(1,0,160)
    Flamingo(30,1,0)
    Flamingo(1,0,195)
    Flamingo(30,1,0)
    Flamingo(1,0,170)
    Flamingo(20,1,0)
    Flamingo(1,0,205)
    Flamingo(23,1,0)
    Flamingo(7,1,13.3)
    Flamingo(14,1,356)
    Flamingo(12,1,0)
    Flamingo(10,1,10)
    Flamingo(24,1,0.833333)
    Flamingo(70,0.1,359)
    Flamingo(23,1,359.5)
    Flamingo_2(2,1,359.5)
    right(222.16)
    
def onClick(x,y):
    if getPixelColorStr() == "red":
        Bild()
        setPos(-335,-160)
        setPenColor("purple")
        dot(50)
    elif getPixelColorStr() == "purple":        
        clear("black")
        Knopf()
    
makeTurtle(mouseHit=onClick)
hideTurtle()
clear("black")
Knopf()