Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- def main():
- pic = makeEmptyPicture(400,400)
- for x in range(1,5):
- addRandomZigZag(pic)
- show(pic)
- crayons = [ red, green, blue, yellow, cyan, magenta, gray ]
- colorItIn(pic, crayons)
- repaint(pic)
- mirrorPicture(pic)
- repaint(pic)
- def addRandomZigZag(pic):
- w= getWidth(pic)
- h= getHeight(pic)
- x= w/2
- y= h/2
- inside= true
- while inside:
- xNew= x + choice([-20,0,20])
- yNew= y + choice([-20,0,20])
- if xNew < 0 or xNew > w-1 or yNew < 0 or yNew > h-1:
- inside = false
- else:
- addLine(pic, x,y, xNew, yNew)
- x= xNew
- y= yNew
- def colorItIn(pic, crayons):
- pixels = getPixels(pic)
- color = getColor(x, y)
- for y in range(0, getHeight(pic)):
- crayonDown = false
- for x in range(getWidth(pic), 0):
- if color is black:
- crayonDown = not crayonDown
- if crayonDown is crayonDown:
- setColor(x,y, crayons)
- elif crayonDown is crayonDown:
- setColor(x,y, crayons)
- def mirrorPicture(pic):
- width = getWidth(pic)
- mirrorpoint = width/2
- for x in range(0, mirrorpoint):
- for y in range(0, getHeight(pic)):
- pleft= getPixel(pic, x, y)
- pright = getPixel(pic, width-x-1, y)
- setColor(pright, getColor(pleft))
- return pic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement