def increaseBlue(picture): for p in getPixels(picture): newBlue = getBlue(p)*1.1 if newBlue > 255: newBlue = 255 setBlue(p,newBlue) return picture def shuffleRGB(picture): for p in getPixels(picture): r = getRed(p) g = getGreen(p) b = getBlue(p) newColor = makeColor(g, b, r) setColor(p, newColor) return picture def jellyfishOnBeach(): jelly = makePicture(getMediaPath('jellyfish-small.jpg')) beach = makePicture(getMediaPath('beach.jpg')) for x in range(360,641): for y in range(1,401): jellyPixel = getPixel(jelly,x,y) beachPixel = getPixel(beach,x,y) jellyColor = getColor(jellyPixel) setColor(beachPixel,jellyColor) return beach def drawFlag(width,height): canvas = makeEmptyPicture(width,height) stripeHeight = height/13 blueUpperRight = [0,0] blueLowerLeft = [width/2,int(stripeHeight*7)] blueWidth = blueLowerLeft[0]-blueUpperRight[0] blueHeight = blueLowerLeft[1]-blueUpperRight[1] addRectFilled(canvas, blueUpperRight[0],blueUpperRight[1], blueWidth, blueHeight, blue) stripeLeftX = blueLowerLeft[0] stripeUpperLeftY = 0 stripeWidth = width - blueLowerLeft[0] stripeUpperLeftX = stripeLeftX for i in range(7): if i%2: # 0 % 2 is zero, 1%2 is one, 2%2 is zero, etc. # this checks whether it's even or odd # so, if i%2 is zero, it's even, otherwise, it's odd # ergo, this block is used for odd values color = white else: color = red addRectFilled(canvas, stripeUpperLeftX, stripeUpperLeftY, stripeWidth, stripeHeight, color) stripeUpperLeftY += stripeHeight # lower stripes stripeUpperLeftX = 0 stripeWidth = width for i in range(6): if i%2: # red stripes color = red else: # white stripes color = white addRectFilled(canvas, stripeUpperLeftX, stripeUpperLeftY, stripeWidth, stripeHeight, color) stripeUpperLeftY += stripeHeight addRect(canvas,0,0, width,stripeUpperLeftY,black) evenStarsX,evenStarsY = 20,20 starsWidth,starsHeight = blueWidth-40,blueHeight-40 starsSize = 15 evenStarsXDelta = starsWidth/5 evenStarsYDelta = starsHeight/4 oddStarsX = evenStarsX+evenStarsXDelta/2 oddStarsY = evenStarsY+evenStarsYDelta/2 for i in range(9): if not i%2: # even stars x = evenStarsX for j in range(6): drawStar(canvas,x,evenStarsY,starsSize) x += evenStarsXDelta evenStarsY += evenStarsYDelta else: x = oddStarsX for j in range(5): drawStar(canvas,x,oddStarsY,starsSize) x += evenStarsXDelta oddStarsY += evenStarsYDelta return canvas def drawStar(picture,x,y,size): half = size/2 halfhalf = half/2 #addOval(picture, x-half,y-half,size,size,white) addLine(picture, x-half, y+half, x, y-half, white) addLine(picture, x, y-half, x+half, y+half, white) addLine(picture, x+half, y+half, x-half,y-halfhalf, white) addLine(picture, x-half, y-halfhalf, x+half, y-halfhalf, white) addLine(picture, x+half,y-halfhalf, x-half, y+half, white)