mandelbrot.in 994 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. {
  2. /*
  3. This is an integer ascii Mandelbrot generator
  4. */
  5. left_edge = -420;
  6. right_edge = 300;
  7. top_edge = 300;
  8. bottom_edge = -300;
  9. x_step = 7;
  10. y_step = 15;
  11. max_iter = 200;
  12. y0 = top_edge;
  13. while (y0 > bottom_edge) {
  14. x0 = left_edge;
  15. while (x0 < right_edge) {
  16. y = 0;
  17. x = 0;
  18. the_char = ' ';
  19. i = 0;
  20. while (i < max_iter) {
  21. x_x = (x * x) / 200;
  22. y_y = (y * y) / 200;
  23. if (x_x + y_y > 800 ) {
  24. the_char = '0' + i;
  25. if (i > 9) {
  26. the_char = '@';
  27. }
  28. i = max_iter;
  29. }
  30. y = x * y / 100 + y0;
  31. x = x_x - y_y + x0;
  32. i = i + 1;
  33. }
  34. putc(the_char);
  35. x0 = x0 + x_step;
  36. }
  37. putc('\n');
  38. y0 = y0 - y_step;
  39. }
  40. }