看图编函数练习Python半彩圆图腾

0 Comments

python半彩圆图腾

python半彩圆图腾
上面的图形不是很复杂,稍微琢磨一下应该能画出来。名字不知道取什么好,就取名为:Python半彩圆图腾吧。 以下是参考代码:

from turtle import *

def draw_13(x,y,size):
    """画 colored semicircle pattern"""
    cs = ['red','orange','yellow','green']
    size = size/2
    size2 = size/2    
    penup()
    pensize(2)
    pencolor('blue')
    goto(x,y)
    setheading(0)
    pendown()     
    for i in range(4):
        fillcolor(cs[i])
        begin_fill()
        circle(size,180)
        end_fill()
        fillcolor(cs[-i])
        begin_fill()
        circle(-size2,180)
        end_fill()
        right(90)
    pensize(1)
    penup()
    goto(x,y)
    setheading(0)           
    
speed(0)        
draw_13(0,0,150)

标签:

发表评论