Example #1
0
        private void Engine()
        {
            fern = new BarnsleyFern();
            long iteration = 0;

            Console.WriteLine("Starting the generator...");
            double[] Coord = new double[2] {
                0, 0
            };                                       // Starting Coordinate
            List <double[]> medCoord         = new List <double[]>(1);
            List <double[]> medCoordUnscaled = new List <double[]>(1);

            while (!IsExitting)
            {
                Thread.Sleep(500);
                while (Draw)
                {
                    medCoordUnscaled = fern.Generate(Coord);

                    Coord[0] = medCoordUnscaled[0][0];
                    Coord[1] = medCoordUnscaled[0][1];

                    DrawEvent(medCoordUnscaled, iteration++);
                }
            }
        }
        private void DrawPoint(List <double[]> coord, long iteration)
        {
            List <double[]> medCoord = BarnsleyFern.ScaleToDisplay(coord,
                                                                   Display.ClientSize.Height, Display.ClientSize.Width / 2,
                                                                   Display.ClientSize.Width / 4, 0);

            try
            {
                g.DrawEllipse(Pens.Black, new Rectangle((int)medCoord[0][0], (int)medCoord[0][1], 1, 1));
            }
            catch (Exception)
            {
                Console.WriteLine("Memory Overflow...");
            }

            if (++memoryDumpCounter > 20000)
            {
                SaveToFile(); // Prevents running out of RAM
            }
        }