pythonturtle颜色大全_python turtle 有多少可用颜色?

turtle模版中的颜色很丰富。简单来说,你想要的颜色,turtle基本都有。

使用turtle设置颜色的命令如下:

turtle.color('#FF8EFF', '#2F0000')

第一个颜色为画笔颜色,第二个颜色为填充颜色,'#FF8EFF', '#2F0000'为颜色代码。

为了有个直观的印象,下图中的所有颜色turtle都可以使用。

简单画个图,看一下颜色:

import turtle as t

def hair():

t.penup()

t.goto(-50, 150)

t.pendown()

t.fillcolor('#a2774d')

t.begin_fill()

for j in range(10):

t.setheading(60 - (j * 36))

t.circle(-50, 120)

t.end_fill()

def face():

t.penup()

t.goto(0, 100)

t.pendown()

t.fillcolor('#f2ae20')

t.begin_fill()

t.setheading(180)

t.circle(85)

t.end_fill()

#下巴

t.circle(85, 120)

t.fillcolor('white')

t.begin_fill()

t.circle(85, 120)

t.setheading(135)

t.circle(100, 95)

t.end_fill()

def ears(dir):

t.penup()

t.goto((0-dir)*30, 90)

t.setheading(90)

t.pendown()

t.fillcolor('#f2ae20')

t.begin_fill()

t.circle(dir*30)

t.end_fill()

t.penup()

t.goto((0-dir)*40, 85)

t.setheading(90)

t.pendown()

t.fillcolor('white')

t.begin_fill()

t.circle(dir*17)

t.end_fill()

def nose():

t.penup()

t.goto(20, 0)

t.setheading(90)

t.pendown()

t.fillcolor('#a2774d')

t.begin_fill()

t.circle(20)

t.end_fill()

def eye(dir): # 画耳朵,dir用来设置方向,左右耳对称

t.penup()

t.goto((0-dir)*30, 20)

t.setheading(0)

t.pendown()

t.fillcolor('black')

t.begin_fill()

t.circle(10)

t.end_fill()

def mouth(): # 画嘴巴

t.penup()

t.goto(0, 0)

t.setheading(-90)

t.pendown()

t.forward(50)

t.setheading(0)

t.circle(80, 30)

t.penup()

t.goto(0, -50)

t.setheading(180)

t.pendown()

t.circle(-80, 30)

hair()

ears(1)

ears(-1)

face()

eye(1)

eye(-1)

mouth()

nose()

t.done()

来自:星空

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值