Last active
September 23, 2022 23:43
-
-
Save jul/200d3a5895a437e20df6 to your computer and use it in GitHub Desktop.
We don't need an OOP class called point or rectangle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageDraw | |
from cmath import pi as PI, e as E | |
I = complex("j") | |
to_x_y = lambda cpl : (cpl.real, cpl.imag) | |
im = Image.new("RGB", (890, 890), "white") | |
draw = ImageDraw.Draw(im) | |
rotation = E**(I*PI/3) | |
homothetia = min( im.size[0], im.size[1]) | |
# to bored to be smart, random guessing | |
trans = homothetia/2 | |
homothetia /= 2.5 | |
# lazyness off | |
polygone = ( complex(0,0), complex(0,1.5), complex(1,1.5), complex(1,0), complex(0,0) ) | |
bigger = list(map(lambda x: x * homothetia + trans/2 , polygone )) | |
bigger_rotated = list(map(rotation.__mul__, bigger )) | |
#draw.line(list(map(to_x_y, bigger)),"blue",4) | |
#draw.line(list(map(to_x_y, bigger_rotated)),"green",5) | |
draw.line(list( | |
map(to_x_y, | |
map( | |
(trans*complex(1,1)).__add__, | |
map( | |
(complex(homothetia/2)*E**(I*PI/2)).__mul__, | |
polygone)))),"blue",5) | |
for i in range(0,30): | |
rot = E**(I*i*PI/11) | |
tr = trans*complex(.5,.5)* .1 | |
draw.line(list( | |
map(to_x_y, | |
map(lambda p: (p* homothetia/30 * i* rot)+tr*i, | |
polygone))), | |
width=2, | |
fill= (255,i*5,255-5*i,255-4*i) | |
) | |
im.save("this.png", "PNG") |
Author
jul
commented
Sep 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment