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


Python Picture.writeFile方法代码示例

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


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

示例1: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import writeFile [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.writeFile("guss.bmp")
    input()
开发者ID:acheney,项目名称:python-labs,代码行数:12,代码来源:sketchy.py

示例2: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import writeFile [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

示例3: main

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import writeFile [as 别名]
def main():
    # Get the width for the canvas
    width = int(eval(input("How wide do you want the canvas to be? (In pixels) ")))
    height = width
    # Get the number of bricks tall the user wants the pyramid to be
    try:
        numBricks = int(eval(input("How many bricks tall do you want your pyramid to be? ")))
    except:
        print("That was a non-numeric value. You are the worst ever. Exciting.")
    # Create the canvas
    canvas = Picture((width, width))
    # Fill in the background
    canvas.setPenColor(255, 255, 255)
    canvas.drawRectFill(0, 0, width, width)
    # Calculate brick height and width
    try:
        brickHeight = int(width/numBricks)
        brickWidth = int(width/numBricks)
    except:
        print("You put in 0 bricks, so you will only get a background. AHAHAHAHAHAAHAHAHAHAHAHAHA. AHAHA. AHA. HA.")
    # Loop through each row of the pyramid
    
    rowX = 0
    rowY = 0
    
    for i in range(0, numBricks):
        # Find the y coordinate for every brick in this row
        brickY = brickHeight*(i + 1)
        # Loop through each brick in each row
        for j in range(0, numBricks - i):
            # Find the x coordinate for each brick as you go along
            canvas.setPenColor(0, 255, 255)
            canvas.drawRectFill(rowX + j*brickWidth, height - brickHeight - rowY, brickWidth, brickHeight)
            canvas.setPenColor(0, 0, 0)
            canvas.drawRect(rowX + j*brickWidth, height - brickHeight - rowY, brickWidth, brickHeight)
            
        rowX += int(brickWidth/2)
        rowY += brickHeight
    canvas.writeFile("pyramid.bmp")
    canvas.display()
开发者ID:acheney,项目名称:python-labs,代码行数:42,代码来源:pyramid.py


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