runezor / PiArtFrame

119 stars 11 forks source link

Same fractals on pi reboot #5

Closed Delqath closed 10 months ago

Delqath commented 10 months ago

Loving your project so far! Got it running, but I was surprised to see that the fractal patterns are the same predictable order on reboot. Based on your comments it didn't seem like this was intended. Is there a way to randomize at the start?

Side question, is it possible to add a line of code to shut down the pi after it renders? My idea is to have a small power switch on a frame where people can hit it to turn on the pi to create a new image, then it shuts down when complete to save battery.

runezor commented 10 months ago

Hi Delqath,

It's quite surprising that the order is the same - are you sure it's not just for the first couple frames? The uniformness logic should allow for plenty of diverging paths. If you'd like a bit more randomness, you could consider changing line 90 of mandelbrot.py to less_uniform_choices = choices rather than less_uniform_choices = [x for x in choices if x[2]<3], though this may yield slightly less interesting renders.

As for turning off and re-rendering the image, it would be slightly more involved but nothing too tricky. You'd need to save the w, h, x and y values of the Mandelbrot render, and load this file on bootup. Turning off the Pi via Python can be done by running a commandline argument via the subprocess Python library. This would probably be like 10 lines of code overall.

Delqath commented 10 months ago

I suppose I was only testing the first 4 frames, I'll revert the code and see what happens on longer runs.

I had tried randomizing the first starting position to see what that did. Ideally I would make something that created a unique image on load, then just powered off. Next time it is powered on it is something else unique. I think all the pieces are here in your code I just need learn python better :)

runezor commented 10 months ago

Creating a unique image is a bit harder, off the top of my head, here's a couple ideas: