Esempio n. 1
0
 /// <summary>
 /// Cette fonction crée une image façon Andy Warhol. En dupliquant l'image 4 fois dans les coins et en la faisant passer dans un filtre popArt.
 /// </summary>
 /// <returns>
 /// Elle retourne une matrice de pixel contenant 4 fois l'image choisi par l'utilisateur dans des styles différents.
 /// </returns>
 public Pixel[,] Innovation()
 {
     Pixel[,] temp = new Pixel[image.GetLength(0) * 2, image.GetLength(1) * 2];
     for (int i = 0; i < image.GetLength(0); i++)
     {
         for (int j = 0; j < image.GetLength(1); j++)
         {
             temp[i, j] = image[i, j].PopArt();
         }
     }
     for (int i = image.GetLength(0); i < temp.GetLength(0); i++)
     {
         for (int j = image.GetLength(1); j < temp.GetLength(1); j++)
         {
             temp[i, j] = image[i - image.GetLength(0), j - image.GetLength(1)].PopArt_2();
         }
     }
     for (int i = 0; i < image.GetLength(0); i++)
     {
         for (int j = image.GetLength(1); j < temp.GetLength(1); j++)
         {
             temp[i, j] = image[i, j - image.GetLength(1)].PopArt_3();
         }
     }
     for (int i = image.GetLength(0); i < temp.GetLength(0); i++)
     {
         for (int j = 0; j < image.GetLength(1); j++)
         {
             temp[i, j] = image[i - image.GetLength(0), j].PopArt_4();
         }
     }
     return(temp);
 }
Esempio n. 2
0
        /// <summary>
        /// Cette fonction crée une nouvelle matrice de pixel contenant soit une fractale de Mandelbrot soit de Julia.
        /// </summary>
        /// <returns>
        /// Elle retourne une matrice de pixel de la fractale.
        /// </returns>
        public Pixel[,] Fractale()
        {
            Console.WriteLine("Quelle fractale voulez vous affichez? Tapez 1 pour la fractale de Mandelbrot, 2 pour celle de Julia ");
            string choix = Convert.ToString(Console.ReadLine());
            double x_min = 0;
            double x_max = 0;
            double y_min = 0;
            double y_max = 0;
            double c_x   = 0;
            double c_y   = 0;
            double x_n   = 0;
            double y_n   = 0;

            Console.WriteLine("Saisissez la hauteur de votre fractale (entre 0 et 1000) ==>");
            int hauteur = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Saisissez la largeur de votre fractale (entre 0 et 1000) ==>");
            int largeur = Convert.ToInt32(Console.ReadLine());

            Pixel[,] Image_fractale = new Pixel[largeur, hauteur];
            int iteration_max = 50;

            if (choix == "1")
            {
                x_min = -2;
                x_max = 0.5;
                y_min = -1.25;
                y_max = 1.25;
            }
            if (choix == "2")
            {
                x_min = -1.25;
                x_max = 1.25;
                y_min = -1.25;
                y_max = 1.25;
            }

            for (int y = 0; y < Image_fractale.GetLength(1); y++)
            {
                for (int x = 0; x < Image_fractale.GetLength(0); x++)
                {
                    if (choix == "1")
                    {
                        c_x = (x * (x_max - x_min) / Image_fractale.GetLength(0) + x_min);
                        c_y = (y * (y_min - y_max) / Image_fractale.GetLength(1) + y_max);
                        x_n = 0;
                        y_n = 0;
                    }
                    if (choix == "2")
                    {
                        c_x = 0.285;
                        c_y = 0.01;
                        x_n = (x * (x_max - x_min) / Image_fractale.GetLength(1) + x_min);
                        y_n = (y * (y_min - y_max) / Image_fractale.GetLength(0) + y_max);
                    }
                    int compteur = 0;

                    while ((x_n * x_n + y_n * y_n) < 4 && compteur < iteration_max)
                    {
                        double temporaire_x = x_n;
                        double temporaire_y = y_n;
                        x_n      = temporaire_x * temporaire_x - temporaire_y * temporaire_y + c_x;
                        y_n      = 2 * temporaire_x * temporaire_y + c_y;
                        compteur = compteur + 1;
                    }
                    if (compteur == iteration_max)
                    {
                        Image_fractale[x, y] = new Pixel(0, 0, 0);
                    }
                    else
                    {
                        //amélioration trouvée sur Internet pour rendre l'image plus agréable à regarder.
                        Image_fractale[x, y] = new Pixel((3 * compteur) % 256, (1 * compteur) % 256, (10 * compteur) % 256);
                    }
                }
            }
            return(Image_fractale);
        }