Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Limit for maximum iterations
- MAX_ITER = 256
- SYMBOLS = ".:coCO8@"
- height = input("Enter size of the fractal (height and width)\n")
- width = input()
- def c(x, y):
- x0 = (3.5 / width) * x - 2.5
- y0 = (2.0 / height) * y - 1
- xi = yi = iteration = 0
- while xi**2 + yi**2 < 4 and iteration < MAX_ITER:
- xtemp = xi**2 - yi**2 + x0
- yi = 2*xi*yi + y0
- xi = xtemp
- iteration += 1
- if (iteration == MAX_ITER):
- return " "
- return SYMBOLS[(iteration - 1) % 8]
- for y in range(height):
- print "".join([c(x, y) for x in range(width)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement