from gpanel import * def onMousePressed(x, y): global xmin, ymin storeGraphics() xmin=x ymin=y def onMouseReleased(x, y): global xmax,ymax global neuesBild xmax=x ymax=ymin+(xmax-xmin) neuesBild=0 def onMouseDragged(x, y): global xmin,ymin delta=x-xmin recallGraphics() move(xmin,ymin) setColor("white") line(xmin, ymin, xmin+delta, ymin) line(xmin+delta, ymin, xmin+delta, ymin+delta) line(xmin+delta, ymin+delta, xmin, ymin+delta) line(xmin, ymin+delta, xmin, ymin) def getIterationColor(it): color = makeColor((it**2) % 256, (3*it) % 256, (5*it) % 256) return color def Mandelbrot(c): z=0 it=0 while it R: return it return maxIterations def drawP(): global xmin, xmax, xstep, xSize global ymin, ymax, ystep, ySize xstep=(xmax-xmin)/xSize ystep=(ymax-ymin)/ySize makeGPanel(Size(xSize,ySize), mousePressed = onMousePressed, mouseReleased = onMouseReleased, mouseDragged = onMouseDragged) window(xmin, xmax, ymin, ymax) y = ymin while y <= ymax: x = xmin while x <= xmax: c = complex(x,y) itCount = Mandelbrot(c) if itCount == maxIterations: setColor("black") else: setColor(getIterationColor(itCount)) point(c) x += xstep repaint() y += ystep #--------------------------------------- # Hauptprogramm #--------------------------------------- R = 2 maxIterations = 100 xmin = -2 xmax = 1 ymin = -1.5 ymax = 1.5 xSize=600 ySize=600 neuesBild=0 key = 0 while key!=27: if neuesBild==0: drawP(); neuesBild=1 key = getKeyCode()