Mandelbrot set Generator

Mandelbrot set Generator preview image

1 collaborator

Default-person Apollo Albright (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.1.0 • Viewed 343 times • Downloaded 43 times • Run 0 times
Download the 'Mandelbrot set Generator' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

turtles-own [x0 iteration y0 xtemp x y Zoom-factor mousex mousey]

To Startup
  ca
  create-turtles 1
  ask turtles [ht]
  ask turtles [setxy -500 500]
  ask turtles [facexy -499 500]
  ask turtles [set Zoom-factor 1
    set mousex 0
    set mousey 0]
end 

To Main
  Startup
  Draw
  loop
  [Zoom]
end 

to Draw
  ask turtles
  [while [ycor >= -499]
    [fd 1
      Calculate
      if not can-move? 1
      [setxy -500 ycor - 1]]]
end 

to Calculate
  set x0 (xcor / 250)
  set y0 (ycor / 250)
  set x (0)
  set xtemp (0)
  set y (0)
  set iteration (0)
  while [((x * x) + (y * y)) < 2 * 2 and iteration < maxiteration]
  [set xtemp ((x * x) - (y * y) + x0)
    set y ((2 * x * y) + y0)
    set x (xtemp)
    set iteration (iteration + 1)]
  set pcolor (iteration / (maxiteration / 10)) + (color-scheme * 10)
end 

to Zoom
  while [not mouse-down?]
  []
  cp
  ask turtles
    [set mousex (mouse-xcor + (mousex * zoom-factor)) / zoom-factor
      set mousey (mouse-ycor + (mousey * zoom-factor)) / zoom-factor
      set zoom-factor (zoom-factor * 4)
      Draw-Zoom
      show zoom-factor]
end 

to Calculate-Zoom
  set x0 ((xcor + (zoom-factor * mousex)) / (250 * zoom-factor))
  set y0 ((ycor + (zoom-factor * mousey)) / (250 * zoom-factor))
  set x (0)
  set xtemp (0)
  set y (0)
  set iteration 0
  while [((x * x) + (y * y)) < 2 * 2 and iteration < maxiteration]
    [set xtemp ((x * x) - (y * y) + x0)
      set y ((2 * x * y) + y0)
      set x (xtemp)
      set iteration (iteration + 1)]
  set pcolor (iteration / (maxiteration / 10)) + (color-scheme * 10)
end 

to Draw-Zoom
  setxy -500 500
  while [ycor >= -499]
    [fd 1
      Calculate-Zoom
      if not can-move? 1
      [setxy xcor - 1000 ycor - 1]]
end 

There is only one version of this model, created over 10 years ago by Apollo Albright.

Attached files

File Type Description Last updated
Mandelbrot set Generator.png preview Preview for 'Mandelbrot set Generator' over 10 years ago, by Apollo Albright Download

This model does not have any ancestors.

This model does not have any descendants.