用 Python Turtle 绘制一只可爱的小狗:用代码捕捉狗狗的萌态

用 Python Turtle 绘制一只可爱的小狗:用代码捕捉狗狗的萌态

  • 前言
  • 往期绘画>>点击进所有绘画
  • 效果图
  • 代码

前言

小狗,作为人类最忠实的朋友之一,总是以它们可爱的模样和活泼的性格,赢得了无数人的喜爱。从呆萌的小狗眼神到摇晃的尾巴,每一处细节都充满了温暖和快乐。今天,我们将用 Python Turtle 模块,绘制一只可爱的小狗,捕捉它那份纯真与活力。

往期绘画>>点击进所有绘画

序号 链接
01 用 Python 与 Turtle 创作属于你的“冰墩墩”!
02 用 Python 与 Turtle 创作属于你的“雪容融”!
03 百变小樱魔法阵全解析
04 魔法少女全解析
05 重现汤姆劈树的经典瞬间
06 ️喜羊羊与灰太狼之喜羊羊绘画️
07 ️喜羊羊与灰太狼之懒羊羊绘画️
08 ️喜羊羊与灰太狼之沸羊羊翻身️
09 ️神奇宝贝️
10 ⏰Q 版蜘蛛侠:代码里的超级英雄⏰
11 ⏰经典汤姆猫:重温卡通角色的经典魅力⏰
12 ⏰经典杰瑞鼠:捕捉卡通世界中的小聪明⏰
13 ⏰罗小黑:用代码呈现可爱与奇幻的萌宠⏰
14 麻衣学姐:从代码中描绘温柔的学姐形象
15 小猪佩奇的涂鸦乐园
16 更多点击

效果图

用 Python Turtle 绘制一只可爱的小狗:用代码捕捉狗狗的萌态_第1张图片

代码

from turtle import *
import turtle as t
t.screensize(500, 500)
# 【头部轮廓】
t.pensize(5)
t.home()
t.seth(0)
t.pd()
t.color('black')
t.circle(20, 80)  # 0
t.circle(200, 30)  # 1
t.circle(30, 60)  # 2
t.circle(200, 29.5)  # 3
t.color('black')
t.circle(20, 60)  # 4
t.circle(-150, 22)  # 5
t.circle(-50, 10)  # 6
t.circle(50, 70)  # 7
# 确定鼻头大概位置
x_nose = t.xcor()
y_nose = t.ycor()
t.circle(30, 62)  # 8
t.circle(200, 15)  # 9
# 【鼻子】
t.pu()
t.goto(x_nose, y_nose + 25)
t.seth(90)
t.pd()
t.begin_fill()
t.circle(8)
t.end_fill()
# 【眼睛】
t.pu()
t.goto(x_nose + 48, y_nose + 55)
t.seth(90)
t.pd()
t.begin_fill()
t.circle(8)
t.end_fill()
# 【耳朵】
t.pu()
t.color('#444444')
t.goto(x_nose + 100, y_nose + 110)
t.seth(182)
t.pd()
t.circle(15, 45)  # 1
t.color('black')
t.circle(10, 15)  # 2
t.circle(90, 70)  # 3
t.circle(25, 110)  # 4
t.rt(4)
t.circle(90, 70)  # 5
t.circle(10, 15)  # 6
t.color('#444444')
t.circle(15, 45)  # 7
# 【身体】
t.pu()
t.color('black')
t.goto(x_nose + 90, y_nose - 30)
t.seth(-130)
t.pd()
t.circle(250, 28)  # 1
t.circle(10, 140)  # 2
t.circle(-250, 25)  # 3
t.circle(-200, 25)  # 4
t.circle(-50, 85)  # 5
t.circle(8, 145)  # 6
t.circle(90, 45)  # 7
t.circle(550, 5)  # 8
# 【尾巴】
t.seth(0)
t.circle(60, 85)  # 1
t.circle(40, 65)  # 2
t.circle(40, 60)  # 3
t.lt(150)
t.circle(-40, 90)  # 4
t.circle(-25, 100)  # 5
t.lt(5)
t.fd(20)
t.circle(10, 60)  # 6
# 【背部】
t.rt(80)
t.circle(200, 35)
# 【项圈】
t.pensize(20)
t.color('#F03C3F')
t.lt(10)
t.circle(-200, 25)  # 5
# 【爱心铃铛】
t.pu()
t.fd(18)
t.lt(90)
t.fd(18)
t.pensize(6)
t.seth(35)
t.color('#FDAF17')
t.begin_fill()
t.lt(135)
t.fd(6)
t.right(180)  # 画笔掉头
t.circle(6, -180)
t.backward(8)
t.right(90)
t.forward(6)
t.circle(-6, 180)
t.fd(15)
t.end_fill()
# 【前小腿】
t.pensize(5)
t.pu()
t.color('black')
t.goto(x_nose + 100, y_nose - 125)
t.pd()
t.seth(-50)
t.fd(25)
t.circle(10, 150)
t.fd(25)
# 【后小腿】
t.pensize(4)
t.pu()
t.goto(x_nose + 314, y_nose - 125)
t.pd()
t.seth(-95)
t.fd(25)
t.circle(-5, 150)
t.fd(2)
t.hideturtle()
t.done()

你可能感兴趣的:(Python的Turtle绘画,python,开发语言)