Ejemplo n.º 1
0
        public Bitmap ColorizePicture(ImageArguments arguments)
        {
            Bitmap image = new Bitmap(arguments.Width, arguments.Height);

            List <Complex> roots          = new List <Complex>();
            Polynomial     derivedPolynom = CreateStartFunction().Derive();

            for (int x = 0; x < arguments.Width; x++)
            {
                for (int y = 0; y < arguments.Height; y++)
                {
                    double yPosition = arguments.Ymin + x * arguments.Ystep;
                    double xPosition = arguments.Xmin + y * arguments.Xstep;

                    Complex coordinates = new Complex()
                    {
                        Real      = xPosition,
                        Imaginary = yPosition
                    };

                    coordinates = CalculateSolutionOfEquation(coordinates, derivedPolynom);

                    int   id    = FindRoot(roots, coordinates);
                    Color color = ColorizePixel(id);
                    image.SetPixel(y, x, color);
                }
            }
            return(image);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            ImageArguments arguments = new ImageArguments();

            arguments.Parse(args);
            NewtonFractals fractals = new NewtonFractals();
            Bitmap         image    = fractals.ColorizePicture(arguments);

            image.Save(arguments.FilePath ?? "../../../out.png");
        }