Skip to content

Instantly share code, notes, and snippets.

@carl-mastrangelo
Created May 10, 2022 22:04
Show Gist options
  • Save carl-mastrangelo/7e73a77cbd5960f775306f1f4691f8d6 to your computer and use it in GitHub Desktop.
Save carl-mastrangelo/7e73a77cbd5960f775306f1f4691f8d6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from PIL import Image
from math import sin, cos, pi
width = 1440
height = 800
midw = width / 2
midh = height / 2
lesser = min(midw, midh)
img = Image.new("RGB", (width, height), color=0)
for x in range(width):
for y in range(height):
dist = (((x - midw)**2 + (y - midh)**2) **.5) / lesser
val = cos((2** (dist* 2)) * pi * 10)
val = round((val + 1) * 255 / 2)
img.putpixel((x, y), (val, val, val))
img.save("img.png", "PNG")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment