This year, I wrote a fractal demo application using DSS/CCR
Distributed Agents and Fractals using DSS/VPL
Now, I’m exploring parallel execution using Task Parallel Library, threads, or MPI (Message Passing Interface). But before writing new versions of fractal app using parallel programming, I added to my ajcodekatas Google code, a base application, WinForm Fractal, that generates fractal images using the GUI thread:
http://code.google.com/p/ajcodekatas/source/browse/#svn/trunk/FractalExample
There is a class library, with core classes, and a WinForm project, that uses a Calculator object to calculate a Sector of fractal. An excerpt of that invocation:
private void Calculate() { Bitmap bitmap = new Bitmap(pcbFractal.Width, pcbFractal.Height); pcbFractal.Image = bitmap; pcbFractal.Refresh(); realWidth = realDelta * pcbFractal.Width; imgHeight = imgDelta * pcbFractal.Height; realMin = realCenter - realWidth / 2; imgMin = imgCenter - imgHeight / 2; int width = pcbFractal.Width; int height = pcbFractal.Height; SectorInfo sectorinfo = new SectorInfo() { FromX = 0, FromY = 0, Width = width, Height = height, RealMinimum = realMin, ImgMinimum = imgMin, Delta = realDelta, MaxIterations = colors.Length, MaxValue = 4 }; Calculator calculator = new Calculator(); Sector sector = calculator.CalculateSector(sectorinfo); this.DrawValues(sector.FromX, sector.FromY, sector.Width, sector.Height, sector.Values); }
Run Fractal.GUI project, and click on Calculate:
You can drag the mouse to select a zone. Releasing the mouse, a new image is generated. You can change the colors, that are randomly selected:
Next Steps
I want to add new versions:
- Multithread version
- Parallel version using Task Parallel Library
- Distributed version (MPI.NET? AjMessages?)
If you are impatient, there is an excellent tutorial, implementing a fractal application using HPC 2008 and the above technologies, ready to download from:
Suggestions, comments, welcome!
Angel “Java” Lopez
http://www.ajlopez.com/en
http://twitter.com/ajlopez