Click here to Skip to main content
11,712,466 members (71,289 online)
Click here to Skip to main content
Articles » Languages » C# » Applications » Downloads
Add your own
alternative version

Tagged as

The beauty of fractals - A simple fractal rendering program done in C#

, 27 Jul 2009 CPOL 99.6K 8.8K 159
A fractal rendering application demonstrating many .NET programming techniques.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Threading;
using System.Runtime.Serialization;

namespace FracMaster
    public class TestFractal : GenericFractal 
        public TestFractal()
            pars.SetValue("NAME", "Render Test");                     

        override protected void RenderFunction(object o)
            object[] P = (object[])o;
            RenderResult.RenderComplete clbk = (RenderResult.RenderComplete)P[0];
            RenderResult.RenderStatus status_clbk = (RenderResult.RenderStatus)P[1];

                int width = (int)pars.GetValue("WIDTH");
                int heigth = (int)pars.GetValue("HEIGHT");

                Bitmap bmp = new Bitmap(width, heigth, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

                using (Graphics g = Graphics.FromImage(bmp))
                    Random r = new Random();

                    for (int i = 0; i < 10000; i++)
                        int x = r.Next(0, width);
                        int y = r.Next(0, heigth);
                        int w = r.Next(1, width - x);
                        int h = r.Next(1, heigth - y);
                        int col = r.Next(0, 255);
                        using (SolidBrush br = new SolidBrush(Color.FromArgb(col, col, col)))
                            g.FillRectangle(br, new Rectangle(x, y, w, h));
                        status_clbk(((float)i) / 100.0f);

                res.IsCompleted = true;
                clbk(bmp, 0);
                clbk(null, -1);



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Zimmermann Stephan
Software Developer (Senior)
Austria Austria
I have started programming at the age of 13 on the commodore 64.

Ever since then I have been programming on many systems in many languages.

During the last 12 years I have been working as professional programmer in different companies and different areas.

Now I am working as freelancer programmer / consultant

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150819.1 | Last Updated 27 Jul 2009
Article Copyright 2009 by Zimmermann Stephan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid