当前位置: 首页>>代码示例>>Python>>正文


Python Picture.display方法代码示例

本文整理汇总了Python中picture.Picture.display方法的典型用法代码示例。如果您正苦于以下问题:Python Picture.display方法的具体用法?Python Picture.display怎么用?Python Picture.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在picture.Picture的用法示例。


在下文中一共展示了Picture.display方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main():
    ifile = input("Open a file: ")
    canvas = Picture(ifile)
    canvas.display()
    print("This program performs the following operations:\n\n",
            "1. Flip Horizontally\n",
            "2. Mirror Horizontally\n",
            "3. Scroll Horizontally\n",
            "4. Make Negative\n",
            "5. Make Grayscale\n",
            "6. Cycle Color Channels\n",
            "7. Zoom\n",
            "8. Posterize\n",
            "9. Change Brightness\n",
            "10. Increase Contrast\n",
            "11. Blur\n",
            "12. Rotate 180 Degrees\n",
            "13. Tiled\n",
            "14. Deuteranopia (Red-Green Colorblindess)\n")
    whatdo = eval(input("Enter the number of the operation you'd like to perform: "))
    if whatdo == 1: canvas = flipHoriz(canvas)
    if whatdo == 2: canvas = mirrorHoriz(canvas)
    if whatdo == 3: canvas = scrollHoriz(canvas)
    if whatdo == 4: canvas = neg(canvas)
    if whatdo == 5: canvas = grayscale(canvas)
    if whatdo == 6: canvas = cycleColorChannels(canvas)
    if whatdo == 7: canvas = zoom(canvas)
    if whatdo == 8: canvas = posterize(canvas)
    if whatdo == 9: canvas = changeBright(canvas)
    if whatdo == 10: canvas = changeContrast(canvas)
    if whatdo == 11: canvas = blur(canvas)
    if whatdo == 12: canvas = rotate180(canvas)
    if whatdo == 13: canvas = tiled(canvas)
    if whatdo == 14: canvas = deuteranopia(canvas)
开发者ID:acheney,项目名称:python-labs,代码行数:36,代码来源:imageedit.py

示例2: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main():
    canvas = Picture((500, 500))
    canvas.display()
    canvas.setPenColor(200,0,0)
    canvas.drawRectFill(250,250,200,200)
    canvas.display()
    input()
开发者ID:Ash927,项目名称:python-labs,代码行数:9,代码来源:testing.py

示例3: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main() :
    CELL_SIZE, ROUNDS = 6, 500
    try:
        cells, TILESX, TILESY  = fillCells(input("Open board from file: "))
    except FileNotFoundError :
        cells = []
        TILESX, TILESY = 50, 80
        for i in range(TILESY):
            cells.append([False]*TILESX)
        cells[39][40]=1
        cells[40][39]=1
        cells[40][40]=1
        cells[41][40]=1
        cells[39][41]=1
    cells2 = []
    for i in range(TILESY):
        cells2.append([False]*TILESX)
    board = Picture(((TILESX * (CELL_SIZE + 1))+1,1+(TILESY*(CELL_SIZE + 1))))
    # "plays" the game for ROUNDS times
    for i in range(ROUNDS):
        # for each cell...
        for x in range(TILESX):
            for y in range(TILESY):
                neighbors = numNeighbors(cells,y,x,TILESX,TILESY)
                if neighbors == 0:
                    cells2[y][x] = False
                if neighbors == 1:
                    cells2[y][x] = False
                if neighbors == 3:
                    cells2[y][x] = True
                if neighbors >= 4:
                    cells2[y][x] = False
        cells,cells2 = cells2,cells
        board = drawGrid(board,TILESX,TILESY,cells,CELL_SIZE)
        board.display()
开发者ID:acheney,项目名称:python-labs,代码行数:37,代码来源:match.py

示例4: flipHoriz

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def flipHoriz(canvas):
    n = Picture((canvas.getWidth(),canvas.getHeight()))
    for x in range(canvas.getWidth()):
        for y in range(canvas.getHeight()):
            r, g, b = canvas.getPixelColor(x,y)
            n.setPixelColor(canvas.getWidth()-x-1,y,r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:11,代码来源:imageedit.py

示例5: blur

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def blur(canvas) :
    w, h = canvas.getWidth(), canvas.getHeight()
    n = Picture((w,h))
    for x in range(w):
        for y in range(h):
            r, g, b = getAdjAvg(canvas,x,y)
            n.setPixelColor(x,y,r,g,b)
    canvas.close()
    n.display()
    return canvas
开发者ID:acheney,项目名称:python-labs,代码行数:12,代码来源:imageedit.py

示例6: rotate180

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def rotate180(canvas) :
    w, h = canvas.getWidth(), canvas.getHeight()
    n = Picture((w,h))
    for x in range(w):
        for y in range(h):
            r, g, b = canvas.getPixelColor(x,y)
            n.setPixelColor(w-x-1,h-y-1,r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:12,代码来源:imageedit.py

示例7: scrollHoriz

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def scrollHoriz(canvas) :
    m = eval(input("Scroll by how many pixels: "))
    n = Picture((canvas.getWidth(),canvas.getHeight()))
    for x in range(canvas.getWidth()):
        for y in range(canvas.getHeight()):
            r, g, b = canvas.getPixelColor(x,y)
            n.setPixelColor((x+m)%canvas.getWidth(),y,r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:12,代码来源:imageedit.py

示例8: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main():
    width = eval(input("Enter a width/height of the canvas (pixels): "))
    numBricks = eval(input("Enter a number of bricks for the height of the pyramid: "))
    canvas = Picture((width, width))
    canvas.setPenColor(0, 255, 255)
    canvas.drawRectFill(0, 0, width, width)
    sideLength = width // numBricks
    for i in range(0, numBricks):
        drawRow(canvas, i * (sideLength / 2), width - 1 - sideLength * (i+1), numBricks - i, sideLength)
    canvas.display()
开发者ID:acheney,项目名称:python-labs,代码行数:12,代码来源:pyramid.py

示例9: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main():
    width = eval(input("Please enter the desired width for the canvas: "))
    n = eval(input("Please enter the desired number of blocks for bottom row of the pyramid: "))
    size=width/n
    canvas = Picture((width, width))
    canvas.setPenColor(255,0,0)
    for i in range(0,n): #loop through the rows of the pyramid
        for j in range(i,n): #loop through the bricks
            canvas.drawRectFill(i*size/2+(j-i)*size,width-size*(i+1),size-2,size-1) #draw each rectangle, stopping a pixil short to leave visible lines between each block
    canvas.display() #display the pyramid
    input("Press enter to end the program.") #leave an input so the program doesnt end before we can see the picture
开发者ID:Ash927,项目名称:python-labs,代码行数:13,代码来源:pyramid.py

示例10: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main():
    # Create the canvas and fill in the background
    canvas = Picture((WIDTH, HEIGHT))
    chooseColor(canvas)
    canvas.drawRectFill(0, 0, WIDTH, HEIGHT)
    # Create 13 objects on the canvas
    for i in range(0, 13):
        chooseColor(canvas)
        chooseShape(canvas)
        
    canvas.display()
    canvas.writeFile("mlewisno.bmp")
开发者ID:acheney,项目名称:python-labs,代码行数:14,代码来源:sketchy.py

示例11: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main():
    pic = Picture((800,800))
    pic.setPenColor(128,80,255)
    pic.drawRectFill(0,0,800,800)
    for i in range(0, NUM_BUILDINGS):
        drawBuilding(pic)
    for i in range(0, 24):
        drawSun(pic, i)
        pic.display()

    pic.writeFile("guss.bmp")
    input()
开发者ID:mayanki,项目名称:python-labs,代码行数:14,代码来源:sketchy.py

示例12: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main():
    for num in range(1,4):
        p = Picture("training_data/a" + str(num)+".png")
        c = Char_Repr(p)
        print(c.points)
        p.display()
        raw_input()
    for num in range(1,4):
        p = Picture("training_data/b" + str(num)+".png")
        c = Char_Repr(p)
        print(c.points)
        p.display()
        raw_input()
开发者ID:benjaminpstern,项目名称:optical_recognition,代码行数:15,代码来源:char_test.py

示例13: copyImage

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def copyImage(pic):
    print (WIDTH, HEIGHT)
    pic2 = Picture((WIDTH, HEIGHT))
    pic2.display()
    input()
    for y in range(0, HEIGHT):
        for x in range(0, WIDTH):
            red = pic.getPixelRed(x, y)
            green = pic.getPixelGreen(x, y)
            blue = pic.getPixelBlue(x, y)
            pic2.setPixelRed(x, y, red)
            pic2.setPixelGreen(x, y, green)
            pic2.setPixelBlue(x, y, blue)
    return pic2
开发者ID:acheney,项目名称:python-labs,代码行数:16,代码来源:tester.py

示例14: zoom

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def zoom(canvas) :
    w, h = canvas.getWidth(), canvas.getHeight()
    n = Picture((w,h))
    for x in range(w//4,w-(w//4)):
        for y in range(h//4,h-(h//4)):
            r, g, b = canvas.getPixelColor(x,y)
            c,d = x-(w//4),y-(h//4)
            n.setPixelColor(c*2,d*2,r,g,b)
            n.setPixelColor((c*2)+1,d*2,r,g,b)
            n.setPixelColor(c*2,(d*2)+1,r,g,b)
            n.setPixelColor((c*2)+1,(d*2)+1,r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:16,代码来源:imageedit.py

示例15: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import display [as 别名]
def main():
    canvas = Picture((400, 400))
    sky(canvas)
    ground(canvas)
    pipe(canvas)
    blocks(canvas)
    questionMarks(canvas)
    mario(canvas)
    sun(canvas)
    clouds(canvas)
    horizontalLines(canvas)
    verticalLines(canvas)
    canvas.display()
    canvas.writeFile("cdavies.jpg")
    input("Press enter to end the prgram.")
开发者ID:Ash927,项目名称:python-labs,代码行数:17,代码来源:sketchy.py


注:本文中的picture.Picture.display方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。