Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Mandelista, a Mandelbrot set explorer for Pythonista
-
Hi, I've been poking around with this little program off and on for a couple of weeks. It can zoom in but not out. It has been run only on an iPad 2. It is kind of slow -- ideas for making it go faster would be welcome.
-
I don't understand the point of the for loop in the mandel function:
z = complex(0,0) for i in range(1, 42): z = z**2 + c if abs(z) > 2: return i return 0
Am I missing something here?
-
As I understand it, this iteration is the essence of the Mandelbrot calculation. The result of one iteration is fed back into the next iteration. If the distance of z from zero doesn't exceed 2.0 after some number of iterations then the value of c is considered to be a member of the Mandelbrot set. Such values are colored black on the graph. Other values of c take different numbers of iterations to exceed 2.0. This number of iterations ("the escape velocity") determines the color of the corresponding point on the graph. The maximum number of iterations is arbitrary and determines the precision of the resulting graph.
-
Ah right, didn't look at the loop clearly enough. Thanks for the explanation!
Btw, when i run this on my iPhone 4S, the whole set flickers a lot. Changing the ITERATION variable to 0.5 helps a little though. I think the retina display is what caused the problems.
-
If time is a problem, in the foregoing century I replaced divisions by multiplications ...
Will check the difference on an Ipad 2 ;-)Does tmp = tmp + 1 be as efficient as tmp += 1 ???
And I will look at the most inner loop for ...
EDIT:
nothing changed I get 'white' vertical lines 'moving' from left to right,
how could that be avoided (repaired?) -
C0deH4cker, I borrowed an iPhone 4 and I see what you mean. I don't understand it. I am really surprised that setting INCREMENT to 0.5 works AT ALL!
PKHG, the vertical lines are drawn from left to right in ten passes which should build up the whole graph. You can avoid the line-skipping behavior so that it draws the whole graph in one pass by setting INCREMENT to 1.
-
I tried running the program on an iPhone 3GS and it worked as expected, so the display problem must be related to the retina display, as C0deH4cker suggested.
Ole wrote, in another posting on this forum: "The coordinate system for retina and non-retina screens is the same..., so that the same code works unmodified on both kinds of screen." If that's what's intended, then this problem is looking like it might be due to a Scene bug. I'd be happy to find that there's a workaround, but I don't have a retina device to experiment with.
-
Thanks, will try ...(later)
-
Here's a little script I wrote a while ago, and then ported to work with Pythonista. It renders the Mandelbrot set.
It uses the canvas module, not the scene module, so the output can be saved as an image, however it is not interactive like your program.
It also uses some techniques described on the Wikipedia page to smooth the image so that you don't get the bands of colour visible in the images your script produced. Feel free to take any code you want from it, and nice work! (Mine only renders colours from black to white ATM, but that can be changed fairly easily)
-
tmhrtly, very nice! I love the continuous color gradation.