Public Class Form1 Dim bmp As Bitmap Dim lastMouseX, lastMouseY As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load bmp = New Bitmap(PictureBox1.Width, PictureBox1.Width, Imaging.PixelFormat.Format32bppArgb) End Sub Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click 'recreate the bitmap bmp = Nothing bmp = New Bitmap(PictureBox1.Width, PictureBox1.Width, Imaging.PixelFormat.Format32bppArgb) Dim g As Graphics = Graphics.FromImage(bmp) g.Clear(Color.Black) On Error Resume Next Dim X As Decimal, Y As Decimal Dim xsquare, ysquare As Decimal Dim dx As Decimal, dy As Decimal Dim i As Integer, j As Decimal, bail As Decimal Dim iter, mul, col As Integer Dim rangex1, rangex2, rangey1, rangey2 As Decimal Dim q(0 To bmp.Width + 1) As Decimal, p As Decimal Dim xpos, ypos As Integer Dim palette(256) As Color 'set up a palette For i = 0 To 63 palette(i) = Color.FromArgb(0, i * 4, (63 - i) * 4) Next For i = 64 To 127 palette(i) = Color.FromArgb((i - 64) * 4, (127 - i) * 4, 0) Next For i = 128 To 191 palette(i) = Color.FromArgb(255, 0, (i - 128) * 4) Next For i = 192 To 255 palette(i) = Color.FromArgb((255 - i) * 4, 0, 255) Next rangex1 = txtRangex1.Text rangex2 = txtRangex2.Text rangey1 = txtRangey1.Text rangey2 = txtRangey2.Text iter = Int(txtIterations.Text) mul = 255 / iter bail = txtBailout.Text dx = (rangex2 - rangex1) / bmp.Width dy = (rangey2 - rangey1) / bmp.Height q(0) = rangey2 For i = 1 To bmp.Width q(i) = q(i - 1) - dy Next i ProgressBar1.Maximum = bmp.Width xpos = 0 : ypos = 0 For p = rangex1 To rangex2 Step dx i = 0 For j = rangey1 To rangey2 Step dy X = 0 : Y = 0 : xsquare = 0 : ysquare = 0 : col = 1 Do If col > iter Then bmp.SetPixel(xpos, ypos, Color.Black) Exit Do End If If Math.Sqrt(xsquare + ysquare) > bail Then bmp.SetPixel(xpos, ypos, palette((col * mul) Mod 255)) Exit Do End If xsquare = X * X ysquare = Y * Y Y = Y * X Y = Y + (Y + q(i)) X = xsquare - ysquare + p col = col + 1 Loop i = i + 1 ypos = ypos + 1 If ypos >= bmp.Height Then Exit For Next j xpos = xpos + 1 If xpos >= bmp.Width Then Exit For ypos = 0 ProgressBar1.Value = xpos Next p PictureBox1.Image = bmp ProgressBar1.Value = 0 End Sub Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove lastMouseX = e.X lastMouseY = e.Y End Sub Private Sub Zoom(ByVal amount As Decimal) Dim rangex1, rangex2, rangey1, rangey2 As Decimal Dim posx, posy As Decimal posx = lastMouseX posy = bmp.Height - lastMouseY rangex1 = txtRangex1.Text rangex2 = txtRangex2.Text rangey1 = txtRangey1.Text rangey2 = txtRangey2.Text posx = posx * (rangex2 - rangex1) / bmp.Width posx = posx + rangex1 posy = posy * (rangey2 - rangey1) / bmp.Height posy = posy + rangey1 txtRangex1.Text = posx - (rangex2 - rangex1) * amount txtRangex2.Text = posx + (rangex2 - rangex1) * amount txtRangey1.Text = posy - (rangey2 - rangey1) * amount txtRangey2.Text = posy + (rangey2 - rangey1) * amount btnGo_Click(Nothing, Nothing) End Sub Private Sub PictureBox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.DoubleClick Zoom(0.25) End Sub Private Sub ZoomOutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ZoomOutToolStripMenuItem.Click Zoom(1.25) End Sub End Class