Advertisement

python 利用turtle绘制奥运五环

阅读量:

奥林匹克象征(the Olympic symbol),又被通称为奥运五环标志,在《奥林匹克宪章》中确立了奥运会在全球范围内的视觉象征标识。 [1]该标志由五个相互套接的奥林匹克环从左至右排列而成:上方依次为蓝色、黑色和红色三个环;下方为黄色和绿色两个环;此外还能够以单一颜色方案表现;其整体形状是一个底端较窄的长方形。

在这里插入图片描述
复制代码
    import turtle
    
    # 设置小乌龟的速度和隐藏小乌龟
    turtle.speed(5)
    turtle.hideturtle()
    
    
    # 画一个圆环的函数
    def draw_a_circle(x, y, color, radius=70, pensize=10):
    turtle.penup()
    turtle.goto(x, y)
    turtle.pensize(pensize)
    turtle.pencolor(color)
    turtle.pendown()
    turtle.circle(radius)
    turtle.penup()
    
    
    # 定义五环的颜色和位置
    circles = [
    (-130, 75, "blue"),
    (-10, 75, "black"),
    (110, 75, "red"),
    (-60, -20, "yellow"),
    (60, -20, "green")
    ]
    
    # 画所有的圆环
    for x, y, color in circles:
    draw_a_circle(x, y, color)
    
    # 完成绘画
    turtle.done()

全部评论 (0)

还没有任何评论哟~