def main(): pic = Picture("crayons.bmp") WIDTH = pic.getWidth() HEIGHT = pic.getHeight() print(WIDTH, HEIGHT) pic2 = copyImage(pic) input()
def main(): canvas = Picture((512, 512)) w = canvas.getWidth() h = canvas.getHeight() canvas.setPenColor(0, 255, 0) print("Welcome to the fractal image generator.") print() print("We have 4 fractals for you to choose from:") print("1. Bubble") print("2. Carpet") print("3. Gasket") print("4. Snowflake") print() k = eval(input("Please enter the number corresponding to the image you would like to see: ")) n = eval(input("How many times would you like it to recurse? ")) if k == 1: bubble(0, 0, w, h, n, 0, canvas).display() if k == 2: carpet(0, 0, w, h, n, canvas).display() if k == 3: canvas.fillPoly((0, w // 2, w - 1), (h - 1, 0, h - 1)) canvas.setPenColor(0, 0, 0) gasket(0, 0, w, h, n, canvas).display() if k == 4: # make a canvas with width and height being a power of 3. canvas = Picture((468, 468)) canvas.setPenColor(0, 255, 0) w = canvas.getWidth() h = canvas.getHeight() canvas.setPosition(w // 6, 4 * h // 6) canvas = snowflake(n, 3 * w // 4, canvas) canvas.rotate(240) canvas = snowflake(n, 3 * w // 4, canvas) canvas.rotate(240) canvas = snowflake(n, 3 * w // 4, canvas) canvas.rotate(240) canvas.display() input("Press enter to end the program.")
def main(): name = input("Enter the filename of an image you would like to edit: ") pic = Picture(name) pic.display() WIDTH = pic.getWidth() HEIGHT = pic.getHeight() instructions() while True: options() userInput = input("Enter the number corresponding to the change you want to perform: ") if userInput == "exit": return else: userInput = eval(userInput) pic = doEdit(userInput, pic) pic.display()
pMain = path.path(path.moveto(x,y+hCornerCenter), path.lineto(x+.5,y-hCenter), path.lineto(x-.5,y-hCenter), path.closepath()) c.stroke(pMain, [deco.filled([get_color("black")])]) #draw r,g,b triangles pRed = draw_rgb(c,x,y,"red",0,r) pGreen = draw_rgb(c,x,y,"green",1,g) pBlue = draw_rgb(c,x,y,"blue",2,b) fill_intersections(c,pRed,pGreen,pBlue,r,g,b) #Main Commands c = canvas.canvas() p = Picture("whitetriangle.jpg") width, height = p.getWidth(), p.getHeight() ##for xp in range(width): ## for yp in range(height): ## rp,gp,bp = p.getPixelColor(xp,yp) ## r, g, b = floor(rp/25.6),floor(gp/25.6),floor(bp/25.6) #### print (xp,yp,r,g,b) ## ## draw_triangle(c,xp,(height-yp)*h,r,g,b) #All possible values ##count=0 ##for i in range(0,L): ## for j in range(0,L): ## for k in range(0,L):