Exemplo n.º 1
0
        /// <summary>
        /// Generate image (L-System)
        /// </summary>
        public void GenerateImage()
        {
            Backend.Parser parser          = new Backend.Parser(Axiom, Rules, Iterations);
            string         expandedGrammar = "";

            try
            {
                expandedGrammar = parser.Expand();
            }
            catch (OutOfMemoryException)
            {
                System.Windows.MessageBox.Show("Not enough memory, try decrease number of iterations.");
                return;
            }

            Backend.LSystem lsystem = new Backend.LSystem(expandedGrammar,
                                                          new PointF(StartX * ((float)Renderer.WIDTH / Renderer.PREVIEW_WIDTH), StartY * ((float)Renderer.HEIGHT / Renderer.PREVIEW_HEIGHT)),
                                                          (float)(StartAngle / 180 * Math.PI),
                                                          StepSize,
                                                          (float)(Delta / 180 * Math.PI),
                                                          (AngleDelta / 100.0f),
                                                          (StepDelta / 100.0f),
                                                          Seed,
                                                          new Pen(new SolidBrush(Color.Black), LineWidth));

            List <Backend.IDrawable> polylist = lsystem.Generate();

            _renderer.Clear(SelectedBackgroundColor);
            _renderer.Paint(polylist);

            // cleanup
            polylist.Clear();

            // update gui
            InvokePropertyChanged("Image");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generate image (L-System)
        /// </summary>
        public void GenerateImage()
        {
            Backend.Parser parser = new Backend.Parser(Axiom, Rules, Iterations);
            string expandedGrammar = "";

            try
            {
                expandedGrammar = parser.Expand();
            }
            catch (OutOfMemoryException)
            {
                System.Windows.MessageBox.Show("Not enough memory, try decrease number of iterations.");
                return;
            }

            Backend.LSystem lsystem = new Backend.LSystem(expandedGrammar,
                new PointF(StartX * ((float)Renderer.WIDTH / Renderer.PREVIEW_WIDTH), StartY * ((float)Renderer.HEIGHT / Renderer.PREVIEW_HEIGHT)),
                (float)(StartAngle / 180 * Math.PI),
                StepSize,
                (float)(Delta / 180 * Math.PI),
                (AngleDelta / 100.0f),
                (StepDelta / 100.0f),
                Seed,
                new Pen(new SolidBrush(Color.Black), LineWidth));

            List<Backend.IDrawable> polylist = lsystem.Generate();

            _renderer.Clear(SelectedBackgroundColor);
            _renderer.Paint(polylist);

            // cleanup
            polylist.Clear();

            // update gui
            InvokePropertyChanged("Image");
        }