Guest User

Untitled

a guest
May 16th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. import pygame
  2. import random
  3. pygame.init
  4. def colorshift(color,rate):
  5. color+=random.randint(-rate,rate)
  6. if color>=256: color=255
  7. if color<=-1: color=0
  8. return color
  9. def imagegen(images, steps, width, height, startcolor, color2, watch): #color2: end color for fade: [0,red,green,blue]
  10. for image in range(images): # color speed for random shift: [1,speed]
  11. random.seed()
  12. if steps==0: steps=width*height
  13. x,y=width/2,height/2
  14. size=width,height
  15. if width==1280 and height==1024 and watch==True:
  16. surfer=pygame.display.set_mode(size,pygame.FULLSCREEN)
  17. elif watch==True:
  18. surfer=pygame.display.set_mode(size)
  19. else:
  20. surfer=pygame.Surface((width,height))
  21. surfer.fill((0,128,0))
  22. if watch==True: pygame.display.flip()
  23. red,blue,green=startcolor[0],startcolor[1],startcolor[2]
  24. for step in range(steps):
  25. if color2[0]==0:
  26. red=startcolor[0]+((color2[1]-startcolor[0])*step/steps)
  27. green=startcolor[1]+((color2[2]-startcolor[1])*step/steps)
  28. blue=startcolor[2]+((color2[3]-startcolor[2])*step/steps)
  29. if color2[0]==1:
  30. red,green,blue=colorshift(red,color2[1]),colorshift(green,color2[1]),colorshift(blue,color2[1])
  31. tangle=pygame.Rect(x,y,1,1)
  32. surfer.set_at((x,y),(red,green,blue))
  33. if watch==True: pygame.display.update(tangle)
  34. x,y=random.randint(x-1,x+1),random.randint(y-1,y+1)
  35. if x==width: x=0
  36. if x==-1: x=width-1
  37. if y==height: y=0
  38. if y==-1: y=height-1
  39. #if watch==False:
  40. pygame.image.save(surfer, "Images\\landsea_"+str(image)+".bmp")
  41. pygame.display.quit()
  42. imagegen(1,0,1280,1024,[0,0,255],[0,0,0,255],False)
Add Comment
Please, Sign In to add comment