Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import random
- pygame.init
- def colorshift(color,rate):
- color+=random.randint(-rate,rate)
- if color>=256: color=255
- if color<=-1: color=0
- return color
- def imagegen(images, steps, width, height, startcolor, color2, watch): #color2: end color for fade: [0,red,green,blue]
- for image in range(images): # color speed for random shift: [1,speed]
- random.seed()
- if steps==0: steps=width*height
- x,y=width/2,height/2
- size=width,height
- if width==1280 and height==1024 and watch==True:
- surfer=pygame.display.set_mode(size,pygame.FULLSCREEN)
- elif watch==True:
- surfer=pygame.display.set_mode(size)
- else:
- surfer=pygame.Surface((width,height))
- surfer.fill((0,128,0))
- if watch==True: pygame.display.flip()
- red,blue,green=startcolor[0],startcolor[1],startcolor[2]
- for step in range(steps):
- if color2[0]==0:
- red=startcolor[0]+((color2[1]-startcolor[0])*step/steps)
- green=startcolor[1]+((color2[2]-startcolor[1])*step/steps)
- blue=startcolor[2]+((color2[3]-startcolor[2])*step/steps)
- if color2[0]==1:
- red,green,blue=colorshift(red,color2[1]),colorshift(green,color2[1]),colorshift(blue,color2[1])
- tangle=pygame.Rect(x,y,1,1)
- surfer.set_at((x,y),(red,green,blue))
- if watch==True: pygame.display.update(tangle)
- x,y=random.randint(x-1,x+1),random.randint(y-1,y+1)
- if x==width: x=0
- if x==-1: x=width-1
- if y==height: y=0
- if y==-1: y=height-1
- #if watch==False:
- pygame.image.save(surfer, "Images\\landsea_"+str(image)+".bmp")
- pygame.display.quit()
- imagegen(1,0,1280,1024,[0,0,255],[0,0,0,255],False)
Add Comment
Please, Sign In to add comment