Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- width = 4096
- height = 2304
- thickness = 3
- glow = 15
- iterations = 20
- depth = 5
- from sys import stdout
- from PIL import Image, ImageDraw
- from math import sin, pi, hypot, log
- #used for relative opacity later
- maxdecay = hypot(0, glow)
- image = Image.new('RGB', (width, height), (0, 0, 0, 0))
- draw = ImageDraw.Draw(image, 'RGBA')
- def drawPixel(x, y, opacityFactor):
- for x_offset in range(0-glow, glow):
- for y_offset in range(0-glow, glow):
- distance = hypot(x_offset, y_offset)
- if distance <= thickness/2:
- opacity = 255
- else:
- if distance > maxdecay:
- opacity = 0
- else:
- opacity = 255 - 255 / maxdecay * distance;
- if (opacity > 0):
- opacity = log(opacity)/2
- opacity = int(round(float(opacity) * float(opacityFactor)))
- draw.point( (x + x_offset, y + y_offset), fill=(255, 255, 255, opacity))
- for j in range(0, iterations):
- for z in range(0, depth):
- for x in range(width):
- y = int((height/2) + (height/2.2-40*j) * sin(2.0*pi*x/width))
- drawPixel(x, y, z/float(depth))
- total = float(iterations) * float(depth) * float(width)
- current = float(j)*float(width) + float(z)*float(width) + float(x)
- progress = current / total * 100.0
- stdout.write("\r%s" % round(progress, 2)+'% complete. ' + str(round(z/float(depth), 2)))
- stdout.flush()
- stdout.write("\n")
- image.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement