1. The NickFrac screensaver, or How I Broke My Brain
- Posted by prickle Aug 04, 2009
- 1235 views
Hi, all. I have just uploaded the full source and a Windows installer of the NickFrac screensaver to the archive. I would put it forward as having the most ridiculously convoluted code base of any program I have written. It is a prime example of how not to write maintainable code.
Not that it is large, just stupefyingly twisted and difficult to follow. For example:
Languages within languages within languages. Three lexicons are used, Euphoria, assembly and one all of it's own, often all within a single statement.
Multiple parallel versions, there is an almost complete development implementation in DOS.
Self-compiling, it has it's own built-in JIT language and parser and both versions can build portions of themselves into precompiled include files.
Self-modifying at multiple levels, not only is the embedded assembly altered during build time but the assembled machine code is altered during runtime on a per-fractal basis.
Complicated math, comprehensive fractal dynamics analysis expressed in the most primitive low-level fashion.
Why did I do it this way? All for execution performance. The images produced require not one fractal plot but many hundreds of complete fractal plots superimposed one on top of another. Any other method would be too slow for a screensaver.
So now I want to return to this code, extending it to a more full-featured fractal explorer. Trying to read the code, let alone understand what I was doing is as difficult as if I had never seen it before and makes my brain hurt. Very little of it makes sense and I expect it is up for a rewrite once I rediscover it's secrets.
Nick
2. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 04, 2009
- 1224 views
Nick,
This is beautiful (the results, not the twisted brain!) but I have a problem. After a few seconds of running the screensaver quits back to the normal screen. It does this on Preview as well as the real thing. On Win XP SP3. Any suggestions?
Andy
3. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by prickle Aug 04, 2009
- 1225 views
Nick,
This is beautiful (the results, not the twisted brain!) but I have a problem. After a few seconds of running the screensaver quits back to the normal screen. It does this on Preview as well as the real thing. On Win XP SP3. Any suggestions?
Andy
Bugger. I have had this problem before. Spurious mouse move events from nowhere. I have a hack to fix it, but it is less than ideal as the screensaver then requires quite energetic mouse movements before it quits. I will update the code, rebuild the installer and resubmit. Gimme a day or two, I have misplaced the original installer script.
Thanks Andy.
Nick
4. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by jeremy (admin) Aug 04, 2009
- 1232 views
Seems to run w/o issue on Windows 7. Good job!
Jeremy
5. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 04, 2009
- 1141 views
Bugger. I have had this problem before. Spurious mouse move events from nowhere. I have a hack to fix it, but it is less than ideal as the screensaver then requires quite energetic mouse movements before it quits. I will update the code, rebuild the installer and resubmit. Gimme a day or two, I have misplaced the original installer script.
Thanks Andy.
Nick
I can wait OK! And I don't mind a quite big wiggle on the mouse. In fact I prefer that, really. there are some screen savers I turn off, some I think are OK, and some are better than working! Yours looks like the latter...
Andy
6. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by prickle Aug 04, 2009
- 1148 views
Seems to run w/o issue on Windows 7. Good job!
Jeremy
Awesome! I can't say I expected that. One might then conclude that some success could be had with Vista. Given this is the case I have decided to keep the original installer and provide the hack separately to be copied into Windows by hand for the affected users. Instructions are in the Readme.txt in the updated distribution. I'll go and upload it now.
Thanks, Jeremy.
7. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by prickle Aug 04, 2009
- 1163 views
I can wait OK! And I don't mind a quite big wiggle on the mouse. In fact I prefer that, really. there are some screen savers I turn off, some I think are OK, and some are better than working! Yours looks like the latter...
Andy
Wow! high praise indeed. Perhaps it was worth a broken brain after all. RDS now has the fix.
Power users may note the interactive features of the screensaver. Pressing space bar will start a new fractal and control-s will (very slowly) capture the current image (watch the red bars crawl down the sides of the screen!) and then allow it to be saved.
Thanks, Andy.
Nick
8. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 04, 2009
- 1139 views
Argh. Now, either the fix ain't fixed it or re-installing has not overwritten the previous version. Sadly, just as I think "This looks great!" it goes back to the boring old Microsoft desktop which I see day after day after day ... I tried making sure the mouse was quiet by laying it on its back - no good. And I can't see how to uninstall the previous version - so, Nick, I still await the delights with bated breath Andy
9. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 04, 2009
- 1164 views
A bit more information: it seems that it is possibly disk activity which trips it. I was doing a search for SAVER.EXE and while it was doing that I couldn't preview more than a few millisex. I stopped the search and got back to running for a few seconds before popping back. So ...
Andy
10. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by prickle Aug 04, 2009
- 1209 views
A bit more information: it seems that it is possibly disk activity which trips it. I was doing a search for SAVER.EXE and while it was doing that I couldn't preview more than a few millisex. I stopped the search and got back to running for a few seconds before popping back. So ...
Andy
Oops, RDS has it but it is not in the recent contributions yet. It may be a couple of hours or more before they get on to it. You will not need to reinstall. Simply copy the file as described in the Readme.txt. If you are keen, my ICQ# is 486485722 I will send you the new file direct.
11. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 05, 2009
- 1196 views
Oops, RDS has it but it is not in the recent contributions yet. It may be a couple of hours or more before they get on to it. You will not need to reinstall. Simply copy the file as described in the Readme.txt. If you are keen, my ICQ# is 486485722 I will send you the new file direct.
Nick, I waited for a few hours and downloaded NickFract, and same problem. At home, at midnight UK, I downloaded it to my desktop PC (also XP SP3) and it was fine. I watched it avidly for a while before going (back) to bed! This morning I downloaded it to my laptop, and followed your instructions this time, and Hey Presto! All OK! No work for a while - when I need to think, I have this new aid to thinking there!
It reminds me of the film 2001 (or one of its successors) with the caveman looking at a screen and learning something - I feel if I watched enough I'd learn the art of time travel, design a space warp and probably anti-gravity after coffee. So there is a challenge! I love the idea of programs which self-compile, self modify, and generally think for themselves ... much better than just clicking together Lego modules of code, much more rewarding ... so thank you, Nick, great work.
Andy
12. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 05, 2009
- 1209 views
Nick, how hard would it be for the control-S command to wait till the fractal is complete before saving? I see great patterns coming up but either hit Ctrl-S too late or earlier than I'd like. Just a thought ... you can tell my work is dropping off a little ... ho hum.
Andy
13. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by prickle Aug 05, 2009
- 1193 views
Nick, how hard would it be for the control-S command to wait till the fractal is complete before saving? I see great patterns coming up but either hit Ctrl-S too late or earlier than I'd like. Just a thought ... you can tell my work is dropping off a little ... ho hum.
Andy
Hi Andy. The reason I did it like that is because the program doesn't use any backing store or screen buffer. The output of the engine is drawn straight to the visual and is destroyed if anything moves over the top of it, like another window or progress bar or something. Fractals went faster that way. This is why the screen is "captured" with little red bars rather than the image being instantly available to save.
I do not have a good knowledge of the Windows API, there may be some much better way to do this. What I think it means though is any visual feedback we give the user at the point they press Ctrl-S will damage part of the image. Not wanting that to happen, we need to simply sit and wait for the fractal to finish before capturing it. Wondering what's going on, the user presses the key again. and again, mashing the keyboard in a frenzy of impatience. Suddenly, dozens of save-as windows appear and the computer crashes. Well, maybe not, but I can't think of a good way. Any ideas?
What I did back when I still used Windows was crank the iterations up by a factor of ten or more on the chaotic fractals like the IFSs and the Strange types so they ran much longer to give me a a better chance of capturing one I liked and turned all the boring ones off. I was thinking of updating the defaults, they were set back in '02 when life was slower but I keep forgetting. Each chaotic fractal type was intended to linger for up to a minute. On a modern machine they probably skip by a bit too quick.
Hmm. not sure. Perhaps if I captured every fractal when it was finished and kept the last ten in a directory somewhere?
Here's to not working,
Nick
14. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 06, 2009
- 1187 views
Hi Andy. The reason I did it like that is because the program doesn't use any backing store or screen buffer. The output of the engine is drawn straight to the visual and is destroyed if anything moves over the top of it, like another window or progress bar or something. Fractals went faster that way. This is why the screen is "captured" with little red bars rather than the image being instantly available to save.
I do not have a good knowledge of the Windows API, there may be some much better way to do this. What I think it means though is any visual feedback we give the user at the point they press Ctrl-S will damage part of the image. Not wanting that to happen, we need to simply sit and wait for the fractal to finish before capturing it. Wondering what's going on, the user presses the key again. and again, mashing the keyboard in a frenzy of impatience. Suddenly, dozens of save-as windows appear and the computer crashes. Well, maybe not, but I can't think of a good way. Any ideas?
What I did back when I still used Windows was crank the iterations up by a factor of ten or more on the chaotic fractals like the IFSs and the Strange types so they ran much longer to give me a a better chance of capturing one I liked and turned all the boring ones off. I was thinking of updating the defaults, they were set back in '02 when life was slower but I keep forgetting. Each chaotic fractal type was intended to linger for up to a minute. On a modern machine they probably skip by a bit too quick.
Hmm. not sure. Perhaps if I captured every fractal when it was finished and kept the last ten in a directory somewhere?
Here's to not working,
Nick
Nick, I understand what you're saying. The best method, IMHO, is to capture the fractal at its completion, so that ctrl-S will save the last completed one. But isn't it like hard work to copy the screen image? I don't know how you're accessing the screen pixel-by-pixel, but it is B quick, so I guess you could read it all quickly too and save in memory. Then the ctrl-S would just bring up an instant getSaveFile menu. Maybe a different command? I don't know, I just think that this is an interesting and absorbing way of not working and it'd be nice to get some of the best looking fractals used as wallpaper or maybe printed. Printing, of course, means either negativeing the image or turning all the true black pixels into white, otherwise it eats all your toner when printing!
If you kept the last ten, you'd need a system for thumbnail display so you could select the one you wanted to save permanently. It could be a lot of work, and I'm loathe to put work out anybody's way....
Anyway, it all runs nicely, thank you, I will now see how long it takes to invent anti-grav or maybe to do my job without working!
Andy
15. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by prickle Aug 09, 2009
- 1275 views
Hi, Andy.
Nick, I understand what you're saying. The best method, IMHO, is to capture the fractal at its completion, so that ctrl-S will save the last completed one.
Yes, that would work. How about ctrl-S saves the current image as per the current behaviour, and ctrl-L saves last image, if it exists?
But isn't it like hard work to copy the screen image? I don't know how you're accessing the screen pixel-by-pixel, but it is B quick, so I guess you could read it all quickly too and save in memory. Then the ctrl-S would just bring up an instant getSaveFile menu. Maybe a different command?
Yes, it was hard work given the get_pixel->Euphoria sequence algorithm I was using. I have now discarded this most shameful algorithm and have implemented the Windows Recommended Method of obtaining a DIB and peeking it straight out to a file. This is orders of magnitude faster.
I don't know, I just think that this is an interesting and absorbing way of not working and it'd be nice to get some of the best looking fractals used as wallpaper or maybe printed. Printing, of course, means either negativeing the image or turning all the true black pixels into white, otherwise it eats all your toner when printing!
Andy, I am thrilled you are taking an interest in this. I pretty much wrote it for my own interests and desires which I satisfied back in '02. Since then I have passed it around and received very little feedback other than for when things broke. Constructive criticism, comments and suggestions are not only welcome but actively sought. Thanks so much.
I never anticipated the images would be printed. Glass on black was my own personal preference. Perhaps it is worth including a method to select a background colour.
If you kept the last ten, you'd need a system for thumbnail display so you could select the one you wanted to save permanently. It could be a lot of work, and I'm loathe to put work out anybody's way....
Yes, a thumbnail display would be nice, but perhaps unnecessary if we find a better way. It would look stylish tho. BTW this is not work for me, it is a hobby (or as some would call it an unhealthy obsession) and generates much pleasure. I simply have exhausted my ideas for this work and need fresh perspective. I am well prepared to take this little screensaver to the next level if people let me know what they like.
Would you or anybody listening be willing to test my intermediate code? I do not have Windows and am testing my new code using WINE. Unfortunately, not everything works in the WINE environment, namely toplevel windows, such that the screensaver proper does not run. The settings dialog is fine though and is enough to develop with. Nevertheless, it would be good for operation to be verified in real Windows. I don't want to bother RDS with incremental updates so please fetch the new ready-to-go .SCR here. Copy this into your Windows directory as per previous updates.
What's new: The ctrl-S save image function should now be virtually instantaneous. Otherwise, the program is functionally the same. This is the first step to extending functionality.
Something I now realise you may not be aware of and I probably should have mentioned is the other interactive mode. When you are in the settings dialog, you can click on the small preview window to detach it from the gui and manipulate it like a normal window. It works the same as the screensaver proper with the interactive keys allowing save and skip, but it will only generate fractals of the type currently selected in the settings dialog and will stop when the fractal is done generating. This is probably the best way to currently save a completed fractal, but it will only be at the resolution of the fractal window. It would appear this functionality is quite non-intuitive. Turns out nobody expects to be able to click on a preview. Perhaps this should also be changed.
Cheers,
Nick
16. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 09, 2009
- 1140 views
Hey, Nick, I'm just enjoying your handiwork. I love the way you can take the preview and drag it out. The saved fractals are instant, now, and you can just keep generating one type over and over and save any great-looking results. I wondered if one could be used to generate the basis for a new icon for Euphoria that others are doing!
I love the fact that someone is doing something with a PC other than try and make it connect to another using a network. It seems that the major requirement for computers and software these days is to get them communicating. Otherwise what the machine does is relatively minor. I write software for PICs - microcontrollers - to control systems, which I find quite satisfying. A PC I use for editing/compiling and then playing - and what you have been doing as a hobby is brilliant stuff.
Yes, I'd be happy to test your code; when it is as simple as bunging a *.scr into Windows and spending a happy lunchtime testing it out, no bother. Send them to andy hat kestreltelecom with a dot in the obvious place, and I'll get them with my emails even if I'm too busy to go on to the forum.
I will think about thumbnails, but I shall have to grab your pixel-drawing code to make it half-fast. You already have done most of the work by drawing a fractal in the small preview window, so maybe it won't be so bad. I can see my lunchtimes getting used up - so much for my usual games of computer snooker! If anyone else wants to try, though, I will not be offended, of course.
Andy
17. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by prickle Aug 10, 2009
- 1187 views
Hey, Nick, I'm just enjoying your handiwork. I love the way you can take the preview and drag it out. The saved fractals are instant, now, and you can just keep generating one type over and over and save any great-looking results. I wondered if one could be used to generate the basis for a new icon for Euphoria that others are doing!
Fabulous. All working then. As far as the icon is concerned, anybody is free to do whatever they please with the generated images. There are no issues with copyright or ownership, I consider any image one generates as your own artwork. If in fact somebody does like a fractal enough to make a logo with it, I'd be chuffed.
I love the fact that someone is doing something with a PC other than try and make it connect to another using a network. It seems that the major requirement for computers and software these days is to get them communicating. Otherwise what the machine does is relatively minor. I write software for PICs - microcontrollers - to control systems, which I find quite satisfying. A PC I use for editing/compiling and then playing - and what you have been doing as a hobby is brilliant stuff.
LOL agreed networking is the current fashion. Mind you fractals were pretty popular probably 10 years back when scientists were trying to use them to explain life and stuff. Personally, I see fractals as a kind of something for nothing, pretty pictures from a handful of almost random numbers. Oh, and I'm an AVR man myself. Another of my technical hobbies.
Yes, I'd be happy to test your code; when it is as simple as bunging a *.scr into Windows and spending a happy lunchtime testing it out, no bother. Send them to andy hat kestreltelecom with a dot in the obvious place, and I'll get them with my emails even if I'm too busy to go on to the forum.
Sure thing. Thanks again for your lunchtimes.
I will think about thumbnails, but I shall have to grab your pixel-drawing code to make it half-fast. You already have done most of the work by drawing a fractal in the small preview window, so maybe it won't be so bad. I can see my lunchtimes getting used up - so much for my usual games of computer snooker! If anyone else wants to try, though, I will not be offended, of course.
No problem. I will post you some info and we should probably start collaborating directly to save the forum from all those gory details. We have much to discuss.
Cheers,
Nick.
18. Re: The NickFrac screensaver, or How I Broke My Brain
- Posted by AndyDrummond Aug 10, 2009
- 1179 views
No problem. I will post you some info and we should probably start collaborating directly to save the forum from all those gory details. We have much to discuss.
Don't get too enthusiastic, though, I'm not a clever programmer and I don't have lots of time. I was thinking if you saved (optionally, maybe) each fractal into a folder once it was finished - say to a maximum of 16 or 32 or some such software-ish number, I could write a separate little browser to show them, allow selection and saving etc. But you get that kind of thing in IrfanView which will probably do everything I can do and a little bit more! But testing your output, yes, OK, fine.
Tried saving some fractals as icons, and they come out very feeble because of the low resolution and so on. I may need to work on an iconiser from your bumpy saved fractals.... I did something similar in XPMMER but it was terrible; I need a decent algorithm. I just feel that icons based on these fractals could be really good - if weird!
Back to work, I suppose.
Andy