Skip to content

Instantly share code, notes, and snippets.

@yitendra
Last active Oct 20, 2018
Embed
What would you like to do?
python color
im = Image.new('RGB', (255, 255))
ld = im.load()
rnd,rnd1,rnd2=random.randint(0,125),random.randint(0,125),random.randint(0,125)
rgbrnd=random.sample(range(0,3), 3)
print(rnd,rnd1,rnd2)
q,w,e=1,1,1
r = rnd
g = rnd1
b = rnd2
for x in range(im.size[0]):
if rgbrnd[0]:
r=r+q
if rgbrnd[1]:
g=g+w
if rgbrnd[2]:
b=b+e
if r==255:
q=random.randint(-2,-1)
if g==255:
w=random.randint(-2,-1)
if b==255:
e=random.randint(-2,-1)
for y in range(im.size[1]):
ld[x, y] = (r, g, b)
im
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment