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教程5python 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教程5python turtle教程5

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

python turtle教程5

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

python turtle教程5

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

python turtle教程5python turtle教程5
猜你喜欢