猫史档案馆


画圆函数,超详细注释讲解!

用户:狂妄的咪噜UIKe狂妄的咪噜UIKe查看:0 回复:0 评论:0 创建时间:2023-06-28T21:37:11


from turtle import *

def draw_circle(size=1, x=0, y=0, r=1, c='black', v=0, fillcolour='white'):
    # size参数为画笔粗细,参数x和y为坐标,参数r为圆的半径,参数c为画笔颜色,参数v为速度,参数fillcolour为填充颜色。
    # 以下为主程序
    print('Welcome to use draw_circle function!')
    # 设置画笔粗细
    pensize(size)
    # 设置画笔颜色
    color(c)
    # 设置填充颜色
    fillcolor(fillcolour)
    # 设置绘画速度
    speed(v)
    # 移动到x, y坐标
    penup()
    goto(x, y)
    # 开始填充
    begin_fill()
    pendown()
    # 画圆
    circle(r)
    end_fill()
    done()

# 调用
draw_circle(3, 0, 1, 100, 'red', 0, 'red')


回复

上一页1 页 / 共 0下一页