Esempio n. 1
0
        private void Draw()
        {
            performanceLogger.Start(Settings.selectedFractalType, Settings.selectedDrawingMode);

            Fractal fractal = null;

            switch (Settings.selectedFractalType)
            {
            case FractalType.Mandelbrot:
                fractal = new Mandelbrot(colorBuffer, Settings.renderWidth, Settings.renderHeight, Settings.maxIterations);
                break;

            case FractalType.Julia:
                fractal = new Julia(colorBuffer, Settings.renderWidth, Settings.renderHeight, Settings.maxIterations);
                break;

            default:
                throw new Exception("Nieprawidłowy typ fraktala: " + Settings.selectedFractalType);
            }

            switch (Settings.selectedDrawingMode)
            {
            case DrawingMode.CpuSingle:
                fractal.DrawOnSingleThread(offsetX, offsetY, zoom);
                break;

            case DrawingMode.CpuMulti:
                fractal.DrawOnMultipleThreads(offsetX, offsetY, zoom);
                break;

            case DrawingMode.Gpu:
                fractal.DrawOnGpu(offsetX, offsetY, zoom);
                break;

            default:
                throw new Exception("Nieprawidłowy typ rysowania: " + Settings.selectedDrawingMode);
            }

            performanceLogger.Stop(CountTotalIterations());

            UpdateBitmap();
            UpdateTransformationText();
        }
Esempio n. 2
0
        public void JuliaFractalTest()
        {
            byte[] a = new byte[400 * 300 * 4];
            byte[] b = new byte[400 * 300 * 4];
            byte[] c = new byte[400 * 300 * 4];

            Utils.BuildIterationColorsCache();

            Julia juliaFractal_A = new Julia(a, 400, 300, 60);

            juliaFractal_A.DrawOnSingleThread(0, 0, 1);

            Julia juliaFractal_B = new Julia(b, 400, 300, 60);

            juliaFractal_B.DrawOnMultipleThreads(0, 0, 1);

            CollectionAssert.AreEqual(a, b);

            Julia juliaFractal_C = new Julia(c, 400, 300, 60);

            juliaFractal_C.DrawOnGpu(0, 0, 1);

            CollectionAssert.AreEqual(a, c);
        }