當前位置: 首頁>>代碼示例>>Python>>正文


Python picture.Picture類代碼示例

本文整理匯總了Python中picture.Picture的典型用法代碼示例。如果您正苦於以下問題:Python Picture類的具體用法?Python Picture怎麽用?Python Picture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Picture類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

def main():
    pic = Picture("crayons.bmp")
    WIDTH = pic.getWidth()
    HEIGHT = pic.getHeight()
    print(WIDTH, HEIGHT)
    pic2 = copyImage(pic)
    input()
開發者ID:acheney,項目名稱:python-labs,代碼行數:7,代碼來源:tester.py

示例2: main

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,代碼行數:34,代碼來源:imageedit.py

示例3: main

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,代碼行數:35,代碼來源:match.py

示例4: PygameStarter

class PygameStarter(game_mouse.Game):

    def __init__(self, width, height):

        game_mouse.Game.__init__(self, "Pygame Starter",
                                 width,
                                 height,
                                 10)
        
        self.font_height = 12
        self.font = pygame.font.SysFont("Courier New", self.font_height)

        self.mPicture = Picture()
        return
        
        
    def game_logic(self, keys, newkeys, buttons, newbuttons, mouse_position):
        x = mouse_position[0]
        y = mouse_position[1]

        if pygame.K_a in newkeys:
            print "a key pressed"
        
        if 1 in newbuttons:
            print "button clicked"

        return
    
    def paint(self, surface):
        self.mPicture.draw(surface)
        return
開發者ID:joshl8n,項目名稱:school-projects,代碼行數:31,代碼來源:pygame_starter.py

示例5: flipHoriz

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,代碼行數:9,代碼來源:imageedit.py

示例6: rotate180

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,代碼行數:10,代碼來源:imageedit.py

示例7: scrollHoriz

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,代碼行數:10,代碼來源:imageedit.py

示例8: blur

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,代碼行數:10,代碼來源:imageedit.py

示例9: main

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,代碼行數:7,代碼來源:testing.py

示例10: rotate180

def rotate180(canvas):
    w = canvas.getWidth()
    h = canvas.getHeight()
    new_canvas = Picture((w,h))
    canvas.close()
    for i in range(0,w):
        for j in range(0,h):
            r = canvas.getPixelRed(w-1-i,h-1-j)            
            g = canvas.getPixelGreen(w-1-i,h-1-j)
            b = canvas.getPixelBlue(w-1-i,h-1-j)
            new_canvas.setPixelColor(i,j,r,g,b)
    return new_canvas
開發者ID:Ash927,項目名稱:python-labs,代碼行數:12,代碼來源:imageedit.py

示例11: zoom

def zoom(canvas):
    w = canvas.getWidth()
    h = canvas.getHeight()
    new_canvas = Picture((w,h))
    canvas.close()
    for i in range(0,w):
        for j in range(0,h):
            r = canvas.getPixelRed(w//4+i//2,h//4+j//2)            
            g = canvas.getPixelGreen(w//4+i//2,h//4+j//2)
            b = canvas.getPixelBlue(w//4+i//2,h//4+j//2)
            new_canvas.setPixelColor(i,j,r,g,b)
    return new_canvas
開發者ID:Ash927,項目名稱:python-labs,代碼行數:12,代碼來源:imageedit.py

示例12: scrollHorizontally

def scrollHorizontally(canvas):
    n = eval(input("How many pixels would you like to scroll? "))
    w = canvas.getWidth()
    h = canvas.getHeight()
    new_canvas = Picture((w,h))
    canvas.close()
    for i in range(0,w):
        for j in range(0,h):
            r = canvas.getPixelRed(i,j)            
            g = canvas.getPixelGreen(i,j)
            b = canvas.getPixelBlue(i,j)
            new_canvas.setPixelColor((i+n)%w,j,r,g,b)
    return new_canvas
開發者ID:Ash927,項目名稱:python-labs,代碼行數:13,代碼來源:imageedit.py

示例13: connect_picture

    def connect_picture(self, clientId):
        # 最新の絵を取得する
        picture = self.get_current_picture()
        if picture == None:
            # 絵がない場合は、新たな絵を登録する
            clientIds = []
            clientIds.append(clientId)
            picture = Picture(
                              clientIds=clientIds,
                              isCurrent=True,
                              )
        else:
            picture.clientIds.append(clientId)

        picture.put()
開發者ID:thinkAmi,項目名稱:9784798123028_GAE,代碼行數:15,代碼來源:picture_helper.py

示例14: main

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,代碼行數:15,代碼來源:sketchy.py

示例15: main

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,代碼行數:12,代碼來源:sketchy.py


注:本文中的picture.Picture類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。