Author Topic: [lua] fractal zoomer  (Read 11556 times)

0 Members and 1 Guest are viewing this topic.

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
[lua] fractal zoomer
« on: June 08, 2014, 10:46:04 am »
Hello!
During the development of my script editor I started a new project, which turned out pretty nice: A fractal zoomer for the Nspire!  :D  I love fractals so I started reading a bit about them and finally had the urge to make a fractal renderer myself on the Nspire. I don't know if there are already fractal renderers for the Nspire, but it wouldn't bother me much because I primarily made it just for fun. Here's the result:

Features:
- Rendering of the mandelbrot set and julia sets
- It first renders at low resolution but the longer you wait, the higher gets the resolution ==> Very fast display
- Zoom in and out by clicking with the mouse
- Free adjustment of calculation depth and constants
- 7 color modes


Information:
- This program is optimized for the handheld; I don't recommend using it on the student software emulator because the emulator doesn't support partial frame updates so that it has to repaint every single pixel on every frame update, which is very slow!
- The menu sometimes doesn't work on the emulator for some reason
- I also included a feature which I haven't seen on any fractal zoomer yet: The possibility to set the values of the first segment Z0 of the sequenze of the mandelbrot set. I'm not familiar enough with fractals to say which exact mathematical meaning this has for the set, but it produces interesting "crippled" shapes (e.g. the middle-right screenshot)

Edit: This program has been revised!

I attached some awesome screenshots of both fractals in different color modes

This project is completed for me, but if you find a serious bug (on the handheld) or have a special request I'm willing to make an update. :)
« Last Edit: March 31, 2015, 11:35:41 am by Jens_K »
Sorry for nonsense.

Projects:



Offline LDStudios

  • Coder Of Tomorrow
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 388
  • Rating: +41/-1
    • View Profile
    • LD Studios
Re: [lua] fractal zoomer
« Reply #1 on: June 08, 2014, 12:13:53 pm »
Amazing work! You continue to do amazing things with Nspire lua, and I can't wait to see what comes next! (Hopefully an update on Jens' Script Editor :P)



Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [lua] fractal zoomer
« Reply #2 on: June 08, 2014, 12:15:42 pm »
Yay. Fractals are awesome ! :D
This looks wonderful too.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: [lua] fractal zoomer
« Reply #3 on: June 08, 2014, 12:30:13 pm »
Looks very cool, and beautiful :P

To answer your first question, Levak made an quite optimized mandelbrot viewer in Nspire-Lua.
By optimized, I mean :
- algorithm-wise : use of quad-tree and general optimizations
- lua-wise : partial invalidates, coroutines, lua tricks etc.

Also, it's not platform-dependant (no absolute coordinates ;) ), so it works well on all nspire platforms (but faster on TINCS and iPad, of course)

Download here (it's the "Mandelbrot_processless3.tns" file, for Lua, the rest is a C ndless program)

There is a video here (it was used for comapring to the C version, but still, you can see it running) :



Your way is quite nice too since you get to see a better "view" the longer you wait, but you get the idea quite fast :P
« Last Edit: June 08, 2014, 12:57:03 pm by Adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [lua] fractal zoomer
« Reply #4 on: June 09, 2014, 01:16:04 am »
THis looks very nice! I wonder how long does it take to render at decent resolution? It would be interesting to see such fractals animated and zooming in, although I doubt it could be done at full res.

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: [lua] fractal zoomer
« Reply #5 on: June 09, 2014, 09:53:27 am »
Thanks for the nice feedback!  :)


@adriweb: I think mine is very optimized too; at least it seems to be not much slower as Levaks version: The same sector at 100 iterations on full resolution takes about 47.5 seconds which is only 1.5 seconds longer than levaks. Plus mine seems to render more accurate (borders seem to be more smooth on my version). I tested it with the attached "high res" version which renders at full resolution right away. Mine is also platform independent; the absolute coordinates are only for initialization; they get overwritten in the on.resize event ;)
But I have a question about coroutines: Do they actually give advantages in speed? I mean the Nspire has only 1 core anyways...


THis looks very nice! I wonder how long does it take to render at decent resolution? It would be interesting to see such fractals animated and zooming in, although I doubt it could be done at full res.
Thanks! On average, 1/4 resolution takes about 5s; 1/2 takes about another 17s; full res takes about another 45s. So I think even on 1/4 resolution it would be too slow... But maybe it would be possible to calculate the indidual frames  and afterwards display them fast enough...
Sorry for nonsense.

Projects:



Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: [lua] fractal zoomer
« Reply #6 on: June 09, 2014, 10:15:59 am »
@LDStudios: Yes I'm still working on the update, I was just too excited about fractals :P
« Last Edit: June 10, 2014, 09:20:27 am by Jens_K »
Sorry for nonsense.

Projects:



Offline AnToX98

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 107
  • Rating: +10/-0
    • View Profile
Re: [lua] fractal zoomer
« Reply #7 on: June 09, 2014, 11:29:43 am »
Wow so pretty :D , I have to show dat to pierrotdu18 :D

Now, Jens K -> back to the editor :D



My Lua projects :

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: [lua] fractal zoomer
« Reply #8 on: June 09, 2014, 11:34:55 am »
Now, Jens K -> back to the editor :D
Aye-aye, sir! :w00t:
Sorry for nonsense.

Projects:



Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [lua] fractal zoomer
« Reply #9 on: June 09, 2014, 12:23:35 pm »
I guess calculating individual frames then animating them pre-rendered could work for animations, although it would take a lot of space.

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: [lua] fractal zoomer
« Reply #10 on: June 10, 2014, 04:35:18 am »
Do you support other fractals? It seems there is a lot of formulas that can yields pretty resutls. Here is a non exhaustive list without illustrations : http://www.lifesmith.com/formulas.html

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: [lua] fractal zoomer
« Reply #11 on: June 10, 2014, 09:13:22 am »
@Jens_K : I never said yours isn't optimized :P
Also, glad it's not platform-dependant, I guess I should have reopened the file in computer view on the software to actually see the re-init in full screen ^^

Also, the problem with Levak's version (which is probably why it's not blazing fast), is that he creates 4^n (i believe) functions for each iteration... which slows the script down.
If he solves that issue, it may be much better ^^
I don't know if he ever will though - maybe one day :P


(Also, I don't have any issues with the menus, like you said ?
edit : ah wait, emu... hum weird)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline mdr1

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 303
  • Rating: +21/-2
    • View Profile
Re: [lua] fractal zoomer
« Reply #12 on: June 10, 2014, 11:21:23 am »
Great that it runs on 3.1. :)
How to draw with the program the fractals in your post?



Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: [lua] fractal zoomer
« Reply #13 on: June 10, 2014, 12:50:58 pm »
Do you support other fractals? It seems there is a lot of formulas that can yields pretty resutls. Here is a non exhaustive list without illustrations : http://www.lifesmith.com/formulas.html
No, not yet... But I could give the user the ability to insert an own formula, let the math.eval function simplifyand then parse it to lua code! I'll try that when I have some spare time  :)


Great that it runs on 3.1. :)
How to draw with the program the fractals in your post?
I attached a screenshot where I marked the positions of the first 5 Screenshots. Then 6th is a mandelbrot set with Z0=0.1+0.7i; The 8th is in a Julia set with C=0.7+0.3i. The other two I can't remember or find :P
Oh and in case you missed it: I continue to support OS 3.1 in the latest alpha release of my script editor! :)
edit: Sorry, only just saw that you've already posted there...
« Last Edit: June 10, 2014, 12:54:44 pm by Jens_K »
Sorry for nonsense.

Projects:



Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: [lua] fractal zoomer
« Reply #14 on: March 31, 2015, 10:53:08 am »
Hello again!
I had noticed that I haven't uploaded this program to ticalc yet, so in order do to that I wanted to fix a few things and polish it a bit and the inevitable happened: I became addicted to fractals again  :P  But at least this fractal renderer now has some cool new features:

- Smooth rendering (see attached screenshot) is now selectable:
  - Full color scale on emulator
  - Dithering on handheld to prevent color-banding (using a 4x4 Bayermatrix)
- Support for custom fractal functions (as suggested by Eiyeron)
  - Switch to page 1.2 to enter a custom function
  - Uses the CAS functions of the Nspire to "extract" the required algorithms and then parses them to Lua code
  - Therefore is only available on OS>3.1
  - The Handheld Lua is too slow for most fractals  :P
- Improved rendering speed, especially on emulator
- New color-set (see attached screenshots)
- Settings are now saved
- Julia sets are not rendered upside-down anymore
- Minor bug-fixes and improvements

And for the sake of the awesomeness of fractals I attached some screenshots of some nice fractals and smooth rendering  ;)
Sorry for nonsense.

Projects: