Pikachu python turtle turtle drawing (power ball version) with source code

Pikachu python turtle turtle drawing (power ball version) with source code

Contents of this article:

1. Pikachu python turtle finished product renderings

2. Introduction to the background of Pikachu

3. Character image of Pikachuka

4. May you have a Pikachu

5. Main methods of turtle drawing in Python

(1) The main steps of turtle drawing

(2) The coordinate system of turtle drawing

(3) Some suggestions for turtle drawing

6. Common commands for turtle drawing

1. Initialization

2. Brush properties

3. Brush movement commands

4. Brush color control commands

5. Global control commands

7. My Pikachu python turtle turtle drawing source code


Foreword:

    Some time ago, the article [ Strawberry Bear Python Turtle Drawing Code ] made me feel a bit gloomy. This version of Strawberry Bear was drawn at the request of a netizen. At that time, I just wanted to find a place to put the code for him, but I didn’t expect the number of visits. There will be so much volume. The strawberry bears I drew are everywhere on Douyin.com and other sites. Even in CSDN, a few people stole my code (they deleted the author's copyright information) and regarded it as their own original work, and they were all listed on the CSDN homepage. Hot recommendations. . .

    What's more, someone actually used my Strawberry Bear code to sell it for money! ! ! Please remember, do not download and purchase this code (including executable exe files, be careful if the code is tampered with viruses) 

    My code is the complete source code. If you copy the code from my blog and run it on your local machine, you will see the same running effect as on my blog (as long as my network is not fully h). I'm happy to share. I don't need you to follow any account, I don't force anyone to become my fan, and I don't need you to purchase the source code in any form. As long as you use it for personal study, or through my code, I can bring it to you. My friends are happy and I am willing to do my part to make it happen.

    Also, please respect the author’s originality and please indicate the source when reprinting. Please retain the author's copyright information in the code. These will not affect the code display effect.

1. Pikachu python turtle finished product renderings

  When you know too much, when you are awake alone, when you are weak and kind and cannot escape something unspeakable. . . When you are alone and helpless facing a powerful enemy, who will you think of? Who will be that trustworthy comrade? Maybe the elf Pikachu will be one of them. Pikachu always keeps himself happy and brings joy to others. It will also have its moments of depression, but it will not let this bring it down.
  It is not powerful, but even if it fails, the little one will stand up bravely again and protect its friends. When someone is sad, it will be there to warm and encourage. Pikachu makes you believe that it loves you back.

  Although there is no real elf Pikachu in the real world, we can draw one and its cute appearance will warm everyone. Wake up in adversity: May you all have a Pikachu that will love you forever!

  This time I used python turtle to draw Pikachu, the effect is as follows:

  The effect without a basemap is as follows:


    I will continue to use python turtle to draw a series of Pikachu animations. If you like Pikachu, you can pay more attention to this column.

    Please respect the author's difficulty in original creation, and please indicate the source when reprinting. Please retain the author's copyright information in the code. These will not affect the code display effect.

2. Introduction to the background of Pikachu

  Pikachu is a common cartoon character in life. If you have never played games or watched anime, you probably know its existence.

  In 1996, the game "Pokémon Red/Green" was first released in Japan. Players captured and trained Pokémon in the virtual world, and continued to fight and challenge with them. The most popular among all the Pokémon is Pikachu. Pikachu has become the protagonist of the Pokémon world, exploring the world with the protagonist Xiaozhi. (The Pikachu profile picture comes from the Internet, and the copyright belongs to the original author and the copyright company. It is only used to introduce the image of the character before drawing)

Chinese name pikachu
Foreign name Pikachu
Alias Pikachu, Pikachu, Pikachao
height 0.4 m
weight 6 kg
Attributes Electric rat Pokémon
Characteristics static electricity. Hidden Trait: Lightning Rod
designer Atsuko Nishida (Pikachu); James Turner (Giant Pikachu)

3. Character image of Pikachuka

  In Pikachu, pika is the sound of electric sparks, and chu is the onomatopoeia of the sound of mouse. When the illustrator Atsuko Nishida created it, she used the squirrel as the prototype. Pikachu drew a round face based on the way a squirrel looks when it is hoarding food - "When a hamster hoards food, its entire body will become round, but in a squirrel, only its cheeks will become round."


  Pikachu is good at electric discharge. It is an electric mouse with yellow fur all over its body. There are two brown stripes on its back. Its tail is like a jagged lightning bolt. There is also a piece of brown fur where it connects to the body. It has a small mouth and black eyes, red electric pouches on its cheeks, and long ears with black tips. Its front paws are short and thick, with five toes, and its back paws have only three toes. The more powerful the Pikachu can create the electric current, the softer and more stretchable the sacs on its cheeks will be. Because the pockets on its cheeks store electrical energy, it feels tingling when touched. When it runs, it runs quickly on all four legs, but more often it stands and walks on its two hind feet.
  Starting in Generation IV, Pikachu began to have gender differences, with male Pikachu having a flat tail and female Pikachu having a heart-shaped tail.

  It recharges itself while sleeping and discharges when it encounters danger. It will also raise its tail to sense whether the surrounding is safe. Pikachu is shy and introverted, and will be shocked if you touch it without permission. Pikachu likes ketchup, apples and berries, and he will definitely try other new foods when he encounters them.

4. May you have a Pikachu

  Among all the elves, Pikachu is not the most powerful one. Pikachu always keeps himself happy and brings joy to others. It will also have its moments of depression, but it will not let this bring it down.
  It is not absolutely powerful and has many weaknesses. But even if it fails in the battle, the little it will stand up bravely again and protect its friends.
  Just "Go, Pikachu!" is enough to make you trust it.

  When someone is sad, it will be there to warm and encourage. "The reason why I love Pikachu is because Pikachu has many moments that make you believe that it loves you too."

  The strong and beautiful friendship between Pikachu and Ash is another major draw for viewers. They are good friends who play together in childish ways. We will also give each other a big hug when needed. Together, two people can bravely face any crisis on the adventure journey.

5. Main methods of turtle drawing in Python

  Turtle drawing (turtle library) is an internal module of Python. You can import the turtle library before use.

  Turtles have several key properties: orientation, position, and brush properties

(1) The main steps of turtle drawing

  Usually when we draw

  The first step is to import the turtle library and some libraries that may be used when drawing, such as the random function library random, numpy library, etc. The specific situation depends on the actual situation.

  Instructions:

  import turtle

  import random

  

  The second step is to use setup() to set the canvas size.

  Canvas:

  The canvas is the area we use for drawing, we can set its size and initial position

  Set canvas size:

  1. turtle.screensize(canvwidth=None, canvheight=None, bg=None)

  The parameters are the width (unit pixel), height, and background color of the canvas.

  turtle.screensize() default size (400, 300)

  For example: turtle.screensize(800, 600, “black”)

  2. turtle.setup(width=numeric value, height=numeric value, startx=None, starty=None)

  setup() sets the form size and position.

  parameter:

  width, height: when it is an integer, it represents pixels;

  width, height: when it is a decimal, it represents the proportion of the computer screen occupied

  turtle.setup(width=0.5, height=0.85, startx=None, starty=None)

  turtle.setup(width=0.6, height=0.6)

  (startx, starty): This coordinate represents the position of the upper left corner of the rectangular window. If it is empty, the window is located in the center of the screen.

  如:turtle.setup(width=800, height=800, startx=100, starty=100)

  Step 3: Set up the brush

  Use Pen() to set the turtle drawing object, that is, the brush: turtle.Pen()

  t = turtle.Pen()

  Use t instead of turtle.Pen(). A once-and-for-all approach that simplifies entering code.

(2) The coordinate system of turtle drawing

  After the code is executed, the canvas is created, and the turtle can be seen in the middle of the screen (arrow)

  In turtle drawing, the starting point of the turtle is (0,0) in the center of the canvas, the unit of movement is pixel, and the turtle's head is in the x-axis direction, which is 0 degrees.

    In turtle drawing, the position and direction are used to describe the status of the turtle (brush).

  Imagine that there is a robot turtle in the drawing area, and its starting position is at the (0, 0) point on the xy plane. Execute import turtle first, and then execute turtle.forward(15). It will advance 15 pixels (on the screen) in the positive direction of the x-axis it is facing, and draw a line segment as it moves. Execute turtle.right(25) again, and it will turn 25 degrees to the right.

  Two words are used to describe the turtle: coordinate origin (position), facing the positive x-axis (direction),

  During the drawing process, if the coordinates and angles are not explicitly specified, then all angles and positions at this time are relative (relative to the current turtle's position and angle) .

When drawing mooncakes, circles are often used: turtle.circle(radius, extent=None, steps=None)

parameter:

  • radius – a numeric value

  • extent -- a number (or None)

  • steps -- an integer (or None)

  Draws a circle with radius specified by radius.

  The center of the circle is radius units to the left of the turtle;

  extent is an included angle, used to determine the part of the circle to be drawn. If extent* is not specified, the entire circle is drawn. If *extent is not a complete circle, an arc is drawn with the current pen position as one endpoint. If radius is positive, the arc is drawn counterclockwise, otherwise clockwise.

  Eventually the turtle's orientation will change based on the extent value.

  A circle is actually approximately represented by its inscribed regular polygon, with the number of sides specified by steps.

  If the number of sides is not specified it will be determined automatically. This method can also be used to draw regular polygons.

  Draw a circle with a radius of 100, circle(100). Note that the center of the circle is not at the origin after drawing.

(3) Some suggestions for turtle drawing

      a. Using Turtle Drawing, you can write programs that repeatedly perform simple actions to draw fine and complex shapes.

from turtle import *

speed(0)

color('blue', '#87CEFA')

begin_fill()

while True:

    forward(200)

    left(170)

    if abs(pos()) < 1:

        break

end_fill()

Arrange text in a circle:

import turtle as t

text="Wish you all a happy Mid-Autumn Festival"

for i in text:

    t.write(i,align="center",font=("黑体",20,"normal"))

    t.right(360/len(text))

    t.penup()   

    t.forward(40)

t.hideturtle()

t.done()

  b. Hide the brush; set the speed to draw faster;

  c. For the color code of turtle drawing, please refer to the link below.

Color comparison table series (1~5) 300 colors (hexadecimal, RGB, CMYK, HSV, Chinese and English names)

    Pick out the color you like and copy the corresponding color code value into the turtle color settings.

6. Common commands for turtle drawing

1. Initialization

code command

effect

import turtle

导入海龟库

t = turtle.Pen()

从工具箱子获取海龟画笔

turtle.setup()

画布设置(尺寸,距离)

turtle.bgcolor("black")

画布背景色(例如黑色)

turtle.title(title标题)    设置画布标题

screensize( )  

设置画布窗口的宽度、高度和背昱颜色

2、画笔属性

代码命令

作 用

turtle.pensize(width数字值)

画笔粗细,设置画笔线条的粗细为指定大小

turtle.color('画笔颜色')

画笔颜色   字符串"green", "red" 或者 RGB 3元组

turtle.speed(0)

设置画笔移动速度

画笔绘制的速度范围[0,10]整数,数字越大画笔速度越慢。值1~9,0最快t.speed(0)

turtle.hideturtle()

隐藏海龟图标(隐藏画笔箭头)

turtle.showturtle()

显示海龟图标(显示画笔箭头)

3、画笔运动命令

代码命令

作 用

turtle.forward()

fd(distance)         

向前移动,沿着当前方向前进指定距离

bk(distance)

向后移动,沿着当前相反方向后退指定距离

turtle.right(旋转角度)

画笔右转,turtle. right (90)海龟方向向右转90°

turtle.left(旋转角度)

画笔左转,turtle.left(90)海龟方向向左转90°

turtle.penup()

提笔,抬起画笔

turtle.pendown()

落笔,落下画笔

turtle.goto(x,y横,纵)

控制画笔移动到指定位置,海龟移动到(x,y)位置

turtle.setx(x)

海龟的x坐标移动到指定位置,纵坐标不变

turtle.sety(y)

海龟的y坐标移动到指定位置,横坐标不变

turtle.circle(指定半径, 弧度)

画圆,绘制一个指定半径和角度e的圆或弧线

turtle.dot(半径,color)

画一个圆点(实心)绘制一个指定半径和颜色的圆点

turtle.setheading(angle指向角度)

turtle.seth(angle)

设置当前朝向为angle角度。画笔的指向,右是0,逆时针0-360递增

turtle.home()

设置当前画笔位置为原点,朝向东(默认值)

4、 画笔颜色控制命令

代码命令

作 用

turtle.fillcolor('颜色')

设置 填充颜色

turtle.color(color1, color2)

设置 画笔颜色为color1,填充颜色为color2

可以使用颜色名称或十六进制RGB代码

turtle.begin_fill()

开始填充颜色

turtle.end_fill()

填充完成,结束填充

turtle. pencolor(‘颜色’)

设置画笔颜色

turtle. filling()

返回填充的状态,True为填充。False为未填充

5、全局控制命令

代码命令

作 用

turtle.clear()

清空turtle窗口,但是turtle的位置和状态不会改变(当前窗口清空,当前画笔位置不改变)

turtle.reset()

清空turtle窗口,重置turtle状态为起始状态(当前窗口清空,画笔位置等状态为初始时的默认值)

turtle.undo()

撤销上一个turtle动作(撤销画笔的最后一步动作)

turtle.isvisible()

返回当前turtle是否可见

turtle.done()

关闭画笔,结束绘制,但画面保留

              

代码命令

作 用

t.write("文本" ,align="center",font=("黑体",20,"normal"))

写文本,可指定显示字体,字体大小等align(可选):left,right,center;font(可选):字体名称,字体大小,字体类型(normal,bold,italic)

七、我的皮卡丘python turtle海龟绘图源代码

#-*- coding: UTF-8 -*-
import turtle as t
 
"""
=================================================
@Project ->Adversity Awake 皮卡丘系列
@类别     : 皮卡丘->皮卡丘之1
@Author  : 逆境清醒
@Date    : 2022/10/26 23:02
@Desc    :https://blog.csdn.net/weixin_69553582
=================================================
"""
# 设置背景颜色,窗口位置以及大小
 
t.colormode(255)# 颜色模式
t.speed(0)
t.screensize(800,800,"white")#画布大小背景颜色
t.setup(width=800, height=800,startx=None, starty=None)#绘图窗口的大小和起始坐标
#t.bgpic("di_2_800.gif")
t.title("逆境清醒皮卡丘!")#设置绘图窗口的标题
t.resizemode('noresize')  #大小调整模式:auto,user,noresize
t.tracer(1)   
t.hideturtle()

def mlingpen(x, y):
    t.penup()
    t.goto(x, y)
    t.pendown()

def mlingpkqface(x,y):
    mlingpen(x, y)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.begin_fill()
    t.seth(40)
    t.circle(100, 30)
    t.circle(40, 60)
    t.right(30)
    t.circle(160, 20)
    t.seth(-20)
    t.circle(300, 30)
    t.circle(30, 50)
    t.left(85)
    t.circle(300,85)
    t.left(1)
    t.circle(300,35)
    t.circle(30, 40)
    t.seth(40)
    t.circle(300,32)
    t.right(150)
    t.circle(100, 30)
    t.circle(30, 60)
    t.left(180)
    t.circle(100, 60)
    t.right(30)
    t.circle(100, 60)
    t.circle(70, 120)
    t.circle(-120, 80)
    t.circle(35,140)
    t.right(60)
    t.circle(300,23)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.circle(30,23)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.circle(90,80)
    t.right(170)
    t.circle(70,65)
    t.right(20)
    t.circle(-150,20)
    t.circle(20,90)
    t.right(200)
    t.circle(50,50)
    t.goto(x, y)
    t.end_fill()
    t.penup()
    t.goto(-72, -25)
    t.pendown()
    t.pencolor("#923E24")
    t.fillcolor("#923E24")
    t.begin_fill()
    t.seth(-6)
    t.circle(120, 30)
    t.right(160)
    t.circle(-50, 65)
    t.end_fill()
    mlingpen(209.21,135.02)
    t.pensize(3)
    t.pencolor("#000000")
    t.fillcolor('#000000')
    t.seth(145)
    t.begin_fill()
    t.circle(300,12)
    t.left(50)
    t.circle(60,59)
    t.left(88)
    t.circle(190,30)
    t.end_fill()
    mlingpen(-253.14,-105.48)
    t.pensize(3)
    t.pencolor("#000000")
    t.fillcolor('#000000')
    t.seth(40)
    t.begin_fill()
    t.circle(300,12)
    t.left(50)
    t.circle(60,57)
    t.left(88)
    t.circle(190,30)
    t.end_fill()

def mlingpkqyingyinying():
    t.penup()
    t.seth(0)
    t.pensize(1)
    t.pencolor("#DDA120")
    t.fillcolor('#DDA120')
    t.begin_fill()
    t.left(220)
    mlingpen(-179,-90)
    t.circle(97, 60)
    t.circle(69, 122)
    t.circle(-120, 80)
    t.circle(33,135)
    t.left(90)
    t.circle(-25,150)
    t.left(175)
    t.circle(-60,140)
    t.left(175)
    t.circle(-60,100)
    t.right(5)
    t.circle(85,60)
    t.goto(-179,-90)
    t.end_fill()
    t.penup()
    t.penup()
    t.seth(0)
    mlingpen(115.87,-170.16)
    t.pencolor("#eca9a9")
    t.fillcolor('#eca9a9')
    t.begin_fill()
    t.left(45)
    t.circle(300,20)
    t.circle(8,155)
    t.left(3)
    t.circle(300,20)
    t.circle(9,155)
    t.goto(115.87,-170.16)
    t.end_fill()
    t.penup()


def mlingpkqjiao():
    mlingpen(-215,-160)
    t.pensize(3)
    t.pencolor("#FBD624")
    t.fillcolor('#FBD624')
    t.begin_fill()
    t.seth(-30)
    t.circle(30,70)
    t.left(20)
    t.circle(-50,150)
    t.circle(10,160)
    t.circle(80,80)
    t.left(5)
    t.circle(75,110)
    t.goto(-210,-160)
    t.penup()
    t.end_fill()
    mlingpen(-149,-191)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.begin_fill()
    t.seth(0)
    t.left(40)
    t.circle(148,55)
    t.right(38)
    t.fd(20)
    t.left(128)
    t.fd(15)
    t.right(88)
    t.fd(15)
    t.left(128)
    t.fd(15)
    t.right(88)
    t.fd(15)
    t.left(128)
    t.fd(15)
    t.right(45)
    t.circle(130,60)
    t.circle(23,75)
    t.end_fill()
    mlingpen(-149,-180)
    t.pensize(3)
    t.pencolor("#eca9a9")
    t.fillcolor('#eca9a9')
    t.begin_fill()
    t.seth(0)
    t.left(45)
    t.circle(148,45)
    t.left(45)
    t.circle(15,110)
    t.right(18)
    t.circle(130,40)
    t.circle(17,100)
    t.end_fill()


def mlingpkqcap():
    mlingpen(-210,95)
    t.pensize(4)
    t.pencolor("#000000")
    t.fillcolor('#CD0000')
    t.begin_fill()
    t.seth(290)
    t.circle(45,80)
    t.circle(345,30)
    t.circle(45,90)
    t.left(2)
    t.fd(120)
    t.left(45)
    t.circle(200,60)
    t.goto(-210,95)
    t.end_fill()
    t.left(175)
    t.circle(-290,50)
    t.pencolor("#000000")
    t.pensize(3)
    t.pencolor("#000000")
    t.fillcolor('#ffffff')
    mlingpen(-160,272)
    t.begin_fill()
    t.goto(-80,260)
    t.goto(-45,200)
    t.left(186)
    t.circle(230,41)
    t.goto(-210,200)
    t.goto(-180,270)
    t.goto(-160,272)
    t.end_fill()
    mlingpen(-175,265)
    t.seth(0)
    t.begin_fill()
    t.circle(13)
    t.end_fill()
    t.penup()
    mlingpen(-125,222)
    t.pensize(7)
    t.pencolor("#6ba65a")
    t.goto(-140,225)
    t.pensize(9)
    t.goto(-155,170)
    t.left(45)
    t.circle(-130,30)
    t.pensize(3)
    mlingpen(-205,96)
    t.pensize(3)
    t.pencolor("#ffffff")
    t.seth(286)
    t.circle(39,74)
    t.left(9)
    t.circle(331,32)
    t.circle(45,80)
    t.pensize(3)


def mlingpkqeye():
    t.color("#000000","#702c00")
    mlingpen(-110, 24)
    t.begin_fill()
    t.seth(0)
    t.circle(24)
    t.end_fill()
    mlingpen(-110,31)
    t.color("black","black")
    t.begin_fill()
    t.circle(20)
    t.end_fill()
    t.color("white", "white")
    mlingpen(-105, 53)
    t.begin_fill()
    t.circle(8)
    t.end_fill()
    t.color("#000000","#702c00")
    mlingpen(0,62)
    t.begin_fill()
    t.seth(0)
    t.circle(24)
    t.end_fill()
    mlingpen(2,70)
    t.color("black","black")
    t.begin_fill()
    t.circle(20)
    t.end_fill()
    mlingpen(5,92)
    t.color("white", "white")
    t.begin_fill()
    t.circle(8)
    t.penup()
    t.end_fill()
    t.hideturtle()


def mlingpkqcheek1():
    t.color("#9E4406", "#FE2C21")
    t.penup()
    t.goto(-130, -50)
    t.pendown()
    t.begin_fill()
    t.setheading(0)
    t.circle(27)
    t.end_fill()
    t.color("#9E4406", "#FE2C21")
    t.penup()
    mlingpen(53, -20)
    t.pendown()
    t.begin_fill()
    t.setheading(0)
    t.circle(27)
    t.end_fill()

def mlingweiba(x,y):
    mlingpen(x, y)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#CD853F')
    t.begin_fill()
    t.seth(40)
    t.fd(200)
    t.seth(-80)
    t.fd(150)
    t.seth(210)
    t.fd(150)
    t.left(90)
    t.fd(100)
    t.right(95)
    t.fd(100)
    t.left(110)
    t.fd(70)
    t.right(110)
    t.fd(80)
    t.left(110)
    t.fd(30)
    t.right(110)
    t.fd(32)
    t.right(106)
    t.circle(100, 25)
    t.right(15)
    t.circle(-300, 2)
    t.seth(30)
    t.fd(40)
    t.left(100)
    t.fd(70)
    t.right(100)
    t.fd(80)
    t.left(100)
    t.fd(46)
    t.seth(66)
    t.circle(200, 38)
    t.right(10)
    t.fd(10)
    t.end_fill()
    mlingpen(202,250)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.begin_fill()
    t.seth(220)
    t.fd(120)
    t.circle(75, 120)
    t.left(50)
    t.fd(110)
    t.end_fill()


def mlingpkqcheek2(x, y, fx):
    mlingpen(x, y)
    t.seth(fx)
    t.pencolor("#840101")
    t.fillcolor('#CD0000')
    t.begin_fill()
    n = 1.8
    for i in range(120):
        if 0 <= i < 30 or 60 <= i < 90:
            n -= 0.05
            t.left(3)
            t.fd(n)
        else:
            n += 0.05
            t.left(3)
            t.fd(n)
    t.end_fill()



def mlingpkqmouth():
    mlingpen(-60,20)
    t.pensize(3)
    t.pencolor("#923E24")
    t.seth(-48)
    t.begin_fill()
    t.circle(15,110)
    t.right(90)
    t.circle(15,110)
    t.seth(0)
    mlingpen(-50,45)
    t.circle(5,180)



def mlingpkqshou1():
    mlingpen(-130,-30)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.seth(100)
    t.begin_fill()
    t.circle(130,30)
    t.right(100)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(30)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(30)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(50)
    t.circle(70,150)
    t.end_fill()

    mlingpen(-138,-67)
    t.pensize(2)
    t.pencolor("#DDA120")
    t.fillcolor('#DDA120')
    t.left(90)
    t.begin_fill()
    t.circle(40,40)
    t.left(10)
    t.circle(-60,70)
    t.left(40)
    t.circle(30,40)
    t.left(83)
    t.circle(70,110)
    t.end_fill()


def mlingpkqshou2():
    mlingpen(0,-40)
    t.pensize(3)
    t.pencolor("#923E24")
    t.fillcolor('#FBD624')
    t.seth(200)
    t.begin_fill()
    t.circle(55,90)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(90)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(60)
    t.fd(10)
    t.left(90)
    t.fd(10)
    t.right(50)
    t.circle(60,80)
    t.end_fill()


def mlingpkqball():
    mlingpen(-30,-250)
    t.pensize(3)
    t.pencolor("#000000")
    t.fillcolor('#CD0000')
    t.seth(0)
    t.begin_fill()
    t.circle(80)
    t.end_fill()
    mlingpen(-110,-170)
    t.seth(-90)
    t.pencolor("#000000")
    t.fillcolor('#ffffff')
    t.begin_fill()
    t.circle(80,180)
    t.end_fill()
    t.pensize(12)
    mlingpen(-105,-170)
    t.pencolor("#000000")
    t.goto(44,-170)
    t.pensize(3)
    mlingpen(-4,-170)
    t.pencolor("#000000")
    t.fillcolor('#000000')
    t.begin_fill()
    t.circle(28)
    t.end_fill()
    mlingpen(-11,-170)
    t.pencolor("#000000")
    t.fillcolor('#ffffff')
    t.begin_fill()
    t.circle(20)
    t.end_fill()
    mlingpen(-21,-170)
    t.pencolor("#000000")
    t.fillcolor('#ffffff')
    t.begin_fill()
    t.circle(10)
    t.end_fill()


def main():
    mlingweiba(50,120)
    mlingpkqface(30,0)
    mlingpkqyingyinying()
    mlingpkqcap()
    mlingpkqcheek2(-140,-10,300)
    mlingpkqcheek2(60, 50,80)
    mlingpkqshou1()
    mlingpkqjiao()
    mlingpkqball()
    mlingpkqshou2()
    mlingpkqmouth()
    mlingpkqeye()

t.color('#321320')
t.penup()
t.goto(260,-40)
t.pendown()
t.write("愿\n你\n拥\n有\n一\n只\n会\n永\n远\n爱\n你\n的\n皮\n卡\n丘\n",align="center",font=("黑体",15,"normal"))
t.penup()
t.goto(290,215)
t.pendown()
t.write("逆\n境\n清\n醒\n",align="center",font=("黑体",10,"normal"))



if __name__ == '__main__':
    main()
    t.done()
    t.hideturtle()

  如果你有自己喜欢的底图,可以将第19行的 “# t.bgpic("di_2_800.gif")” 这句里的图片文件名替换成你自己的图片文件名,记得将注释的 # 符号取消。

  本例草莓熊绘制窗口大小是800*800,绘制环境是python 3.10。 

 八、怎么才能正常运行python turtle绘图代码(本机运行、打包发给别人)

怎么才能正常运行python turtle绘图代码
(1)本机运行绘图代码
(2)打包发给别人欣赏python动画
      (a)安装Pyinstaller
      (b)用Pyinstaller打包动画文件


Pyinstaller参数详解
(1)可选参数
(2)、与生成结果有关的参数
(3)、指定打包哪些资源、代码
(4)、生成参数
(5)、Windows 和 Mac OS X 特定选项
(6)、Windows特有的参数

    具体的详细介绍写在此文中,请点击查看:巴斯光年python turtle绘图__附源代码

   推荐阅读:

原创唯美浪漫情人节表白专辑,(复制就可用)(html5,css3,svg)更好的向你所喜欢的人表达内心的感受。

2023年春节祝福第二弹——送你一只守护兔,让它温暖每一个你【html5 css3】画会动的小兔子
25

2023春节祝福系列第一弹(放飞祈福孔明灯,祝福大家身体健康)(附完整源代码及资源免费下载)
24

​​

HTML+CSS+svg绘制精美彩色闪灯圣诞树,HTML+CSS+Js实时新年时间倒数倒计时(附源代码)

23

​​

​Strawberry Bear python drawing (Spring Festival version, Christmas countdown snowflake version) with source code

22

​​

[Programming Life] Qatar World Cup elements python turtle drawing (source code attached), 5 World Cup themed front-end special effects (source code attached)

21

0a4256d5e96d4624bdca36433237080b.png​​

​​

python love source code collection
20

4d9032c9cdf54f5f9193e45e4532898c.png​​

​​

Buzz Lightyear python turtle drawing__source code attached
19

074cd3c255224c5aa21ff18fdc25053c.png​​

​​​

Detailed explanation of Three.js examples___Spinning Elf Girl (with complete code and resources)
18

daecd7067e7c45abb875fc7a1a469f23.png​​

​​​​

​Strawberry Bear python turtle drawing (rose version) with source code

17

fe88b78e78694570bf2d850ce83b1f69.png​​

​​​​

Three-dimensional multi-layered rose drawing source code__rose python drawing source code collection

16

c5feeb25880d49c085b808bf4e041c86.png​​

​​​​

Pikachu python turtle turtle drawing (power ball version) with source code

15

38266b5036414624875447abd5311e4d.png​​

​​​​

[CSDN Cloud IDE] Personal experience and suggestions (including super detailed operation tutorials) (python, webGL direction)

14

03ed644f9b1d411ba41c59e0a5bdcc61.png​​

​​​​

Strawberry Bear python turtle drawing (windmill version) with source code

13

09e08f86f127431cbfdfe395aa2f8bc9.png​​

​​​​

Celebrating the Mid-Autumn Festival with code, would you like to take a bite of the python turtle mooncake?

12

40e8b4631e2b486bab2a4ebb5bc9f410.png​​

​​​​

"Python List List Full Example Detailed Explanation Series"__Series General Catalog

11

938bc5a8bb454a41bfe0d4185da845dc.jpeg​​

​​​​

Use code to write romance__ collection (python, matplotlib, Matlab, java to draw hearts, roses, front-end special effects roses, hearts)

10

0f09e73712d149ff90f0048a096596c6.png​​

​​​​

A complete collection of detailed explanations of Python function method examples (updating...)

9

93d65dbd09604c4a8ed2c01df0eebc38.png​​

​​​​

matplotlib comes with a quick check on the display of drawing style effects (28 types, all)

8

aa17177aec9b4e5eb19b5d9675302de8.png​​

​​​​

The phone screen is broken ____How to export the data inside (18 methods)

7

1750390dd9da4b39938a23ab447c6fb6.jpeg​​

​​​​

January 2023 ____Programming language rankings__Salary status by multiple authoritative organizations

6

dc8796ddccbf4aec98ac5d3e09001348.jpeg​​

​​​​

Usage of Print() function in Python___ Detailed explanation of examples (full, many examples)

5

1ab685d264ed4ae5b510dc7fbd0d1e55.jpeg​​

​​​​

Color comparison table (300 colors) (hexadecimal, RGB, CMYK, HSV, Chinese and English names)

4

80007dbf51944725bf9cf4cfc75c5a13.png​​

​​​​

Node.js (v19.1.0npm 8.19.3) vue.js installation and configuration tutorial (super detailed)

3

c6374d75c29942f2aa577ce9c5c2e12b.png​​

​​​​

Tomcat startup crash problem solution set (eight major categories in detail)

2

5218ac5338014f389c21bdf1bfa1c599.png​​

​​​​

Tomcat port configuration (details)

1

fffa2098008b4dc68c00a172f67c538d.png​​

​​​​

Tomcat10 installation (Windows environment) (details)

Guess you like

Origin blog.csdn.net/weixin_69553582/article/details/127505979