begin process at 2012 02 11 05:37:31
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Maths & Algorithmes

 > FRACTAL DE MANDELBROT

FRACTAL DE MANDELBROT


 Information sur la source

Note :
Aucune note
Catégorie :Maths & Algorithmes Source .NET ( DotNet ) Classé sous :fractal, mandelbrot, fractals, fractales, math graphique Niveau :Débutant Date de création :11/02/2007 Date de mise à jour :30/03/2008 11:21:56 Vu / téléchargé :9 173 / 323

Auteur : Bidou

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note


 Description

Cliquez pour voir la capture en taille normale
Le fractal de Mandelbrot est la visualisation d'un objet mathématique. Il s'agit en fait d'une matrice de nombres, où la valeur de chaque nombre est représentée par une couleur.
Chaque point de l'image est un nombre calculé par l'ordinateur selon une équation très simple: Zn+1 = Zn2 + C (pour plus d'informations, http://en.wikipedia.org/wiki/Mandelbrot_set).

Il y a deux méthodes pour dessiner le fractal dans le projet. Une fois avec une méthode qui utilise SetPixel (managé mais très lent) et une fois un bloc unsafe qui permet, via les pointeurs, d'avoir de bonnes performances.

Source

  • /// ------------------------------------------------------------------------
  • /// <summary>
  • /// Draw the fractal (with unmanaged code).
  • /// </summary>
  • /// ------------------------------------------------------------------------
  • public void DrawMandelBrotFractalUnmanaged()
  • {
  • int width = this.Width;
  • int height = this.Height;
  • int offset = width % 4;
  • int halfX = 2 * width;
  • int halfY = height / 2;
  • using (Graphics gfx = this.CreateGraphics())
  • {
  • this._bmpBuffer = new Bitmap(width, height, gfx);
  • BitmapData bmpData = this._bmpBuffer.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
  • unsafe
  • {
  • byte* newPixel = (byte*)(void*)bmpData.Scan0;
  • width *= 3;
  • for (int y = 0; y < height; ++y)
  • {
  • for (int x = 0; x < width; x += 3)
  • {
  • Complex complex = new Complex((x - halfX) / 450d, (y - halfY) / 150d);
  • Color color = this.GetColor(this.GetStep(complex));
  • newPixel[0] = color.B;
  • newPixel[1] = color.G;
  • newPixel[2] = color.R;
  • newPixel += 3;
  • }
  • newPixel += offset;
  • }
  • }
  • this._bmpBuffer.UnlockBits(bmpData);
  • Graphics.FromImage(this._bmpBuffer).DrawString("Mandelbrot's Fractal", this._font, this._fontBrush, Point.Empty);
  • gfx.DrawImage(this._bmpBuffer, Point.Empty);
  • }
  • }
       /// ------------------------------------------------------------------------
        /// <summary>
        /// Draw the fractal (with unmanaged code).
        /// </summary>
        /// ------------------------------------------------------------------------
        public void DrawMandelBrotFractalUnmanaged()
        {
            int width = this.Width;
            int height = this.Height;
            int offset = width % 4;

            int halfX = 2 * width;
            int halfY = height / 2;

            using (Graphics gfx = this.CreateGraphics())
            {
                this._bmpBuffer = new Bitmap(width, height, gfx);
                BitmapData bmpData = this._bmpBuffer.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

                unsafe
                {
                    byte* newPixel = (byte*)(void*)bmpData.Scan0;
                    width *= 3;

                    for (int y = 0; y < height; ++y)
                    {
                        for (int x = 0; x < width; x += 3)
                        {
                            Complex complex = new Complex((x - halfX) / 450d, (y - halfY) / 150d);
                            Color color = this.GetColor(this.GetStep(complex));
                            newPixel[0] = color.B;
                            newPixel[1] = color.G;
                            newPixel[2] = color.R;
                            newPixel += 3;
                        }
                        newPixel += offset;
                    }
                }
                this._bmpBuffer.UnlockBits(bmpData);
                Graphics.FromImage(this._bmpBuffer).DrawString("Mandelbrot's Fractal", this._font, this._fontBrush, Point.Empty);
                gfx.DrawImage(this._bmpBuffer, Point.Empty);
            }
        }


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

11 février 2007 11:56:07 :
Modification description
11 février 2007 15:50:56 :
Merci à Lutinore qui m'a indiqué que GDI utilisait BGR et pas RGB !

 Sources du même auteur

Source avec Zip Source .NET (Dotnet) CHESS GAME CORE - LIBRAIRIE JEU D'ÉCHEC EN C#
Source avec Zip Source avec une capture Source .NET (Dotnet) CUBE-IT: PETIT JEU EN WPF
Source avec Zip Source avec une capture Source .NET (Dotnet) YOUTUBE VIEWER
Source avec Zip Source avec une capture Source .NET (Dotnet) COLOR WHEEL
Source avec Zip Source avec une capture Source .NET (Dotnet) PETIT EXEMPLE UTILISANT XAML ET WPF

 Sources de la même categorie

Source avec Zip Source avec une capture (CONSOLE) TROUVER LA CLEF D'UN CODE INSEE EN DONNANT SES 13 ... par Maxime95k
Source avec Zip Source .NET (Dotnet) QUANTUM BIBLIOTHÈQUE MATHÉMATIQUES par QuantumNet
Source avec Zip Source avec une capture Source .NET (Dotnet) ALGORITHME DE LA PROPENSION par olivieram2
Source avec Zip Source .NET (Dotnet) PETITE LIBRAIRIE MATHÉMATIQUE par dodo7263
Source avec Zip Source .NET (Dotnet) INCLUSION D'UN POINT DANS UN CERCLE par eishtein

 Sources en rapport avec celle ci

Source avec Zip Source .NET (Dotnet) FRACTALES SOUS C# par furby5

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,640 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales