Exemple #1
0
        void mandelPanel_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left) //zoom in
            {
                //add current statee to list
                MandelState state = new MandelState(middle, scale, maxLoop);
                stateList.Add(state);

                //calculate new middle + zoom
                middle = mandelImage.pixelToMandelPoint(e.X, e.Y);
                scale /= 2;
            }
            else if (e.Button == MouseButtons.Right) //zoom out
            {
                if (stateList.Count == 0)
                {
                    return; //don't refresh when there is no previous state
                }
                // loads the previous settings in textfields
                scale   = stateList.Last().scale;
                middle  = stateList.Last().middle;
                maxLoop = stateList.Last().maxLoop;
                stateList.Remove(stateList.Last());
            }
            refreshImage();
            fillTextFields();
        }
Exemple #2
0
        List <MandelColor> colorList = new List <MandelColor>(); // list for all possible colorfilters

        public MandelForm()
        {
            InitializeComponent();

            //add color filters
            colorList.Add(new RandomColor());
            colorList.Add(new BlueAlpha());
            colorList.Add(new RedGreenBlue());
            colorList.Add(new Fire());
            colorList.Add(new Green());
            colorList.Add(new BlackWhite());
            foreach (MandelColor color in colorList)
            {
                comboBoxColors.Items.Add(color.ToString());
            }
            comboBoxColors.SelectedItem = comboBoxColors.Items[0];

            //initialize variables
            middle = new MandelPoint(0, 0);
            refreshImage();
            fillTextFields();

            //register event handlers
            mandelPanel.Paint      += mandelPanel_Paint;
            mandelPanel.MouseClick += mandelPanel_MouseClick;
            mandelPanel.MouseMove  += mandelPanel_MouseMove;
            comboBoxColors.SelectedIndexChanged += comboBoxColors_SelectedIndexChanged;
        }
Exemple #3
0
        void mandelPanel_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left) //zoom in
            {
                //add current statee to list
                MandelState state = new MandelState(middle, scale, maxLoop);
                stateList.Add(state);

                //calculate new middle + zoom
                middle = mandelImage.pixelToMandelPoint(e.X, e.Y);
                scale /= 2;
            }
            else if (e.Button == MouseButtons.Right) //zoom out
            {
                if (stateList.Count == 0)
                    return; //don't refresh when there is no previous state

                // loads the previous settings in textfields
                scale = stateList.Last().scale;
                middle = stateList.Last().middle;
                maxLoop = stateList.Last().maxLoop;
                stateList.Remove(stateList.Last());
            }
            refreshImage();
            fillTextFields();
        }
Exemple #4
0
        List<MandelColor> colorList = new List<MandelColor>(); // list for all possible colorfilters

        public MandelForm()
        {
            InitializeComponent();

            //add color filters
            colorList.Add(new RandomColor());
            colorList.Add(new BlueAlpha());
            colorList.Add(new RedGreenBlue());
            colorList.Add(new Fire());
            colorList.Add(new Green());
            colorList.Add(new BlackWhite());
            foreach (MandelColor color in colorList)
                comboBoxColors.Items.Add(color.ToString());
            comboBoxColors.SelectedItem = comboBoxColors.Items[0];

            //initialize variables
            middle = new MandelPoint(0, 0);
            refreshImage();
            fillTextFields();

            //register event handlers
            mandelPanel.Paint += mandelPanel_Paint;
            mandelPanel.MouseClick += mandelPanel_MouseClick;
            mandelPanel.MouseMove += mandelPanel_MouseMove;
            comboBoxColors.SelectedIndexChanged += comboBoxColors_SelectedIndexChanged;
        }
Exemple #5
0
        void mandelPanel_MouseMove(object sender, MouseEventArgs e)
        {
            // display current position in graph
            MandelPoint mandelPoint = mandelImage.pixelToMandelPoint(e.X, e.Y);
            int         n           = mandelImage.mandelPointToNumber(mandelPoint);

            this.Text = String.Format("({0}, {1}): {2}", mandelPoint.a, mandelPoint.b, n);
        }
Exemple #6
0
        int maxLoop; //number of times to try calculating the mandel number

        public MandelImage(int width, int height, MandelPoint middle, double scale, int maxLoop = 100)
        {
            // properties of the image
            this.width = width;
            this.height = height;
            this.middle = middle;
            this.scale = scale;
            this.maxLoop = maxLoop;
        }
Exemple #7
0
        int maxLoop;        //number of times to try calculating the mandel number

        public MandelImage(int width, int height, MandelPoint middle, double scale, int maxLoop = 100)
        {
            // properties of the image
            this.width   = width;
            this.height  = height;
            this.middle  = middle;
            this.scale   = scale;
            this.maxLoop = maxLoop;
        }
Exemple #8
0
 private void buttonSpace_Click(object sender, EventArgs e)
 {
     scale   = 3.0517578125E-07;
     maxLoop = 1000;
     middle  = new MandelPoint(-1.6320947265625, -4.7607421875E-05);
     comboBoxColors.SelectedItem = comboBoxColors.Items[1];
     fillTextFields();
     refreshImage();
 }
Exemple #9
0
 // methods for examples
 private void buttonTeeth_Click(object sender, EventArgs e)
 {
     scale   = 6.103515625E-07;
     maxLoop = 1000;
     middle  = new MandelPoint(-1.63213623046875, -3.662109375E-06);
     comboBoxColors.SelectedItem = comboBoxColors.Items[0];
     fillTextFields();
     refreshImage();
 }
Exemple #10
0
 //calculate the mandel number for a point 'pt'
 public int calculate(MandelPoint point)
 {
     MandelPoint basePoint = new MandelPoint(0, 0);
     for (int i = 0; i < maxLoop; i++)
     {
         basePoint = transform(basePoint, point.a, point.b);
         if (!basePoint.IsInBounds())
             return i + 1;
     }
     return INVALID;
 }
Exemple #11
0
        //calculate the mandel number for a point 'pt'
        public int calculate(MandelPoint point)
        {
            MandelPoint basePoint = new MandelPoint(0, 0);

            for (int i = 0; i < maxLoop; i++)
            {
                basePoint = transform(basePoint, point.a, point.b);
                if (!basePoint.IsInBounds())
                {
                    return(i + 1);
                }
            }
            return(INVALID);
        }
Exemple #12
0
 // method for adjusting settings when clicking 'refresh'
 private void buttonRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         scale   = double.Parse(textBoxScale.Text);
         maxLoop = int.Parse(textBoxMax.Text);
         middle  = new MandelPoint(double.Parse(textBoxMiddleX.Text), double.Parse(textBoxMiddleY.Text));
         refreshImage();
     }
     catch (Exception)
     {
         MessageBox.Show("Invalid format used!", "Error"); // in case input is not a number
     }
 }
Exemple #13
0
 private void buttonSpace_Click(object sender, EventArgs e)
 {
     scale = 3.0517578125E-07;
     maxLoop = 1000;
     middle = new MandelPoint(-1.6320947265625, -4.7607421875E-05);
     comboBoxColors.SelectedItem = comboBoxColors.Items[1];
     fillTextFields();
     refreshImage();
 }
Exemple #14
0
 // the state of the mandelimage with 3 variables
 public MandelState(MandelPoint middle, double scale, int maxLoop)
 {
     this.middle = middle;
     this.scale = scale;
     this.maxLoop = maxLoop;
 }
Exemple #15
0
 //transform a mandel point: f(a,b) = (a*a - b*b + x, 2*a*b + y)
 private static MandelPoint transform(MandelPoint basePoint, double x, double y)
 {
     return new MandelPoint(basePoint.a * basePoint.a - basePoint.b * basePoint.b + x, 2 * basePoint.a * basePoint.b + y);
 }
Exemple #16
0
        //get the mandel number for a specified point in the mandelbrot image
        public int mandelPointToNumber(MandelPoint point)
        {
            MandelNumber mandelNumber = new MandelNumber(maxLoop);

            return(mandelNumber.calculate(point));
        }
Exemple #17
0
 //transform a mandel point: f(a,b) = (a*a - b*b + x, 2*a*b + y)
 private static MandelPoint transform(MandelPoint basePoint, double x, double y)
 {
     return(new MandelPoint(basePoint.a * basePoint.a - basePoint.b * basePoint.b + x, 2 * basePoint.a * basePoint.b + y));
 }
Exemple #18
0
 // the state of the mandelimage with 3 variables
 public MandelState(MandelPoint middle, double scale, int maxLoop)
 {
     this.middle  = middle;
     this.scale   = scale;
     this.maxLoop = maxLoop;
 }
Exemple #19
0
 // methods for examples
 private void buttonTeeth_Click(object sender, EventArgs e)
 {
     scale = 6.103515625E-07;
     maxLoop = 1000;
     middle = new MandelPoint(-1.63213623046875, -3.662109375E-06);
     comboBoxColors.SelectedItem = comboBoxColors.Items[0];
     fillTextFields();
     refreshImage();
 }
Exemple #20
0
 //get the mandel number for a specified point in the mandelbrot image
 public int mandelPointToNumber(MandelPoint point)
 {
     MandelNumber mandelNumber = new MandelNumber(maxLoop);
     return mandelNumber.calculate(point);
 }
Exemple #21
0
 // method for adjusting settings when clicking 'refresh'
 private void buttonRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         scale = double.Parse(textBoxScale.Text);
         maxLoop = int.Parse(textBoxMax.Text);
         middle = new MandelPoint(double.Parse(textBoxMiddleX.Text), double.Parse(textBoxMiddleY.Text));
         refreshImage();
     }
     catch (Exception)
     {
         MessageBox.Show("Invalid format used!", "Error"); // in case input is not a number
     }
 }