Mathematically Generated Fire – REVISED

A demonstration of mathematically-generated fire

Because the first draft of this project has received more traffic than I anticipated, I’ve gone ahead and written a new and MUCH faster version of the algorithm.  As before, no pre-built images or palettes are used, meaning that both coloring and flame generation are done using only math (and ingenuity!).

Updates to this version include the following:

  • DIB sections are now used in place of Get/SetPixel.  This alone nearly tripled the frame rate on my old 1.6ghz laptop.
  • Flame coloring is now done via look-up tables.  Previously this was calculated on the fly, which required way too many duplicate calculations.
  • Random horizontal movement of individual flames is now calculated for every 4th pixel (instead of every single one).  Random number generation is costly, and visually this method looks almost identical (but is markedly faster).
  • Scrollbars are now available so that you can color the flames however you’d like.  Red flames, blue flames, green flames, or any combination in-between – so knock yourself out.

On my aforementioned 1.6ghz laptop, the original version of this code ran (compiled) at 6-7 fps for a 512×256 image.  The new code runs between 27 and 28 fps – or a 400+% increase.

Enjoy, and if you have any recommendations for Fire v.3, leave a comment!

Similar Posts:

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!