Esempio n. 1
0
        static void Main(string[] args)
        {
            ArgsAdapter.initArgs(args);
            FractalViewer fractalViewer = new FractalViewer();

            fractalViewer.DrawImage();
            Console.ReadKey();
        }
Esempio n. 2
0
 public FractalViewer()
 {
     bitmap          = new Bitmap(ArgsAdapter.GetIntArgs(0), ArgsAdapter.GetIntArgs(1));
     newtonFactorial = new NewtonFractal();
     colors          = new Color[] {
         Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Orange,
         Color.Fuchsia, Color.Gold, Color.Cyan, Color.Magenta
     };
 }
Esempio n. 3
0
 public NewtonFractal()
 {
     roots                = new List <ComplexNumber>();
     xmin                 = ArgsAdapter.GetDoubleArgs(0);
     xmax                 = ArgsAdapter.GetDoubleArgs(1);
     ymin                 = ArgsAdapter.GetDoubleArgs(2);
     ymax                 = ArgsAdapter.GetDoubleArgs(3);
     xstep                = (xmax - xmin) / ArgsAdapter.GetIntArgs(0);
     ystep                = (ymax - ymin) / ArgsAdapter.GetIntArgs(1);
     polynomial           = getPolynomial();
     derivativePolynomial = polynomial.Derive();
 }
Esempio n. 4
0
 public void DrawImage()
 {
     for (int i = 0; i < bitmap.Width; i++)
     {
         for (int j = 0; j < bitmap.Height; j++)
         {
             newtonFactorial.SetComplexNumber(i, j);
             var id    = newtonFactorial.FindRootNumber();
             var it    = newtonFactorial.SolveEquationUsingNewtonsIteration();
             var color = colors[id % colors.Length];
             color = Color.FromArgb(color.R, color.G, color.B);
             color = Color.FromArgb(Math.Min(Math.Max(0, color.R - it * 2), 255), Math.Min(Math.Max(0, color.G - it * 2), 255), Math.Min(Math.Max(0, color.B - it * 2), 255));
             bitmap.SetPixel(j, i, color);
         }
     }
     bitmap.Save(ArgsAdapter.GetOutputPath() ?? "../../../out.png");
 }