当前位置: 首页>>代码示例>>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;未经允许,请勿转载。