python绘制草莓熊

import matplotlib.pyplot as plt
import numpy as np

# 绘制草莓熊的圆形身体
x, y = np.meshgrid(np.linspace(-1, 1, 100), np.linspace(-1, 1, 100))
circle = x**2 + y**2 < 0.8
plt.imshow(circle, cmap='gray')

# 绘制草莓熊的耳朵,由两个圆组成
ear1 = (x - 0.5)**2 + (y + 0.5)**2 < 0.3
ear2 = (x + 0.5)**2 + (y + 0.5)**2 < 0.3
ear = np.logical_or(ear1, ear2)
plt.imshow(ear, cmap='gray')

# 绘制草莓熊的眼睛,由两个圆组成
eye1 = (x - 0.3)**2 + (y + 0.2)**2 < 0.05
eye2 = (x + 0.3)**2 + (y + 0.2)**2 < 0.05
eye = np.logical_or(eye1, eye2)
plt.imshow(eye, cmap='gray')

# 绘制草莓熊的鼻子,由一个圆和一个半弧组成
nose1 = (x - 0.1)**2 + y**2 < 0.05
nose2 = y < 0 and x < 0.2 and x > -0.2
nose = np.logical_or(nose1, nose2)
plt.imshow(nose, cmap='gray')

# 绘制草莓熊的嘴巴,由一条弧组成
mouth = x**2 + (y - 0.4)**2 < 0.2
plt.imshow(mouth, cmap='gray')

# 绘制草莓熊的手臂,由两个半弧和一个短线组成
arm1 = y < -0.3 and x > 0 and (x - 0.2)**2 + (y + 0.3)**2 > 0.1
arm2 = y < -0.3 and x < 0 and (x + 0.2)**2 + (y + 0.3)**2 > 0.1
arm3 = y < -0.4 and x < 0.2 and x > -0.2
arm = np.logical_or(arm1, arm2)
arm = np.logical_or(arm, arm3)
plt.imshow(arm, cmap='gray')

# 添加草莓图案
strawberry = x**2 + (y - 0.8)**2 < 0.2
plt.imshow(strawberry, cmap='pink')

# 添加标题和显示图片
plt.title('Strawberry bear')
plt.show()

草莓熊,其身体由一个圆形组成,耳朵、眼睛、鼻子、嘴巴和手臂由圆和弧线组成,而草莓图案由一个圆组成。

  • 3
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值