Advertisement
kdall3

Mandelbrot Fractal

Sep 30th, 2022 (edited)
957
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import pygame
  2.  
  3. pygame.init()
  4.  
  5. screen_dimensions = (1920, 1080)
  6. window = pygame.display.set_mode(screen_dimensions)
  7.  
  8. pixel_array = pygame.PixelArray(window)
  9.  
  10. for x in range(len(pixel_array)):
  11.     for y in range(len(pixel_array[0])):
  12.         dx = (x-1000)/600
  13.         dy = (y-540)/600
  14.         a = dx
  15.         b = dy
  16.  
  17.         for t in range(200):
  18.             d = (a*a)-(b*b)+dx
  19.             b = 2*(a*b)+dy
  20.             a = d
  21.             H = d>200
  22.  
  23.             if H:
  24.                 pixel_array[x, y] = (abs(t-20), abs(t-50), abs(t-65))
  25.                 break
  26.  
  27. pixel_array.close()
  28.  
  29. run = True
  30. while run:
  31.     for event in pygame.event.get():
  32.         if event.type == pygame.QUIT:
  33.             run = False
  34.  
  35.     pygame.display.flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement