public void StartApp(IReadOnlyCollection <string> args) { int width = 900, height = 600; var iterations = 20; int offsetX = 0, offsetY = 0; var zoom = 1.0f; var options = new OptionSet { { "w=", x => width = int.Parse(x) }, { "h=", x => height = int.Parse(x) }, { "iter=", x => iterations = int.Parse(x) }, { "ofX=", x => offsetX = int.Parse(x) }, { "ofY=", x => offsetY = int.Parse(x) }, { "z=", x => zoom = float.Parse(x) }, { "help", x => PrintHelp() } }; List <string> argsList; try { argsList = options.Parse(args); } catch (FormatException) { Console.WriteLine("Wrong parameter types!"); return; } catch (OptionException) { Console.WriteLine("Some of the specified launch parameters do not contain a required value!"); return; } if (width < 10 || height < 10 || zoom <= 0) { Console.WriteLine("Wrong parameter values!"); return; } if (argsList.Count == args.Count || args.Count < 1) { Console.WriteLine("Using default values. Start with -help to get more information."); } if (isHelp) { return; } IFractal fractal = new MandelbrotSet(iterations, offsetX, offsetY, zoom); fractal.Listener = this; fractal.GetFractal(width, height); }
private void CreateTask(TileIndex id, DataRect bounds) { Task task = Task.Create(o => { var set = new MandelbrotSet(size, bounds); set.Palette = new HSBPalette(); var bmp = set.Draw(); bmp.Freeze(); ReportSuccessAsync(null, bmp, id); LookForNexttask(); }, manager); }
private void CreateTask(TileIndex id, DataRect bounds) { var task = factory.StartNew(() => { var set = new MandelbrotSet(size, bounds); set.Palette = new HSBPalette(); var bmp = set.Draw(); bmp.Freeze(); ReportSuccessAsync(null, bmp, id); LookForNexttask(); }); }
private void CreateTask(TileIndex id, DataRect bounds) { Task task = factory.StartNew(() => { Thread.CurrentThread.Priority = ThreadPriority.Lowest; var set = new MandelbrotSet(size, bounds); set.Palette = new HsbPalette(); var bmp = set.Draw(); bmp.Freeze(); ReportSuccessAsync(null, bmp, id); LookForNextTask(); }); }
public void ScaleTest(double value, double currentScaleMin, double currentScaleMax, double desiredScaleMin, double desiredScaleMax, double expected) { var actual = MandelbrotSet.Scale(value, currentScaleMin, currentScaleMax, desiredScaleMin, desiredScaleMax); Assert.Equal(expected, actual, 6); }
public MandelbrotRenderer(Paint paint) : base(paint) { Mandelbrot = new MandelbrotSet(); }