手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

python turtle教程5

时间:2024-10-13 19:43:52

1、这里我主要介绍一些颜薄本窭煌色控制,包括画笔颜色和填充颜色。画笔颜色控制 pencolorturtle.pencolor()#没有参数则返回当前画笔的颜色turtle.pen艘早祓胂color('#33cc8c')#输入颜色对应十六进制turtle.pencolor(0.5,0.5,0.5)#三个元素对应着r,g,b大小默认需要在0-1之间turtle.pencolor((0,1,0))#tuple的形式也行可以使用colormode(255)将0-1映射为0-255型

python turtle教程5
python turtle教程5
python turtle教程5
python turtle教程5

2、填充颜色改变 fillcolor 和 pencolor 的用法基本一致turtle.fillcolor()垆杪屑丝#没有参数则返回当前填充的颜色turtle.fillcolor('#33cc8c')#输入颜色对应十六进制turtle.fillcolor(0.5,0.5,0.5)#三个元素对应着r,g,b大小默认需要在0-1之间turtle.fillcolor((0,1,0))#tuple的形式也行

python turtle教程5
python turtle教程5
python turtle教程5
python turtle教程5

3、直接合并pencolor和fillcolor使用color函数turtle.color()#没有参数则返回当前画笔的颜色和填充的颜色用法与pencolor和fillcolor一致,只是要输入两个参数。

python turtle教程5
python turtle教程5

4、填充形状 begin_fill 告知开始 end_fill 告知结束turtle.begin_fill()将当前位置作为起点,并告知程序开始启动填充图形。turtle.end_fill()将当前位置作为重点,并告知程序关闭填充图形。当开始和结束没有形成闭合区域会默认开始和结束点连接在一起

python turtle教程5
python turtle教程5

5、判断当前是否正在填充 fillingturtle.filling()不在填充为false正在填充为True

python turtle教程5

6、重新开始作画 reset 和 clearturtle.clear()只消除作画痕迹,画布的属性还在turtle.reset() 全部重来,参数也变为默认

python turtle教程5
python turtle教程5

7、写文本text wr坡纠课柩ite()turtle.write(arg,move=False,align="left",font=("Arial",8,"normal"))arg 为要写的字符串 move 为False 则箭头不移动 为True 则移动

python turtle教程5
© 手抄报圈