Advertisement

turtle绘制奥运五环

阅读量:
复制代码
    # -*- coding: utf-8 -*-
    """
    Created on Fri Apr 24 17:08:31 2020
    
    @author: HONOR
    """
    
    import turtle
    color=['blue','black','red','orange','green']
    turtle.setup(1000,1000,0,0)#画布参数 1000 1000是画布像素点 0 0是小海龟起始位置
    
    '''
    也可以用pen这个中间参数来表示,这样tab键会出函数提示
    pen=turtle.Pen()
    pen.width(5)
    pen.circle(100)
    '''
    #做画图准备
    turtle.penup()#起笔 小海龟移动 但是不在画布上留下痕迹
    turtle.fd(-250)#画笔向前移动250个像素点
    turtle.pendown()#落笔 小海龟移动时会出现轨迹
    turtle.pensize(20)#规定画笔大小
    turtle.seth(-90)#让小海龟的头 向第四象限方向旋转90度
    #turtle.speed(1)#可以控制画笔速度
    
    x=0
    def circle():
    turtle.pencolor(color[x])
    turtle.circle(70,540)
    
    for i in range(5):
    if i==3:
        turtle.penup()
        turtle.right(90)
        turtle.fd(350)
        turtle.left(90)
        turtle.fd(100)
        turtle.left(90)
        turtle.right(90)
        turtle.pendown()
    circle()
    x+=1
    turtle.right(180)
    '''    
    turtle.penup()
    turtle.fd(5)
    turtle.pendown()
    turtle.circle(1000)
    turtle.penup()
    turtle.fd(100)
    turtle.pendown()
    turtle.circle(5)
    '''
    #这俩行代码可以在用鼠标点击画布一次之后  画布就会消失
    window=turtle.Screen()
    window.exitonclick()

画出五环图形 主要就是计算好小海龟旋转对的角度 与角度的偏转

一些海归库的常见函数

在这里插入图片描述

全部评论 (0)

还没有任何评论哟~