Python 3 generated magic Mandelbrot (the Mandelbrot) set

Recursion is a self-similar manner duplicates process. For example, when the two mirror surfaces perfectly parallel to each other, the nested image appears is a form of infinite recursion. From logic to linguistics, this term has many specific meaning. The most common application is recursion in mathematics and computer science, it refers to a method defined functions, in this method, the function is defined to be applied to its own definition. In particular, it defines an unlimited instances (function values), using a limited expression, for some examples can be cited other examples, but in this case, an infinite loop or impossible citations chain. The term is also used more generally described in terms of self-similar repetition of the process objects. (Wikipedia)

Mandelbrot Set (DS Boluo Te Man set) is a set of points in the complex plane, the French mathematician "Fractal father" Beno`t Mandelbrot named because of its exquisite incomparable image, known as "God's fingerprints."

Generating a shared below Mandelbrot set (Mandelbrot set) sample program (or a similar image!)

code show as below:

import pygame
width, height = 1300,1000
screen = pygame.display.set_mode((width, height))
xaxis = width / 2.2 + 60
yaxis = height / 2
scale = 300
maxit = 200
for ty in range(height/2+1):
    for tx in range(width):
        d = 0 + 0j
        c = complex(float(tx - xaxis) / scale, float(ty - yaxis) / scale)

        for linux in range(maxit):
            d = d*d + c
            if abs(d) > 2:
                col=(linux % 32 * 8, linux % 16 * 16, linux % 8 * 32)
                break
        else:
            col = (255, 0, 255)

        screen.set_at((tx, ty), col)
        screen.set_at((tx, height-ty), col)
    pygame.display.update()
input("Done")

Renderings:

Python 3 generated magic Mandelbrot (the Mandelbrot) set

Python 3 generated magic Mandelbrot (the Mandelbrot) set

Guess you like

Origin www.linuxidc.com/Linux/2019-12/161806.htm