Skip to main content
Code Review

Return to Question

replaced http://meta.codereview.stackexchange.com/ with https://codereview.meta.stackexchange.com/
Source Link

I thought I would give this months community challenge community challenge a try. This is my first time using Python. It does take quite a while to run and it's not very colourful but it works.

from PIL import Image, ImageDraw
img = Image.new("RGB", (2400, 2400), "white")
draw = ImageDraw.Draw(img)
max_count = 200
width = img.size[0]
height = img.size[1]
for row in range(height):
 for col in range(width):
 str_output = ""
 c = complex(
 (col - float(width)/2.0)*5.0/float(width),
 (row - float(height)/2.0)*5.0/float(height)
 )
 iteration = 0
 z = 0
 while abs(z) < 2 and iteration < max_count:
 z = z**2 + c
 iteration += 1
 if abs(z) < 2:
 draw.point((col, row), fill="black")
 else:
 draw.point((col, row), fill=(255 - iteration,255 - iteration,255 - iteration))
img.save('mandelbrot.png')

black and white mandelbrot set

I thought I would give this months community challenge a try. This is my first time using Python. It does take quite a while to run and it's not very colourful but it works.

from PIL import Image, ImageDraw
img = Image.new("RGB", (2400, 2400), "white")
draw = ImageDraw.Draw(img)
max_count = 200
width = img.size[0]
height = img.size[1]
for row in range(height):
 for col in range(width):
 str_output = ""
 c = complex(
 (col - float(width)/2.0)*5.0/float(width),
 (row - float(height)/2.0)*5.0/float(height)
 )
 iteration = 0
 z = 0
 while abs(z) < 2 and iteration < max_count:
 z = z**2 + c
 iteration += 1
 if abs(z) < 2:
 draw.point((col, row), fill="black")
 else:
 draw.point((col, row), fill=(255 - iteration,255 - iteration,255 - iteration))
img.save('mandelbrot.png')

black and white mandelbrot set

I thought I would give this months community challenge a try. This is my first time using Python. It does take quite a while to run and it's not very colourful but it works.

from PIL import Image, ImageDraw
img = Image.new("RGB", (2400, 2400), "white")
draw = ImageDraw.Draw(img)
max_count = 200
width = img.size[0]
height = img.size[1]
for row in range(height):
 for col in range(width):
 str_output = ""
 c = complex(
 (col - float(width)/2.0)*5.0/float(width),
 (row - float(height)/2.0)*5.0/float(height)
 )
 iteration = 0
 z = 0
 while abs(z) < 2 and iteration < max_count:
 z = z**2 + c
 iteration += 1
 if abs(z) < 2:
 draw.point((col, row), fill="black")
 else:
 draw.point((col, row), fill=(255 - iteration,255 - iteration,255 - iteration))
img.save('mandelbrot.png')

black and white mandelbrot set

edited tags; edited title
Link
SuperBiasedMan
  • 13.5k
  • 5
  • 37
  • 62

Python Mandelbrot Set Fractal

fixed link and mistake in code
Source Link

I thought I would give this months community challenge community challenge a try. This is my first time using Python. It does take quite a while to run and it's not very colourful but it works.

from PIL import Image, ImageDraw
img = Image.new("RGB", (2400, 2400), "white")
draw = ImageDraw.Draw(img)
max_count = 200
width = img.size[0]
height = img.size[1]
for row in range(height):
 for col in range(width):
 str_output = ""
 c = complex(
 (col - float(wwidth)/2.0)*5.0/float(width),
 (row - float(hheight)/2.0)*5.0/float(height)
 )
 iteration = 0
 z = 0
 while abs(z) < 2 and iteration < max_count:
 z = z**2 + c
 iteration += 1
 if abs(z) < 2:
 draw.point((col, row), fill="black")
 else:
 draw.point((col, row), fill=(255 - iteration,255 - iteration,255 - iteration))
img.save('mandelbrot.png')

black and white mandelbrot set

I thought I would give this months community challenge a try. This is my first time using Python. It does take quite a while to run and it's not very colourful but it works.

from PIL import Image, ImageDraw
img = Image.new("RGB", (2400, 2400), "white")
draw = ImageDraw.Draw(img)
max_count = 200
width = img.size[0]
height = img.size[1]
for row in range(height):
 for col in range(width):
 str_output = ""
 c = complex(
 (col - float(w)/2.0)*5.0/float(width),
 (row - float(h)/2.0)*5.0/float(height)
 )
 iteration = 0
 z = 0
 while abs(z) < 2 and iteration < max_count:
 z = z**2 + c
 iteration += 1
 if abs(z) < 2:
 draw.point((col, row), fill="black")
 else:
 draw.point((col, row), fill=(255 - iteration,255 - iteration,255 - iteration))
img.save('mandelbrot.png')

black and white mandelbrot set

I thought I would give this months community challenge a try. This is my first time using Python. It does take quite a while to run and it's not very colourful but it works.

from PIL import Image, ImageDraw
img = Image.new("RGB", (2400, 2400), "white")
draw = ImageDraw.Draw(img)
max_count = 200
width = img.size[0]
height = img.size[1]
for row in range(height):
 for col in range(width):
 str_output = ""
 c = complex(
 (col - float(width)/2.0)*5.0/float(width),
 (row - float(height)/2.0)*5.0/float(height)
 )
 iteration = 0
 z = 0
 while abs(z) < 2 and iteration < max_count:
 z = z**2 + c
 iteration += 1
 if abs(z) < 2:
 draw.point((col, row), fill="black")
 else:
 draw.point((col, row), fill=(255 - iteration,255 - iteration,255 - iteration))
img.save('mandelbrot.png')

black and white mandelbrot set

Source Link
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /