import colorsys

from PIL import Image  # type: ignore






def        SCREAMING_SNAKE_CASE_      (		lowerCAmelCase_:			float			,						lowerCAmelCase_:			float			,						lowerCAmelCase_:			int  ):
      snake_case_  :      str  	=							x
      snake_case_  :      int  	=							y
      for step in range(__UpperCamelCase  ):  # noqa: B007
            snake_case_  :      Optional[Any]  	=							a * a - b * b + x
            snake_case_  :      List[Any]  	=							2 * a * b + y
            snake_case_  :      Union[str, Any]  	=							a_new

            # divergence happens for all complex number with an absolute value
            # greater than 4
            if a * a + b * b > 4:
                  break
      return step / (max_step - 1)






def        SCREAMING_SNAKE_CASE_      (		lowerCAmelCase_:			float  ):
      if distance == 1:
            return (0, 0, 0)
      else:
            return (2_5_5, 2_5_5, 2_5_5)






def        SCREAMING_SNAKE_CASE_      (		lowerCAmelCase_:			float  ):
      if distance == 1:
            return (0, 0, 0)
      else:
            return tuple(round(i * 2_5_5  ) for i in colorsys.hsv_to_rgb(__UpperCamelCase			,						1			,						1  )  )






def        SCREAMING_SNAKE_CASE_      (		lowerCAmelCase_:			int = 8_0_0			,						lowerCAmelCase_:			int = 6_0_0			,						lowerCAmelCase_:			float = -0.6			,						lowerCAmelCase_:			float = 0			,						lowerCAmelCase_:			float = 3.2			,						lowerCAmelCase_:			int = 5_0			,						lowerCAmelCase_:			bool = True			,						):
      snake_case_  :      int  	=							Image.new("RGB"			,						(image_width, image_height)  )
      snake_case_  :      Optional[int]  	=							img.load()

      # loop through the image-coordinates
      for image_x in range(__UpperCamelCase  ):
            for image_y in range(__UpperCamelCase  ):
                  # determine the figure-coordinates based on the image-coordinates
                  snake_case_  :      Optional[int]  	=							figure_width / image_width * image_height
                  snake_case_  :      Tuple  	=							figure_center_x + (image_x / image_width - 0.5) * figure_width
                  snake_case_  :      str  	=							figure_center_y + (image_y / image_height - 0.5) * figure_height

                  snake_case_  :      str  	=							get_distance(__UpperCamelCase			,						__UpperCamelCase			,						__UpperCamelCase  )

                  # color the corresponding pixel based on the selected coloring-function
                  if use_distance_color_coding:
                        snake_case_  :      Any  	=							get_color_coded_rgb(__UpperCamelCase  )
                  else:
                        snake_case_  :      Optional[Any]  	=							get_black_and_white_rgb(__UpperCamelCase  )

      return img


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     # colored version, full figure
     UpperCAmelCase					      =							get_image()

     # uncomment for colored version, different section, zoomed in
     # img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
     # figure_width = 0.8)

     # uncomment for black and white version, full figure
     # img = get_image(use_distance_color_coding = False)

     # uncomment to save the image
     # img.save("mandelbrot.png")

     img.show()







'''simple docstring'''
def 					lowerCamelCase_ ( __UpperCamelCase					:       int		)					->	bool:







     """simple docstring"""
     if num < 0:
          return False

     _A				=							num
     _A				=							0
     while num > 0:
          _A				=							rev_num * 1_0 + (num % 1_0)
          num //= 1_0

     return num_copy == rev_num


if __name__ == "__main__":
    import doctest

    doctest.testmod()





