Beispiel #1
0
 public Image RenderFractal(RenderProperties properties, RenderColors colors)
 {
     IFractal fract =  GetFractal(properties,colors);
     fract.RenderComplete += RenderCompleteCall;
     fract.RenderProgress += RenderProgressCall;
     return fract.GenerateImage(new Size(properties.Width,properties.Height),properties.Area);
 }
 public void ShowFractal(RenderProperties properties, RenderColors colors)
 {
     Task.Factory.StartNew(()=>
        {
            RenderAndSetFractal(properties,colors);
        });
 }
Beispiel #3
0
        private IFractal GetFractal(RenderProperties properties, RenderColors colors)
        {
            IFractal fractal = null;

            if(properties.Fractal == FractalType.Mandelbrot)
            {
                if(properties.SingleIteration)
                {
                    fractal = new MandelbrotSet(colors.FractalColor, colors.BackgroundColor, properties.Iterations);
                }
                else
                {
                    fractal = new MandelbrotSet(colors.GetColorPalette(properties.Iterations),
                        properties.Iterations);
                }
            }
            else if(properties.Fractal == FractalType.Julia)
            {
                if(properties.SingleIteration)
                {
                    fractal = new JuliaSet(colors.FractalColor,
                        colors.BackgroundColor,
                        properties.RealConst,
                        properties.ImaginaryConst,
                        properties.Iterations);
                }
                else
                {
                     fractal = new JuliaSet(colors.GetColorPalette(properties.Iterations),
                         properties.RealConst,
                         properties.ImaginaryConst,
                         properties.Iterations);
                }
            }

            return fractal;
        }
 private void UpdateViewProperties(RenderProperties newProperties)
 {
     _view.UpdateProperties(newProperties);
 }
        private void RenderAndSetFractal(RenderProperties properties,RenderColors colors)
        {
            this._renderColors = colors;
            this._renderProperties = properties;

            var i = _renderEngine.RenderFractal(properties, colors);
            if (_renderViewThread == null || !_renderViewThread.IsAlive)
            {
                CreateRenderViewThread(i);
                _fractalsStack.Clear();
            }
            else
            {
                _view.ShowImage(i);
            }
            _lastRender = new FractInfo() { Image = i, Area = properties.Area };
            ActualFractalImage = i;
        }
Beispiel #6
0
        public void UpdateProperties(RenderProperties properties)
        {
            this.Invoke((MethodInvoker)(()=>{
                this.imageWidthTextBox.Text = properties.Width.ToString();
                this.imageHeightTextBox.Text = properties.Height.ToString();
                this.startPositionTextBox.Text = string.Format("{0}:{1}",
                    properties.StartX.ToString(CultureInfo.InvariantCulture),
                    properties.StartY.ToString(CultureInfo.InvariantCulture));

                this.sideLenghtTextBox.Text = properties.SideLenght.ToString(CultureInfo.InvariantCulture);
                this.realConstTextBox.Text = properties.RealConst.ToString(CultureInfo.InvariantCulture);
                this.imaginaryConstTextBox.Text = properties.ImaginaryConst.ToString(CultureInfo.InvariantCulture);
                this.iterationshScrollBar.Value = properties.Iterations;
            }));
        }
Beispiel #7
0
        public RenderProperties GetRenderProperties()
        {
            double[] startP = ParseStartPosition();
            FractalType fractType = (FractalType)(Enum.Parse(typeof(FractalType),
                fractalTypeComboBox.SelectedItem.ToString()));
            RenderProperties properties = new RenderProperties{

                Fractal = fractType,

                Width = int.Parse(imageWidthTextBox.Text),
                Height = int.Parse(imageHeightTextBox.Text),
                Iterations = iterationshScrollBar.Value,
                SideLenght = double.Parse(sideLenghtTextBox.Text,CultureInfo.InvariantCulture),
                SingleIteration = singleIterationMode.Checked,
                StartX = startP[0],
                StartY = startP[1],
                RealConst = double.Parse(realConstTextBox.Text,CultureInfo.InvariantCulture),
                ImaginaryConst = double.Parse(imaginaryConstTextBox.Text,CultureInfo.InvariantCulture)
            };

            return properties;
        }