Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. from random import *
  2.  
  3. def main():
  4. pic = makeEmptyPicture(400,400)
  5. for x in range(1,5):
  6. addRandomZigZag(pic)
  7. show(pic)
  8. crayons = [ red, green, blue, yellow, cyan, magenta, gray ]
  9. colorItIn(pic, crayons)
  10. repaint(pic)
  11. mirrorPicture(pic)
  12. repaint(pic)
  13.  
  14. def addRandomZigZag(pic):
  15. w= getWidth(pic)
  16. h= getHeight(pic)
  17. x= w/2
  18. y= h/2
  19. inside= true
  20. while inside:
  21. xNew= x + choice([-20,0,20])
  22. yNew= y + choice([-20,0,20])
  23. if xNew < 0 or xNew > w-1 or yNew < 0 or yNew > h-1:
  24. inside = false
  25. else:
  26. addLine(pic, x,y, xNew, yNew)
  27. x= xNew
  28. y= yNew
  29.  
  30. def colorItIn(pic, crayons):
  31. pixels = getPixels(pic)
  32. color = getColor(x, y)
  33. for y in range(0, getHeight(pic)):
  34. crayonDown = false
  35. for x in range(getWidth(pic), 0):
  36. if color is black:
  37. crayonDown = not crayonDown
  38. if crayonDown is crayonDown:
  39. setColor(x,y, crayons)
  40. elif crayonDown is crayonDown:
  41. setColor(x,y, crayons)
  42.  
  43. def mirrorPicture(pic):
  44. width = getWidth(pic)
  45. mirrorpoint = width/2
  46. for x in range(0, mirrorpoint):
  47. for y in range(0, getHeight(pic)):
  48. pleft= getPixel(pic, x, y)
  49. pright = getPixel(pic, width-x-1, y)
  50. setColor(pright, getColor(pleft))
  51. return pic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement