python杂学之用turtle画熊二(附代码)

先放一张想要画的图

再一张 过程图

 

到这里好像还可以,还是蛮可爱

接着,加上了眼睛高光,有点可怜兮兮的味道了

 加上嘴巴以后

.......

“你看我开心吗”

import turtle as t
# turtle.pos()
# home() #以当前海龟位置为坐标原点

t.pensize(4)  # 画笔线条宽度
t.colormode(255)  # 画笔颜色模式

t.screensize(800, 6000, "#F0F0F0")  # 画布宽、高、背景颜色
t.speed(9)  # 画笔移动速度

# 变形的脑袋
t.pu()  # 提起画笔,不绘图
t.goto(0, 0)  # 移动至指定坐标
t.pd()  # 画笔移动时绘制图形
t.seth(30)  # 设置画笔角度
t.color(204, 147, 86)
t.begin_fill()
t.circle(100, 100)
t.circle(400, 20)
t.circle(100, 100)
t.circle(400, 20)
t.circle(100, 100)
t.end_fill()

# 耳朵
t.pu()
t.goto(-20, 200)
t.pd()
t.seth(30)
t.color(204, 147, 86)
t.begin_fill()
t.circle(50)
t.end_fill()

t.pu()
t.goto(-200, 150)
t.pd()
t.seth(30)
t.color(204, 147, 86)
t.begin_fill()
t.circle(50)
t.end_fill()

# 身子
t.pu()
t.goto(-180, -20)
t.pd()
t.seth(-130)
t.color(204, 147, 86)
t.begin_fill()
t.circle(500, 50)
t.seth(0)
t.fd(500)
t.seth(100)
t.circle(1000, 30)
t.end_fill()

# 右胳膊
t.pu()
t.goto(-10, 40)
t.pd()
t.color(204, 147, 86)
t.begin_fill()
t.seth(-30)
t.circle(-500, 30)
t.seth(-95)
t.circle(-300, 50)
t.end_fill()

# 胳膊细线
t.pu()
t.goto(70, -100)
t.pd()
t.color(66, 25, 5)
t.begin_fill()
t.seth(-50)
t.circle(-500, 30)
t.end_fill()

t.pu()
t.goto(-200, -100)
t.pd()
t.color(66, 25, 5)
t.begin_fill()
t.seth(240)
t.circle(500, 30)
t.end_fill()

# 白色肚子
t.pu()
t.goto(-60, -130)
t.pd()
t.seth(-130)
t.color(252, 248, 200)
t.begin_fill()
t.seth(90)
t.setheading(-90 + 270)
a = 5
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a += 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a -= 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

# 眼睛
t.pu()
t.color(5, 7, 4)
t.goto(-180, 80)
t.pd()
t.begin_fill()
t.seth(90)
t.setheading(100 + 270)
a = 0.3
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a += 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a -= 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

t.pu()
t.goto(-50, 120)
t.pd()
t.begin_fill()
t.seth(90)
t.setheading(120 + 270)
a = 0.3
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a += 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a -= 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

# 眼睛高光
t.pu()
t.color(252, 248, 200)
t.goto(-185, 115)
t.pd()
t.begin_fill()
t.seth(90)
t.circle(5)
t.end_fill()

t.pu()
t.color(252, 248, 200)
t.goto(-60, 155)
t.pd()
t.begin_fill()
t.seth(90)
t.circle(5)
t.end_fill()


# 嘴巴
t.pu()
t.goto(-230, 40)
t.pd()
t.color(168, 127, 97)
t.begin_fill()
t.seth(-15)
t.circle(200, 80)
t.seth(-80)
t.circle(-200, 30)
t.seth(230)
t.circle(-200, 50)
t.seth(150)
t.circle(-200, 28)
t.end_fill()

# 嘴巴细线
t.pu()
t.goto(-10, 90)
t.pd()
t.color(217, 157, 146)
t.seth(-120)
t.circle(-170, 70)


t.mainloop()

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
嗨!很高兴回答你关于Python的NumPy库的问题。NumPy是一个强大的科学计算库,提供了高性能的数组对象和各种功能丰富的数学函数。 首先,你可以使用以下命令安装NumPy库: ```python pip install numpy ``` 一旦安装完成,你可以在Python脚本中导入NumPy库: ```python import numpy as np ``` 现在让我们来看一些NumPy的常用功能。 1. 创建NumPy数组: - 使用`np.array()`函数从Python列表或元组创建数组。 - 使用`np.zeros()`创建一个元素全为0的数组。 - 使用`np.ones()`创建一个元素全为1的数组。 - 使用`np.random`模块生成随机数组。 2. 数组操作: - 通过索引访问和修改数组的元素。 - 使用切片操作提取子数组。 - 使用数组的形状、大小和维度等属性。 3. 数学函数: - NumPy提供了丰富的数学函数,例如平方根(`np.sqrt()`)、指数函数(`np.exp()`)、对数函数(`np.log()`)等。 - 通过在数组上应用这些函数,可以进行元素级别的数学操作。 4. 数组运算: - NumPy支持基本的数组运算,如加法、减法、乘法和除法。 - 这些运算可以在两个数组之间进行,也可以在数组和标量之间进行。 5. 线性代数: - NumPy提供了许多线性代数操作的函数,如矩阵乘法(`np.dot()`)、矩阵求逆(`np.linalg.inv()`)、特征值和特征向量(`np.linalg.eig()`)等。 这只是NumPy库的一小部分功能,但对于进行科学计算和数据分析来说非常重要。你可以参考NumPy官方文档以了解更多详细信息:https://numpy.org/doc/ 希望这些信息能帮助你开始学习NumPy库!如果还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值