本文整理汇总了Python中picture.Picture.setPosition方法的典型用法代码示例。如果您正苦于以下问题:Python Picture.setPosition方法的具体用法?Python Picture.setPosition怎么用?Python Picture.setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类picture.Picture
的用法示例。
在下文中一共展示了Picture.setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPosition [as 别名]
def main() :
print("1. Bubbles\n2. Carpet\n3. Gasket\n4. Snowflake\n\n")
choice = eval(input("Input the number of the pattern you would like:"))
size = eval(input("Please enter a size: "))
depth = eval(input("Please enter a depth: "))
if choice == 1 : #Draw Bubbles
canvas = Picture((size*4,size*4))
canvas.setPenColor(255,102,0)
canvas.drawRectFill(0,0,size*4,size*4)
canvas.setPenColor(0,0,255)
canvas = bubbles(canvas,0,0,size*4,depth)
canvas.display()
if choice == 2 : #Draw Carpet
canvas = Picture((size*3,size*3))
canvas.setPenColor(0,255,0)
canvas.drawRectFill(0,0,size*3,size*3)
canvas.setPenColor(255,0,0)
canvas = carpet(canvas,0,0,size*3,depth)
canvas.display()
if choice == 3 : #Draw Gasket
canvas = Picture((size,size))
canvas.setPenColor(0,255,255)
canvas.drawRectFill(0,0,size,size)
canvas.setPenColor(0,0,255)
canvas.fillPoly([0,size//2,size],[size,0,size])
canvas.setPenColor(0,255,255)
canvas = gasket(canvas,0,0,size,depth)
canvas.display()
if choice == 4 : #Draw Snowflake
canvas = Picture((size + (size//2),size + (size//2)))
canvas.setPenColor(80,0,80)
canvas.drawRectFill(0,0,size + (size//2),size + (size//2))
canvas.setPenColor(0,255,0)
canvas.setPosition(size + (size//4),size)
canvas.rotate(240)
canvas = snowflake(canvas,size,depth)
canvas.rotate(240)
canvas = snowflake(canvas,size,depth)
canvas.rotate(240)
canvas = snowflake(canvas,size,depth)
canvas.display()
示例2: main
# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPosition [as 别名]
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.")