Mandelbrot set (pseudocode)


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. For each pixel on the screen do:
  2. {
  3. x0 = x co-ordinate of pixel
  4. y0 = y co-ordinate of pixel
  5.  
  6. x = 0
  7. y = 0
  8.  
  9. iteration = 0
  10. max_iteration = 1000
  11.  
  12. while ( x*x y*y <= (2*2) AND iteration < max_iteration )
  13. {
  14. xtemp = x*x - y*y x0
  15. y = 2*x*y y0
  16.  
  17. x = xtemp
  18.  
  19. iteration = iteration 1
  20. }
  21.  
  22. if ( iteration == max_iteration )
  23. then
  24. color = black
  25. else
  26. color = iteration
  27.  
  28. plot(x0,y0,color)
  29. }

URL: http://en.wikipedia.org/wiki/Mandelbrot_set

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.