Skip to content

Instantly share code, notes, and snippets.

@srdg
Last active January 30, 2020 05:31
Show Gist options
  • Save srdg/c1c1c1ec270923ebd858e0596741f9c6 to your computer and use it in GitHub Desktop.
Save srdg/c1c1c1ec270923ebd858e0596741f9c6 to your computer and use it in GitHub Desktop.
from PIL import ImageDraw, Image
from random import randint, choices
from PIL.ImageColor import getrgb
from os import getcwd
from time import strftime
from string import ascii_letters
from pathlib import Path
Path(getcwd()+'/wallpapers').mkdir(parents=True, exist_ok=True)
def split_rectangle(draw,img):
a,b,c,d,e,f,g,h=0,0,192,0,0,108,192,108
for i in range(10):
for j in range(10):
draw.polygon([(a,b),(c,d),(e,f)],fill = getrgb('#'+''.join(choices('ABCDEF1234567890',k=6)))+(randint(0,1000),))
draw.polygon([(c,d),(e,f),(g,h)],fill = getrgb('#'+''.join(choices('ABCDEF1234567890',k=6)))+(randint(0,1000),))
a=c
c=c+192
e=a
g=g+192
a,b,c,d,e,f,g,h=0,b+108,192,d+108,0,f+108,192,h+108
img.save(getcwd()+'/wallpapers/SPR_'+''.join(choices(ascii_letters,k=6))+strftime("%H%M%S")+'.png')
def rhombus(draw,img):
a,b,c,d,e,f,g,h=0,0,192,0,0,108,192,108
for i in range(10):
for j in range(10):
draw.polygon([(a,b),(c,d),(e,f),(g,h)],fill = getrgb('#'+''.join(choices('ABCDEF1234567890',k=6)))+(randint(0,1000),))
a=c
c=c+192
e=a
g=g+192
a,b,c,d,e,f,g,h=0,b+108,192,d+108,0,f+108,192,h+108
img.save(getcwd()+'/wallpapers/RHO_'+strftime("%H%M%S")+''.join(choices(ascii_letters,k=6))+'.png')
def rectangle(draw,img):
a,b,c,d,e,f,g,h=0,0,192,0,0,108,192,108
for i in range(10):
for j in range(10):
draw.polygon([(a,b),(c,d),(e,f),(g,h)],fill = getrgb('#'+''.join(choices('ABCDEF1234567890',k=6)))+(randint(0,1000),))
a=c
c=c+192
e=a
g=g+192
a=0
b=b+108
c=192
d=b
e=a
f=f+108
g=c
h=f
img.save(getcwd()+'/wallpapers/REC_'+strftime("%H%M%S")+''.join(choices(ascii_letters,k=6))+'.png')
img = Image.new('RGBA', (1920,1080))
draw=ImageDraw.Draw(img)
rhombus(draw,img)
split_rectangle(draw,img)
rectangle(draw,img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment