Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            zoom             = 1;
            zoomText.Text    = "1";
            currentZoom.Text = "Current Zoom = " + zoom + "x";
            offset           = new Complex(0, 0);
            Bitmap bm = new Bitmap(picCanvas.Width, picCanvas.Height);

            for (int x = 0; x < picCanvas.Width; x++)
            {
                for (int y = 0; y < picCanvas.Height; y++)
                {
                    double  a  = (double)(x - (picCanvas.Width / 2)) / (double)(picCanvas.Width / 4);
                    double  b  = (double)(y - (picCanvas.Height / 2)) / (double)(picCanvas.Height / 4);
                    Complex c0 = new Complex(a, b);
                    Complex z  = new Complex(0, 0);
                    int     it = 0;
                    do
                    {
                        it++;
                        z.Square();
                        z.Add(c0);
                        if (z.Magnitude() > 2.0)
                        {
                            break;
                        }
                    }while (it < 129);
                    bm.SetPixel(x, y, Color.FromArgb(it % 128 * 2, it % 64 * 4, it % 32 * 8));
                }

                picCanvas.Image = bm;
            }
        }
Ejemplo n.º 2
0
        private void picCanvas_MouseClick(object sender, MouseEventArgs e)
        {
            double Mouse_X = e.X;
            double Mouse_Y = e.Y;
            double c;
            double d;

            c = (double)(Mouse_X - (picCanvas.Width / 2)) / (double)(picCanvas.Width / 4 * zoom);
            d = (double)(Mouse_Y - (picCanvas.Height / 2)) / (double)(picCanvas.Height / 4 * zoom);



            zoom             = zoom + zoomAdd;
            currentZoom.Text = "Current Zoom = " + zoom + "x";
            Complex offset1 = new Complex(c, d);

            offset.Add(offset1);
            System.Diagnostics.Debug.WriteLine(c);
            System.Diagnostics.Debug.WriteLine(d);
            //newCX = (float)Mouse_X;
            //newCY = (float)Mouse_Y;

            // picCanvas.Refresh();


            Bitmap bm = new Bitmap(picCanvas.Width, picCanvas.Height);

            for (int x = 0; x < picCanvas.Width; x++)
            {
                for (int y = 0; y < picCanvas.Height; y++)
                {
                    double  a  = (double)(x - ((picCanvas.Width) / 2)) / (double)((picCanvas.Width) / 4 * zoom);
                    double  b  = (double)(y - ((picCanvas.Width) / 2)) / (double)((picCanvas.Width) / 4 * zoom);
                    Complex c0 = new Complex(a, b);
                    c0.Add(offset);
                    Complex z  = new Complex(0, 0);
                    int     it = 0;
                    do
                    {
                        it++;
                        z.Square();
                        z.Add(c0);
                        if (z.Magnitude() > 2.0)
                        {
                            break;
                        }
                    }while (it < 129);
                    bm.SetPixel(x, y, Color.FromArgb(it % 128 * 2, it % 64 * 4, it % 32 * 8));
                }

                picCanvas.Image = bm;
            }
        }
Ejemplo n.º 3
0
        // ReSharper disable once SuggestBaseTypeForParameter
        private static void ComputeJuliaSetAtOffset(Complex a, Action <byte> action)
        {
            var c = new Complex
            {
                Real      = -0.8f,
                Imaginary = +0.156f,
            };

            for (byte i = 0; i < 255; ++i)
            {
                a = a * a + c;

                if (a.Magnitude() >= 2)
                {
                    action(i);
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        private static void ComputeJuliaSetAtOffset(deviceptr <byte> result, Complex a, int offset)
        {
            var c = new Complex
            {
                Real      = -0.8f,
                Imaginary = +0.156f,
            };

            for (byte i = 0; i < byte.MaxValue; ++i)
            {
                a = a * a + c;

                if (a.Magnitude() >= 2)
                {
                    result[offset + 0] = i;
                    result[offset + 1] = i;
                    result[offset + 2] = i;
                    break;
                }
            }
        }