Upload code
This commit is contained in:
27
Animation/Animation_Simple.py
Executable file
27
Animation/Animation_Simple.py
Executable file
@@ -0,0 +1,27 @@
|
||||
import turtle
|
||||
|
||||
import time
|
||||
|
||||
turtle.setup(500,500)
|
||||
turtle.speed(0)
|
||||
turtle.width(4)
|
||||
|
||||
def quadrat():
|
||||
for i in range(4):
|
||||
turtle.fd(100)
|
||||
turtle.rt(90)
|
||||
|
||||
turtle.pu()
|
||||
turtle.setpos(-350,-50)
|
||||
turtle.pd()
|
||||
|
||||
turtle.ht()
|
||||
turtle.tracer(0)
|
||||
|
||||
while True:
|
||||
turtle.clear()
|
||||
quadrat()
|
||||
turtle.fd(1)
|
||||
time.sleep(0.01)
|
||||
turtle.update()
|
||||
|
26
Animation/Animation_dot.py
Executable file
26
Animation/Animation_dot.py
Executable file
@@ -0,0 +1,26 @@
|
||||
import turtle
|
||||
|
||||
import time
|
||||
|
||||
turtle.width(4)
|
||||
turtle.bgcolor("black")
|
||||
turtle.color("red")
|
||||
|
||||
turtle.ht()
|
||||
|
||||
turtle.pu()
|
||||
turtle.setpos(-700,-700)
|
||||
turtle.lt(45)
|
||||
turtle.pd()
|
||||
|
||||
|
||||
turtle.tracer(0)
|
||||
turtle.delay(500)
|
||||
|
||||
|
||||
while True:
|
||||
turtle.clear()
|
||||
turtle.dot(50)
|
||||
turtle.fd(0.5)
|
||||
turtle.update()
|
||||
|
101
Animation/Animation_ship.py
Executable file
101
Animation/Animation_ship.py
Executable file
@@ -0,0 +1,101 @@
|
||||
from turtle import*
|
||||
import time
|
||||
import math
|
||||
|
||||
|
||||
speed_boat = 0.01
|
||||
|
||||
def ship():
|
||||
clear()
|
||||
fd(130)
|
||||
lt(50)
|
||||
fd(50)
|
||||
lt(130)
|
||||
fd(90)
|
||||
rt(90)
|
||||
fd(150)
|
||||
rt(154)
|
||||
fd(math.sqrt(16900 + 4900))
|
||||
rt(116)
|
||||
fd(65)
|
||||
lt(90)
|
||||
fd(18)
|
||||
rt(90)
|
||||
fd(102)
|
||||
lt(130)
|
||||
fd(49)
|
||||
lt(50)
|
||||
update()
|
||||
|
||||
def ship_2():
|
||||
clear()
|
||||
fd(130)
|
||||
lt(50)
|
||||
fd(50)
|
||||
lt(130)
|
||||
fd(240)
|
||||
rt(130)
|
||||
|
||||
|
||||
|
||||
|
||||
def speed_more():
|
||||
global speed_boat
|
||||
speed_boat += 0.5
|
||||
|
||||
|
||||
def goleft():
|
||||
lt(1)
|
||||
bk(1)
|
||||
|
||||
|
||||
def goright():
|
||||
rt(1)
|
||||
bk(1)
|
||||
|
||||
|
||||
def speed_less():
|
||||
global speed_boat
|
||||
speed_boat -= 0.5
|
||||
|
||||
def speed_stop():
|
||||
global speed_boat
|
||||
speed_boat = -1.35
|
||||
|
||||
def speed_exelerate_fast():
|
||||
global speed_boat
|
||||
speed_boat += 2
|
||||
|
||||
def speed_reduce_fast():
|
||||
global speed_boat
|
||||
speed_boat -= 2
|
||||
|
||||
def reset_system():
|
||||
global speed_boat
|
||||
speed_boat = 0.01
|
||||
home()
|
||||
pu()
|
||||
setpos(-350,-50)
|
||||
pd()
|
||||
tracer(0)
|
||||
ht()
|
||||
|
||||
|
||||
|
||||
|
||||
reset_system()
|
||||
|
||||
while True:
|
||||
fd(speed_boat)
|
||||
ship()
|
||||
time.sleep(0.01)
|
||||
onkeypress(reset_system, "Escape")
|
||||
onkeypress(speed_exelerate_fast, "w")
|
||||
onkeypress(speed_reduce_fast, "s")
|
||||
onkeypress(speed_stop, "space")
|
||||
onkeypress(speed_more, "Up")
|
||||
onkeypress(goright, "Right")
|
||||
onkeypress(goleft, "Left")
|
||||
onkeypress(speed_less, "Down")
|
||||
listen()
|
||||
|
32
Animation/Erde und Mond.py
Executable file
32
Animation/Erde und Mond.py
Executable file
@@ -0,0 +1,32 @@
|
||||
#Import der Module
|
||||
import turtle
|
||||
import time
|
||||
|
||||
#Aufsetzen der Turtle instanzen
|
||||
earth = turtle.Turtle()
|
||||
sun = turtle.Turtle()
|
||||
|
||||
#Vorbereiten der Benutzeroberfläche
|
||||
turtle.bgcolor("black")
|
||||
turtle.addshape("earth.gif")
|
||||
turtle.addshape("sun.gif")
|
||||
earth.shape("earth.gif")
|
||||
sun.shape("sun.gif")
|
||||
|
||||
#Erde umkreist Sonne
|
||||
def earth_move():
|
||||
for i in range(10):
|
||||
earth.fd(1)
|
||||
earth.rt(0.2)
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
turtle.tracer(2)
|
||||
|
||||
earth.pu()
|
||||
earth.fd(250)
|
||||
earth.rt(90)
|
||||
|
||||
while True:
|
||||
earth_move()
|
||||
|
252
Animation/Main_hub.py
Executable file
252
Animation/Main_hub.py
Executable file
@@ -0,0 +1,252 @@
|
||||
#Imporieren aller module
|
||||
from turtle import*
|
||||
import random
|
||||
import time
|
||||
import math
|
||||
|
||||
title("Main Hub")
|
||||
|
||||
#Wichtige Vorbereitungen
|
||||
|
||||
def hi():
|
||||
pu()
|
||||
setpos(-100,0)
|
||||
pd()
|
||||
lt(90)
|
||||
fd(200)
|
||||
bk(100)
|
||||
rt(90)
|
||||
fd(100)
|
||||
lt(90)
|
||||
fd(100)
|
||||
bk(200)
|
||||
pu()
|
||||
setpos(50,0)
|
||||
pd()
|
||||
fd(200)
|
||||
|
||||
speed(10000)
|
||||
ht()
|
||||
|
||||
#Lässt den Benutzer auswählen, ob die Formen zufällig oder in einem Kreis angeordnet, nach Wünschen des Benutzers gezeichnet werden sollen.
|
||||
print("ready")
|
||||
hi()
|
||||
program_choice = int(numinput("Welches Program sollte ausgeführt werden?", " 1=Custom, 2=Random, 3=Drunken Man ",1,minval=1))
|
||||
|
||||
|
||||
#Definition des Befehls Vieleck(). Der Grundbaustein des Programms
|
||||
def vieleck(anzahl_seiten,radius, anzahl_kreis_printed, figuren, kreise, figur_nummer, save_first):
|
||||
parts_circle = 1
|
||||
time_durchgang_start = time.time()
|
||||
for i in range(anzahl_seiten):
|
||||
fd(radius/anzahl_seiten)
|
||||
rt(360/anzahl_seiten)
|
||||
parts_circle += 1
|
||||
if parts_circle / anzahl_seiten * 100 >= 50 and parts_circle / anzahl_seiten * 100 < 50.1:
|
||||
print(" Circle:",parts_circle / anzahl_seiten * 100, "%")
|
||||
time_durchgang_end = time.time()
|
||||
exact_timecalculation(time_durchgang_start, time_durchgang_end, anzahl_seiten, radius, anzahl_kreis_printed, figuren, kreise, figur_nummer, save_first)
|
||||
|
||||
|
||||
#Definition des Befehls, der mit beendigung des Auswahlverfahrens aufgerufen wird. Verwaltet die wichtigsten feautures
|
||||
def figur(seite,radiusin,anzahlkr,anzahl_figuren,erh_input):
|
||||
figur_number = 1
|
||||
first_time = 1
|
||||
print("Globally: 0 % done")
|
||||
for i in range(anzahl_figuren):
|
||||
change_color(figur_number)
|
||||
print("drawing figure number",figur_number)
|
||||
anzahl_kr_printed = 0
|
||||
for i in range(anzahlkr):
|
||||
vieleck(seite,radiusin, anzahl_kr_printed, anzahl_figuren, anzahlkr, figur_number, first_time)
|
||||
rt(360/anzahlkr)
|
||||
anzahl_kr_printed += 1
|
||||
print(anzahl_kr_printed / anzahlkr * 100, "%")
|
||||
radiusin += erh_input
|
||||
figur_number += 1
|
||||
print("done")
|
||||
print("Globally:", (figur_number - 1) / anzahl_figuren * 100, "% done")
|
||||
|
||||
#Berechnet, sobald das Programm begonnen hatte zu zeichnen, wie lange der Vorgang noch dauern wird.
|
||||
def exact_timecalculation(time_durchgang_end_1, time_durchgang_start_1, seitenzahl, radiusinput, anzahl_kreise_printed, figuren, kreise, figur_number, save_1):
|
||||
print("Time per shape", time_durchgang_start_1 - time_durchgang_end_1)
|
||||
remaining_circles = (figuren * kreise) - ((anzahl_kreise_printed + ((figur_number - 1) * kreise)))
|
||||
remaining_time = remaining_circles * ((time_durchgang_end_1 - time_durchgang_start_1) * -1)
|
||||
print(((anzahl_kreise_printed + ((figur_number - 1) * kreise))), "/", (kreise * figuren), "shapes got already printed.", remaining_circles, "remaining")
|
||||
print("ETA:", remaining_time, "seconds or", remaining_time / 60, "minutes")
|
||||
if save_1 > 1:
|
||||
remaining_time = save_time_end
|
||||
save_1 = 0
|
||||
else:
|
||||
save_1 = 0
|
||||
|
||||
#Wechselt die Farbe
|
||||
def change_color(anz_figuren):
|
||||
if anz_figuren >= 1 and anz_figuren < 2:
|
||||
color("red")
|
||||
else:
|
||||
if anz_figuren >= 2 and anz_figuren < 3:
|
||||
color("green")
|
||||
else:
|
||||
if anz_figuren >= 3 and anz_figuren < 4:
|
||||
color("blue")
|
||||
else:
|
||||
if anz_figuren >= 4 and anz_figuren < 5:
|
||||
color("brown")
|
||||
else:
|
||||
color("black")
|
||||
|
||||
|
||||
#Führt den zufälligen Teil des Programms aus
|
||||
def vieleck_random_randomize():
|
||||
amount_circles_drawn = 0
|
||||
pu()
|
||||
amount_circles = random.randint(25, 75)
|
||||
print(amount_circles, "shapes need to be printed. Esitmated time:", amount_circles * 0.35, "seconds")
|
||||
print("0 / 0 or 0 % done")
|
||||
for i in range(amount_circles):
|
||||
color(random.random(),random.random(),random.random())
|
||||
size = random.randint(50, 250)
|
||||
width(random.randint(2, 10))
|
||||
ecken = random.randint(3, 20)
|
||||
setpos(random.randint(-300,300), random.randint(-300,300))
|
||||
fuellen = random.randint(0,1)
|
||||
pd()
|
||||
if fuellen >= 1:
|
||||
begin_fill()
|
||||
for i in range(ecken):
|
||||
fd(size / ecken)
|
||||
rt(360 / ecken)
|
||||
end_fill()
|
||||
else:
|
||||
for i in range(ecken):
|
||||
fd(size / ecken)
|
||||
rt(360 / ecken)
|
||||
amount_circles_drawn += 1
|
||||
pu()
|
||||
print(amount_circles_drawn, "/", amount_circles, "or", amount_circles_drawn / amount_circles * 100, "% drawn.")
|
||||
print("100 % done. Process ended with a 0")
|
||||
|
||||
#Definition des Betrunkenen Mannes??
|
||||
def drunken_man_walk_show(schritte,distanz):
|
||||
for i in range(schritte):
|
||||
fd(distanz)
|
||||
setheading(random.randint(0, 360))
|
||||
|
||||
def drunken_man_walk_calculate(anzahl_tests,anzahl_figuren_test,add,anzahl_tests_pro,ausgabe):
|
||||
print("started. Going to make the test", anzahl_tests, "times to get a result which is as acurate as possible")
|
||||
schritte = 100
|
||||
schritte_begin = schritte
|
||||
distanz = 20
|
||||
summe = 0
|
||||
summe_second = 0
|
||||
l = [1]
|
||||
for i in range(anzahl_figuren_test):
|
||||
amount_atemps_per = 0
|
||||
for i in range(anzahl_tests):
|
||||
print("Collecting data for", schritte,"steps, collecting data for try number", amount_atemps_per + 1, "/", anzahl_tests)
|
||||
for i in range(anzahl_tests_pro):
|
||||
drunken_man_walk_show(schritte,distanz)
|
||||
x = xcor()
|
||||
y = ycor()
|
||||
d = math.sqrt(x**2 + y**2)
|
||||
summe += d
|
||||
pu()
|
||||
home()
|
||||
pd()
|
||||
summe_calc = summe / anzahl_tests_pro
|
||||
print("Average dislocation of 0.0 is:", summe_calc,"pixels, with a amount of steps of", schritte,".")
|
||||
summe_second += summe_calc
|
||||
reset()
|
||||
summe = 0
|
||||
amount_atemps_per += 1
|
||||
print("TOTAL Average dislocation of 0.0 is:", summe_second / anzahl_tests, "pixels with", schritte, "steps")
|
||||
print("Next size getting executed")
|
||||
result = summe_second / anzahl_tests
|
||||
l.append(result)
|
||||
schritte += add
|
||||
summe_second = 0
|
||||
l.remove(1)
|
||||
l.reverse()
|
||||
print("\n\n\n")
|
||||
print("entire list:",l)
|
||||
print("\n_________________________ \n\n\n")
|
||||
if ausgabe == 1:
|
||||
for i in range(anzahl_figuren_test):
|
||||
show = l.pop()
|
||||
print(schritte_begin, "has an average dislocation of", show)
|
||||
schritte_begin += add
|
||||
else:
|
||||
print("Schritte | Durchschnittliche Entfernung")
|
||||
print("----------------------------------------------")
|
||||
for i in range(anzahl_figuren_test):
|
||||
show = l.pop()
|
||||
print(schritte_begin, " | ", show)
|
||||
schritte_begin += add
|
||||
|
||||
|
||||
|
||||
|
||||
#Wird ausgeführt, wenn der vom Benutzer einstellbare Modus ausgewählt wird.
|
||||
if program_choice >= 1 and program_choice < 2:
|
||||
title("Custom Design")
|
||||
reset()
|
||||
ht()
|
||||
speed(10000)
|
||||
print("Custom Design")
|
||||
seiteninput = int(numinput("Wie viele Seiten?", " Gerade Zahl von 3-unendlich ",10,minval=3))
|
||||
radiusinput = int(numinput("Wie gross soll der Radius sein?", " Gerade Zahl von 50-unendlich ",50,minval=50))
|
||||
anzahlkrinput = int(numinput("Wie viele Kreise sollen gezeichnet werden??", " Gerade Zahl von 1-unendlich ",5,minval=1))
|
||||
figureninput = int(numinput("Wie viele Figuren sollen gezeichnet werden?", " Gerade Zahl von 1-unendlich ",5,minval=1))
|
||||
erhinput = int(numinput("Um wieviel soll sich sich der Radius der Kreise erhöhen?", " Gerade Zahl von 20-unendlich ",50,minval=20))
|
||||
verzoegerung = int(numinput("Wie schnell soll die Animation laufen?", " Gerade Zahl von 1-unendlich, umso höher, desto schneller ",50,minval=0))
|
||||
print("starting process...")
|
||||
tracer(verzoegerung)
|
||||
print(anzahlkrinput * figureninput, "circles need to be printed. Estimated time until completion:", (anzahlkrinput * figureninput * (seiteninput * 0.0330383)), "seconds or", (anzahlkrinput * figureninput * (seiteninput * 0.0330383)) / 60, "minutes")
|
||||
time.sleep(2)
|
||||
draw_time_start = time.time()
|
||||
figur(seiteninput,radiusinput,anzahlkrinput,figureninput,erhinput)
|
||||
draw_time_end = time.time()
|
||||
draw_time = (draw_time_end - draw_time_start) - (anzahlkrinput * figureninput * (seiteninput * 0.0330383))
|
||||
print("Drawing of", anzahlkrinput * figureninput, "shapes has taken", draw_time_end - draw_time_start , "seconds or", (draw_time_end - draw_time_start) / 60, "minutes, estimated:", (anzahlkrinput * figureninput * (seiteninput * 0.0330383)), "seconds, which means a diffrence of", draw_time, "seconds or missed by", draw_time * 100, "%")
|
||||
print("Click to exit")
|
||||
|
||||
|
||||
else:
|
||||
if program_choice >= 2 and program_choice < 3:
|
||||
title("Random Design")
|
||||
reset()
|
||||
ht()
|
||||
speed(10000)
|
||||
print("Random Design")
|
||||
draw_time_start = time.time()
|
||||
vieleck_random_randomize()
|
||||
draw_time_end = time.time()
|
||||
print("Drawing has taken", draw_time_end - draw_time_start , "seconds")
|
||||
print("Click to exit")
|
||||
else:
|
||||
if program_choice >= 3 and program_choice < 4:
|
||||
title("Drunken Man's Walk")
|
||||
reset()
|
||||
ht()
|
||||
speed(0)
|
||||
print("Drunken Man's Walk")
|
||||
easy_difficult = int(numinput("Soll es gezeigt oder eine Tabelle erstellt werden?", " 1=Normal, 2=Tabelle ",1,minval=1))
|
||||
if easy_difficult == 1:
|
||||
title("Drunken Man's Walk: standard")
|
||||
drunken_man_walk_show(100,20)
|
||||
else:
|
||||
title("Drunken Man's Walk: List")
|
||||
tests_total = int(numinput("Wie viele unterschiedliche Längen sollten getestet werden?", " Dauer erhöht sich extrem, Genauigkeit genauso ",10,minval=1))
|
||||
tests_per = int(numinput("Wieviele Tests sollten pro Länge durchgeführt werden?", " Dauer erhöht sich extrem, Genauigkeit genauso ",10,minval=1))
|
||||
addition = int(numinput("Um wieviel soll die Schrittzahl vergrössert werden?", " Dauer erhöht sich unbedeutend, abhängig von Tests ", 100, minval=1))
|
||||
executes_per = int(numinput("Wie viele Spuren sollen gezeichnet werden?", " Dauer erhöht sich ziemlich, Genauigkeit genauso ",1000,minval=1))
|
||||
tracerdelay = int(numinput("Alle wie viele Striche soll aktualisiert werden?", " umso höher, desto schneller ",10000,minval=1))
|
||||
output = int(numinput("Wie soll die Liste ausgegeben werden?", " 1 = Liste, 2 = Tabelle ",1,minval=1, maxval=2))
|
||||
tracer(tracerdelay)
|
||||
drunken_man_walk_calculate(tests_per,tests_total,addition,executes_per,output)
|
||||
|
||||
else:
|
||||
print("wrong")
|
||||
update()
|
||||
exitonclick()
|
21
Animation/Viereck drehung.py
Executable file
21
Animation/Viereck drehung.py
Executable file
@@ -0,0 +1,21 @@
|
||||
from turtle import*
|
||||
import time
|
||||
#tracer(1)
|
||||
#ht()
|
||||
|
||||
def viereck():
|
||||
for i in range(1000000000000000):
|
||||
clear()
|
||||
pu()
|
||||
setpos(0,0)
|
||||
rt(10)
|
||||
fd(50)
|
||||
rt(90)
|
||||
pd()
|
||||
for i in range(4):
|
||||
fd(50)
|
||||
rt(90)
|
||||
fd(50)
|
||||
time.sleep(0.05)
|
||||
|
||||
viereck()
|
24
Animation/Wartesymbol.py
Executable file
24
Animation/Wartesymbol.py
Executable file
@@ -0,0 +1,24 @@
|
||||
import time
|
||||
import os
|
||||
|
||||
strich = 1
|
||||
|
||||
|
||||
while True:
|
||||
for i in range(4):
|
||||
print("Please wait...")
|
||||
if strich == 1:
|
||||
print("\t-", end="\r")
|
||||
time.sleep(0.5)
|
||||
elif strich == 2:
|
||||
print("\t\\", end="\r")
|
||||
time.sleep(0.5)
|
||||
elif strich == 3:
|
||||
print("\t|", end="\r")
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
print("\t/", end="\r")
|
||||
time.sleep(0.5)
|
||||
os.system( 'clear' )
|
||||
strich += 1
|
||||
strich = 1
|
BIN
Animation/earth.gif
Executable file
BIN
Animation/earth.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
Animation/sun.gif
Executable file
BIN
Animation/sun.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Reference in New Issue
Block a user