Пример #1
0
        /// <summary>
        /// Draw the JuliaSet set.
        /// </summary>
        private void JuliaSet_Paint(object sender, PaintEventArgs e)
        {
            // Keep track of how long it takes to draw the scene.
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            // Determine the delta values for x and y.
            xDelta = (xMax - xMin) / (DrawRegion.Width - 1);
            yDelta = (yMax - yMin) / (DrawRegion.Height - 1);

            // Determine the color of each pixel.
            Parallel.For(0, DrawRegion.Width, x =>
            {
                for (int y = 0; y < DrawRegion.Height; ++y)
                {
                    // Calculate real and imaginary components for z.
                    double zReal = xMin + (x * xDelta);
                    double zImag = yMin + (y * yDelta);

                    // Perform the iterations.
                    Complex z      = new Complex(zReal, zImag);
                    Complex c      = new Complex(cReal, cImag);
                    int iterations = quadraticIterator.Iterate(z, c);

                    // Store pixel color.
                    colors[x, y] = ColorFactory.GetColor(colorScheme, iterations);
                }
            });

            // Fill the draw region with the calculated colors.
            SolidBrush brush = new SolidBrush(Color.Black);

            for (int x = 0; x < DrawRegion.Width; ++x)
            {
                for (int y = 0; y < DrawRegion.Height; ++y)
                {
                    brush.Color = colors[x, y];
                    e.Graphics.FillRectangle(brush, x, y, 1, 1);
                }
            }

            // Stop timing.
            stopwatch.Stop();
            paintTime = stopwatch.Elapsed;
        }
Пример #2
0
 public MoveInfo MoveNext()
 {
     if (m_CurrentPosition < Steps.Count - 1)
     {
         m_CurrentPosition++;
         return(new MoveInfo(true, false));
     }
     else if (m_IterationContext != null && m_IterationContext.CanIterate)
     {
         m_IterationContext.Iterate();
         Reset();
         return(new MoveInfo(true, true));
     }
     return(new MoveInfo(false, false));
 }
Пример #3
0
 public void WhenIIterateTheIteratorsValue()
 {
     _iterator.Iterate();
 }