3分钟,教你画三种软软萌萌的小熊猫~超详细教程,看完即可上手哦~

前言

哈喽,小可爱们,我是喜欢编程爱游戏爱生活的栗子👸同学~

当当当当:

前不久一个“爱抱大腿”的熊猫宝宝在网上成为热搜,这圆碌碌的小小团,憨厚赖皮的样子立刻圈粉无数~

是不是特别可爱啊❤️

它就是已经在地球上生存了至少800万年“活化石”——国宝大熊猫⬇️

 大熊猫的形象还衍生出了更多好玩有趣的东西:动漫、电影、甚至......

 今天栗子带大家绘制不一样的大熊猫给大家,话不多说,我们愉快的开始吧~

1)大熊猫手绘图

环境配置

Python3、 Pycharm 、Pygame。

第三方库的安装:pip  install pygame


效果展示:

 

代码演示:

import numpy as np
import tkinter.filedialog
root = tkinter.Tk().withdraw()
filename = tkinter.filedialog.askopenfilename()  # 打开选择文件对话框
try:
    depth = 30  # 0-100,越高,颜色越深
    picture_grad = np.gradient(np.asarray(Image.open(filename).convert('L')).astype('int'))  # 取图像灰度的梯度值
    grad_x, grad_y = picture_grad[0] * depth / 100., picture_grad[1] * depth / 100.  # 将获取的维度梯度值进行深度处理
    base = np.sqrt(grad_x ** 2 + grad_y ** 2 + 1.)  # 降噪基
    _x, _y, _z = grad_x / base, grad_y / base, 1. / base
    sce_z, sce_x = np.pi / 2.1, np.pi / 3  # 光源的俯视角度值和方位角度值
    # 光源对x,y,z 轴的影响
    dx, dy, dz = np.cos(sce_z) * np.cos(sce_x), np.cos(sce_z) * np.sin(sce_x), np.sin(sce_z)
    Normalized = 255 * (dx * _x + dy * _y + dz * _z).clip(0, 255)  # 光源归一化
    im = Image.fromarray(Normalized.astype('uint8'))  # 重构图像
    im.save('转换后的素描图.jpg')  # 保存转换后的图片
    im.show()  # 展示转换后的图片
except Exception:
    print('转换失败!')

2)大熊猫Turtle图

效果展示:

 

 代码展示(仅部分):

代码比较多就不全部放在上面了哈!需要的看文末或者文章汇总即可!

t.title("熊猫宝宝")
t.shape("classic")
t.pensize(3)
t.color("black")
t.fillcolor("black")
t.speed(100)
t.hideturtle()
#左耳
t.penup()
t.goto(-105,97)
t.setheading(160)
t.begin_fill()
t.pendown()
t.circle(-30,230)
t.setheading(180)
t.circle(37,90)
t.end_fill()
#右耳
t.penup()
t.goto(105,97)
t.setheading(20)
t.begin_fill()
t.pendown()
t.circle(30,230)
t.setheading(0)
t.circle(-37,90)
t.end_fill()
#头部轮廓
t.penup()
t.goto(-67,140)
t.setheading(30)
t.pendown()
t.circle(-134,60)

t.penup()
t.goto(-50,-25)
t.setheading(180)
t.pendown()
t.circle(-100,30)
t.circle(-30,90)
t.setheading(100)
t.circle(-200,20)

t.penup()
t.goto(50,-25)
t.setheading(0)
t.pendown()
t.circle(100,30)
t.circle(30,90)
t.setheading(80)
t.circle(200,20)

#两熊猫眼
#左眼
t.penup()
t.goto(-90,25)
t.setheading(-45)
t.begin_fill()
t.pendown()
#椭圆绘制技巧
a = 0.2
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.1
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.1
        t.lt(3)
        t.fd(a)
t.end_fill()

t.fillcolor("white")
t.penup()
t.goto(-53,43)
t.setheading(0)
t.begin_fill()
t.pendown()
t.circle(13,360)
t.end_fill()

t.penup()
t.pensize(4)
t.goto(-60,57)
t.setheading(30)
t.pendown()
t.circle(-12,60)
#右眼
t.penup()
t.goto(90,25)
t.setheading(45)
t.pensize(2)
t.fillcolor("black")
t.begin_fill()
t.pendown()
#椭圆绘制技巧
a = 0.2
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.1
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.1
        t.lt(3)
        t.fd(a)
t.end_fill()

t.fillcolor("white")
t.penup()
t.goto(53,43)
t.setheading(0)
t.begin_fill()
t.pendown()
t.circle(13,360)
t.end_fill()

t.penup()
t.pensize(4)
t.goto(60,57)
t.setheading(150)
t.pendown()
t.circle(12,60)

#鼻子和嘴吧
t.penup()
t.goto(-16,20)
t.setheading(-90)
t.fillcolor("black")
t.begin_fill()
t.pendown()
a = 0.2
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.03
        t.lt(3)
        t.fd(a)
    else:
        a = a - 0.03
        t.lt(3)
        t.fd(a)
t.end_fill()

t.penup()
t.goto(-24,0)
t.setheading(-60)
t.pendown()
t.circle(28,120)

#熊肢体
#左肢
t.penup()
t.goto(-65,-24)
t.setheading(-140)
t.begin_fill()
t.pendown()
t.circle(100,40)
t.setheading(180)
t.circle(30,40)
t.setheading(-40)
t.circle(40,40)
t.setheading(-150)
a = 0.5
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.05
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    elif 30 <= i < 60 or 90<=i <100:
        a=a-0.05
        t.lt(3)
        t.fd(a)
t.setheading(93)
t.circle(-150,30)
t.end_fill()

t.penup()
t.goto(-85,-115)
t.setheading(-150)
t.color("gray","gray")
t.begin_fill()
t.pendown()
a = 0.3
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.03
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.03
        t.lt(3)
        t.fd(a)
t.end_fill()
#每个脚趾绘制函数
def toe(x,y):
    t.begin_fill()
    t.goto(x,y)
    t.circle(3,360)
    t.end_fill()

t.penup()
toe(-98,-120)
toe(-96,-110)
toe(-88,-105)
toe(-80,-105)

#右肢
t.color("black")
t.penup()
t.goto(65,-24)
t.setheading(-40)
t.begin_fill()
t.pendown()
t.circle(-100,40)
t.setheading(0)
t.circle(-30,40)
t.setheading(-140)
t.circle(-40,40)
t.setheading(-30)
a = 0.5
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.05
        t.rt(3) #向左转3度
        t.fd(a) #向前走a的步长
    elif 30 <= i < 60 or 90<=i <100:
        a=a-0.05
        t.rt(3)
        t.fd(a)
t.setheading(87)
t.circle(150,30)
t.end_fill()

t.penup()
t.goto(85,-115)
t.setheading(150)
t.color("gray","gray")
t.begin_fill()
t.pendown()
a = 0.3
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.03
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.03
        t.lt(3)
        t.fd(a)
t.end_fill()

t.penup()
toe(98,-120)
toe(96,-110)
toe(88,-105)
toe(80,-105)

t.goto(-57,-140)
t.color("black")
t.setheading(-20)
t.pendown()
t.circle(165,40)

结尾

这款赏析大熊猫的文章到这里就完成了~完整的项目源码素材打包等你来领取👇


免费获取源码项目:

滴滴我即可啦!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值