How to use Turtle to draw Doraemon and Peppa Pig in Python
1.Doraemon
"As long as you tie your wish to a bamboo pole and ask the moon goddess, your wish will come true." I like this sentence very much.
The creation of Doraemon can be traced back to a certain deadline in 1969. A kitten suddenly broke into the home of the author Fujiko F Fujio. Although the deadline was coming soon, The author still played with the kitten and scratched its lice for several hours. By the time the author realizes that there is not enough time, it is too late to complete the manuscript. At this time, the author was walking around like an ant on a hot pot, and suddenly kicked his daughter's roly-poly toy. Then the author had an idea and combined the image of the cat with the roly-poly to create Doraemon.
2.Peppa Pig
Compared with the domestic "Pleasant Goat and Big Big Wolf" and "Bear Infested", I hope that one day Pleasant Goat will be stewed by Big Big Wolf, and Bear will be raped by a bald head. Hit and sell directly to the zoo. (Hahaha...) But this idea has never been realized, and I feel a little disappointed. Let’s watch Peppa Pig:
After it was first broadcast by E1 Kids in the UK on May 31, 2004, its cartoon has been broadcast in 180 regions around the world and has been broadcast for 6 seasons;
China Central Television’s children’s channel is also popular. The minimalist animation style, humorous dialogue tone, and deeply educational storylines not only allow preschoolers to learn knowledge, but also help children grow up from an early age. Develop good living habits and experience life, and is deeply loved by children and their parents around the world.
3. Python code implementation (Doraemon)
import turtle as t t.title('哆啦A梦') # t.speed(5) t.pensize(8) t.hideturtle() t.screensize(500, 500, bg='white') """猫脸""" t.fillcolor('#00A1E8') t.begin_fill() t.circle(120) t.end_fill() t.pensize(3) t.fillcolor('white') t.begin_fill() t.circle(100) t.end_fill() t.pu() t.home() t.goto(0, 134) t.pd() t.pensize(4) t.fillcolor("#EA0014") t.begin_fill() t.circle(18) t.end_fill() t.pu() t.goto(7, 155) t.pensize(2) t.color('white', 'white') t.pd() t.begin_fill() t.circle(4) t.end_fill() t.pu() t.goto(-30, 160) t.pensize(4) t.pd() t.color('black', 'white') t.begin_fill() a = 0.4 for i in range(120): if 0 <= i < 30 or 60 <= i < 90: a = a + 0.08 t.lt(3) # 向左转3度 t.fd(a) # 向前走a的步长 else: a = a - 0.08 t.lt(3) t.fd(a) t.end_fill() t.pu() t.goto(30, 160) t.pensize(4) t.pd() t.color('black', 'white') t.begin_fill() for i in range(120): if 0 <= i < 30 or 60 <= i < 90: a = a + 0.08 t.lt(3) # 向左转3度 t.fd(a) # 向前走a的步长 else: a = a - 0.08 t.lt(3) t.fd(a) t.end_fill() t.pu() t.goto(-38, 190) t.pensize(8) t.pd() t.right(-30) t.forward(15) t.right(70) t.forward(15) t.pu() t.goto(15, 185) t.pensize(4) t.pd() t.color('black', 'black') t.begin_fill() t.circle(13) t.end_fill() t.pu() t.goto(13, 190) t.pensize(2) t.pd() t.color('white', 'white') t.begin_fill() t.circle(5) t.end_fill() t.pu() t.home() t.goto(0, 134) t.pensize(4) t.pencolor('black') t.pd() t.right(90) t.forward(40) t.pu() t.home() t.goto(0, 124) t.pensize(3) t.pencolor('black') t.pd() t.left(10) t.forward(80) t.pu() t.home() t.goto(0, 114) t.pensize(3) t.pencolor('black') t.pd() t.left(6) t.forward(80) t.pu() t.home() t.goto(0, 104) t.pensize(3) t.pencolor('black') t.pd() t.left(0) t.forward(80) """左边的胡子""" t.pu() t.home() t.goto(0, 124) t.pensize(3) t.pencolor('black') t.pd() t.left(170) t.forward(80) t.pu() t.home() t.goto(0, 114) t.pensize(3) t.pencolor('black') t.pd() t.left(174) t.forward(80) t.pu() t.home() t.goto(0, 104) t.pensize(3) t.pencolor('black') t.pd() t.left(180) t.forward(80) t.pu() t.goto(-70, 70) t.pd() t.color('black', 'red') t.pensize(6) t.seth(-60) t.begin_fill() t.circle(80, 40) t.circle(80, 80) t.end_fill() t.pu() t.home() t.goto(-80, 70) t.pd() t.forward(160) t.pu() t.home() t.goto(-50, 50) t.pd() t.pensize(1) t.fillcolor("#eb6e1a") t.seth(40) t.begin_fill() t.circle(-40, 40) t.circle(-40, 40) t.seth(40) t.circle(-40, 40) t.circle(-40, 40) t.seth(220) t.circle(-80, 40) t.circle(-80, 40) t.end_fill() # 领带 t.pu() t.goto(-70, 12) t.pensize(14) t.pencolor('red') t.pd() t.seth(-20) t.circle(200, 30) t.circle(200, 10) """铃铛""" t.pu() t.goto(0, -46) t.pd() t.pensize(3) t.color("black", '#f8d102') t.begin_fill() t.circle(25) t.end_fill() t.pu() t.goto(-5, -40) t.pd() t.pensize(2) t.color("black", '#79675d') t.begin_fill() t.circle(5) t.end_fill() t.pensize(3) t.right(115) t.forward(7) t.mainloop()
4. Python code implementation (Peppa Pig)
import turtle from turtle import * turtle.title('小猪佩奇') def nose(x,y): """画鼻子""" pensize(5) pencolor((255, 155, 192)) penup() # 将海龟移动到指定的坐标 goto(x,y) pendown() # 设置海龟的方向(0-东、90-北、180-西、270-南) setheading(-30) begin_fill() fillcolor(255, 192, 203) a = 0.4 for i in range(120): if 0 <= i < 30 or 60 <= i <90: a = a + 0.08 # 向左转3度 left(3) # 向前走 forward(a) else: a = a - 0.08 left(3) forward(a) end_fill() penup() setheading(90) forward(25) setheading(0) forward(10) pendown() """设置画笔的颜色(红, 绿, 蓝)""" pencolor(255, 155, 192) setheading(10) begin_fill() circle(5) color(160, 82, 45) end_fill() penup() setheading(0) forward(20) pendown() pencolor(255, 155, 192) setheading(10) begin_fill() circle(5) color(160, 82, 45) end_fill() def head(x, y): """画头""" color((255, 155, 192), "pink") penup() goto(x,y) setheading(0) pendown() begin_fill() setheading(180) circle(300, -30) circle(100, -60) circle(80, -100) circle(150, -20) circle(60, -95) setheading(161) circle(-300, 15) penup() goto(-100, 100) pendown() setheading(-30) a = 0.4 for i in range(60): if 0<= i < 30 or 60 <= i < 90: a = a + 0.08 lt(3) #向左转3度 fd(a) #向前走a的步长 else: a = a - 0.08 lt(3) fd(a) end_fill() def ears(x,y): """画耳朵""" color((255, 155, 192), "pink") penup() goto(x, y) pendown() begin_fill() setheading(100) circle(-50, 50) circle(-10, 120) circle(-50, 54) end_fill() penup() setheading(90) forward(-12) setheading(0) forward(30) pendown() begin_fill() setheading(90) circle(-50, 50) circle(-10, 120) circle(-50, 56) end_fill() def eyes(x,y): """画眼睛""" color((255, 155, 192), "white") penup() setheading(90) forward(-20) setheading(0) forward(-95) pendown() begin_fill() circle(15) end_fill() color("black") penup() setheading(90) forward(12) setheading(0) forward(-3) pendown() begin_fill() circle(3) end_fill() color((255, 155, 192), "white") penup() seth(90) forward(-25) seth(0) forward(40) pendown() begin_fill() circle(15) end_fill() color("black") penup() setheading(90) forward(12) setheading(0) forward(-3) pendown() begin_fill() circle(3) end_fill() def cheek(x,y): """画脸颊""" color((255, 155, 192)) penup() goto(x,y) pendown() setheading(0) begin_fill() circle(30) end_fill() def mouth(x,y): """画嘴巴""" color(239, 69, 19) penup() goto(x, y) pendown() setheading(-80) circle(30, 40) circle(40, 80) def body(x,y): '''画身体''' penup() goto(x,y) pencolor('red') fillcolor(250,106,106) pendown() begin_fill() setheading(-66) circle(-450,17) setheading(180) forward(185) setheading(85) circle(-450,17) end_fill() '''右手''' penup() goto(110,-45) pendown() pensize(8) pencolor(255, 192, 203) setheading(30) circle(-400,10) penup() goto(167,-5) pendown() setheading(-120) forward(20) left(100) forward(20) '''左手''' penup() goto(-25,-45) pendown() pencolor(255, 192, 203) setheading(150) circle(400,10) penup() goto(-78,-6) pendown() setheading(-60) forward(20) right(100) forward(20) def feet1(x,y): pensize(7) pencolor(255, 192, 203) penup() goto(x,y) setheading(-90) pendown() forward(10) penup() goto(x-12,y-10) pendown() pencolor(238,201,0) fillcolor(238,230,132) begin_fill() setheading(0) forward(24) right(90) forward(36) right(90) forward(40) circle(-10,180) forward(16) left(90) forward(12) end_fill() def feet2(x,y): pensize(7) pencolor(255, 192, 203) penup() goto(x,y) setheading(-90) pendown() forward(10) penup() goto(x-12,y-10) pendown() pencolor(238,201,0) fillcolor(238,230,132) begin_fill() setheading(0) forward(24) right(90) forward(36) right(90) forward(40) circle(-10,180) forward(16) left(90) forward(12) end_fill() def tail(x,y): pensize(8) penup() goto(x,y) pendown() pencolor(255, 192, 203) setheading(-5) circle(30,100) circle(10,180) circle(20,150) def backg(x): penup() goto(-420,x) setheading(0) fillcolor(50,205,50) begin_fill() forward(840) right(90) forward(300) right(90) forward(840) right(90) forward(300) end_fill() setheading(0) fillcolor(0,191,255) begin_fill() forward(840) left(90) forward(600) left(90) forward(840) left(90) forward(600) end_fill() def cloude1(x, y): """画云""" penup() goto(x,y) setheading(90) fillcolor(255,255,255) begin_fill() a = 0.4 for i in range(120): if 0 <= i < 30 or 60 <= i <90: a = a + 0.14 # 向左转3度 left(3) # 向前走 forward(a) else: a = a - 0.15 left(3) forward(a) end_fill() def cloude2(x, y): """画云""" penup() goto(x,y) setheading(90) fillcolor(255,255,255) begin_fill() a = 0.4 for i in range(120): if 0 <= i < 30 or 60 <= i <90: a = a + 0.15 # 向左转3度 left(3) # 向前走 forward(a) else: a = a - 0.13 left(3) forward(a) end_fill() def setting(): """设置参数""" pensize(5) # 隐藏海龟 hideturtle() colormode(255) color((255, 155, 192), "pink") setup(840, 700) speed(10) def main(): """主函数""" setting() backg(0) body(105,-20) nose(-100, 100) head(-69, 167) ears(0, 160) eyes(0, 140) cheek(80, 10) mouth(-20, 30) feet1(10,-150) feet2(90,-150) tail(130,-110) cloude1(-200,200) cloude2(300,300) done() if __name__ == '__main__': main()
The above is the detailed content of How to use Turtle to draw Doraemon and Peppa Pig in Python. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

To run Python code in Sublime Text, you need to install the Python plug-in first, then create a .py file and write the code, and finally press Ctrl B to run the code, and the output will be displayed in the console.

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

VS Code can be used to write Python and provides many features that make it an ideal tool for developing Python applications. It allows users to: install Python extensions to get functions such as code completion, syntax highlighting, and debugging. Use the debugger to track code step by step, find and fix errors. Integrate Git for version control. Use code formatting tools to maintain code consistency. Use the Linting tool to spot potential problems ahead of time.
