so das rohe script steht jetzt, aber zufrieden bin damit nicht, weil ich nicht unbedingt das zeug erst auf platte speichern will.
außerdem ist die ausgabe verdammt langsam bei groeßeren bildern.
Code: Alles auswählen
import math, copy
from time import sleep, time
from Tkinter import *
from PIL import Image
def getgap(xz , yz, x, y):
return math.sqrt((xz-x)**2+(yz-y)**2) #berechne abstand zu einem zentrum
def getamp(x1,y1, x2,y2, x, y):
global winkel, wellenlaenge
return math.sin((winkel - getgap(x1,y1, x, y)/wellenlaenge) * math.pi) + \
math.sin((winkel - getgap(x2,y2, x, y)/wellenlaenge) * math.pi) + 2
#h = sin(winkel*pi - abstand1) + sin(winkel*pi - abstand2)
def getColor(sw):
return "#%02X%02X%02X" % (sw,sw,sw)
winkel = 0
wellenlaenge = 19
v = 0.1
#koordinaten z1
x1 = 150
y1 = 200
#koordinaten z2
x2 = 200
y2 = 200
#feldgroesse
feldx = 400
feldy = 300
n = 0
bild = Image.new("L", (feldx,feldy))
while winkel + 0.000001 < 2:
t = time()
for i in range(feldy):
for j in range(feldx):
bild.putpixel((j, i), int(getamp(x1,y1,x2,y2,j,i)*64)) #berechne hoehe des punktes i,j
#speichen
bild.save(str(n).zfill(2)+".GIF", "GIF")
print "\rBild %d von %d fertig" % (n+1, int(2/v)),
winkel += v
n += 1
# print "\r%2.3f FPS" % (1/(time()-t+0.001)), #berechne FPS
fenster = Tk()
bild = PhotoImage(width = feldx, height = feldy)
Label(master=fenster, image=bild).pack()
#ausgabe
while 1:
for n in range(int(2.0001/v)):
bild.config(file = str(n).zfill(2)+".GIF")
fenster.update()