Esempio n. 1
0
        private void initRender(WriteableBitmap bitmap, Rect view)
        {
            m_bitmap = bitmap;
            m_bitmap.Dispatcher.Invoke(new Action(() =>
            {
                m_pxWidth = m_bitmap.PixelWidth;
                if (m_pxWidth % 2 == 1)
                {
                    m_pxWidth++;
                }
                m_pxHeight      = m_bitmap.PixelHeight;
                m_bytesPerPixel = m_bitmap.Format.BitsPerPixel / 8;
                m_pBackbuffer   = m_bitmap.BackBuffer;
            }));

            m_topLeft = new Complex(view.Left, view.Top);
            m_size    = new Complex(view.Width, view.Height);

            //init point array
            m_curDepth = 0;
            m_values   = new MandelPoint[m_pxWidth, m_pxHeight];
            for (int x = 0; x < m_pxWidth; x++)
            {
                for (int y = 0; y < m_pxHeight; y++)
                {
                    m_values[x, y] = new MandelPoint(m_topLeft, m_size, x / (double)m_pxWidth, y / (double)m_pxHeight);
                }
            }
        }
Esempio n. 2
0
        private void calcPoint(int x, int y)
        {
            MandelPoint mp = m_values[x, y];

            if (mp.notInSet)
            {
                return;
            }

            do
            {
                m_fractDef.applyFunction(mp);
                if (!m_fractDef.isInSet(mp))
                {
                    setPixel(x, y, m_colorLookup[mp.depth % colorPeriod]);
                    mp.notInSet = true;
                    return;
                }

                mp.depth++;
            }while (rendering && mp.depth <= m_maxDepth && mp.depth % m_drawInterval != 0);

            setPixel(x, y, Colors.Black);
        }
Esempio n. 3
0
 //check if point is in the mandelbrot set
 public bool isInSet(MandelPoint p)
 {
     return(p.z.Real * p.z.Real + p.z.Imaginary * p.z.Imaginary < 500);
 }
Esempio n. 4
0
 ///applies mandelbrot function to point
 public void applyFunction(MandelPoint p)
 {
     p.z = p.z * p.z + p.c;
 }