예제 #1
0
파일: Form1.cs 프로젝트: rbovenkamp/Imp
        // Inzoomen op de mandelbrot wanneer de gebruiker scrollt
        private void zoomOnMandelbrot(object sender, MouseEventArgs e)
        {
            // Nieuwe schaal afhankelijk van hoe ver er gescrollt is
            double newScale = this.CurrentState.Scale * Math.Pow(0.999, e.Delta);
            int    width    = pictureBox1.Width;
            int    height   = pictureBox1.Height;

            // Om 1 of andere reden kan er ook een delta van 0 optreden, in dit geval verandert er niks aan de coordinaten
            if (e.Delta > 0)
            {
                // Zorg dat het punt waar je op inzoomt onder de muis blijft met de nieuwe schaal
                double selectedX  = ((e.X - width / 2)) * this.CurrentState.Scale + this.CurrentState.Center.X;
                double leftBorder = selectedX - e.X * newScale;
                double xOffset    = leftBorder + (width / 2 * newScale);

                double selectedY = ((e.Y - height / 2)) * this.CurrentState.Scale + this.CurrentState.Center.Y;
                double topBorder = selectedY - e.Y * newScale;
                double yOffset   = topBorder + (height / 2 * newScale);

                CurrentState = new MandelbrotState(CurrentState.MaxIterations, newScale, new PointD(xOffset, yOffset));
            }
            else
            {
                CurrentState = new MandelbrotState(CurrentState.MaxIterations, newScale, CurrentState.Center);
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: rbovenkamp/Imp
        // Inzoomen wanneer de gebruiker op de mandelbrot klikt, plaats ook de geklikte locatie in het midden
        private void clickOnMandelbrot(object sender, MouseEventArgs e)
        {
            int mouseX = e.X;
            int mouseY = e.Y;
            int width  = pictureBox1.Width;
            int height = pictureBox1.Height;

            double selectedX = ((mouseX - width / 2)) * this.CurrentState.Scale + this.CurrentState.Center.X;
            double selectedY = ((mouseY - height / 2)) * this.CurrentState.Scale + this.CurrentState.Center.Y;

            CurrentState = new MandelbrotState(CurrentState.MaxIterations, this.CurrentState.Scale / 2, new PointD(selectedX, selectedY));
        }
예제 #3
0
파일: Form1.cs 프로젝트: rbovenkamp/Imp
 public void DrawMandelBrot(MandelbrotState state, uint?iterations = null)
 {
     pictureBox1.Image = state.ToImage(this.pictureBox1.Size, iterations ?? state.MaxIterations);
 }