# Python realizes the new coronary Dora A Dream

Posted by allanric on Thu, 06 Feb 2020 09:09:28 +0100  Mei Step 1: first, make two auxiliary lines to facilitate the calculation of coordinates and proportions

```#Draw two guides first
w.create_line(0,300,600,300,dash=(4,4))
w.create_line(300,0,300,600,dash=(4,4))
``` Mei Step 2: draw a blue head (set a diameter of 300) at the lower middle position
(coordinate calculation: since the diameter is determined to be 300, then it is 150 for the left side of y-axis, 150 for the right side, x1=300-150=150, Y1 = 300-200 = 100 (don't reduce 300 here, otherwise all go to the upper half, 200 for here, leave 100 below), then x2=300+150=450,y2=300+100=400. )

So (x1, Y1) = (150100) and (X2, Y2) = (450300)

```#Blue head
w.create_rectangle(150,100,450,400,outline="black",dash=(4,4))
w.create_oval(150,100,450,400,outline="black",fill=Light_blue)
``` Mei Step 3: white face egg (diameter 250)
(coordinate calculation: the face is slightly smaller than the head, and the lower side is overlapped, so the diameter is set to 250, so X1 = 300-125 = 175, Y1 = 300-150 = 150 (because the lower part is overlapped, 100 should be reserved with the upper part, because the diameter is 250, so it's minus 150), x2=300+125=425,y2=300+100=400. )

So (x1, Y1) = (175150) and (X2, Y2) = (425400)

```#White face cake
w.create_rectangle(175,150,425,400,outline="black",dash=(4,4))
w.create_oval(175,150,425,400,outline="black",fill="white")
``` Mei Step 4: draw two oval eggs OO (length: 65, width: 50)
(coordinate calculation: the left eye – > X1 = 300-50, the eye is bigger than the face pie, so subtract 185 (the eye size can be adjusted by yourself, once this is determined, the later points will be calculated according to the length and width you set), y1=300-185=115,x2=300,y2=300-(185-65)=180,
Right eye – > X3 = 300, Y3 = 300-185 = 115, X4 = 300 + 50 = 350, Y4 = 300 - (185-65) = 180)

So the left eye: (x1, Y1) = (250115) and (X2, Y2) = (300180)
So the left eye: (x1, Y1) = (300115) and (X2, Y2) = (350180)

```#Two egg eyes
w.create_rectangle(250,115,300,180,outline="black",dash=(4,4))
w.create_oval(250,115,300,180,outline="black",fill="white")
w.create_rectangle(300,115,350,180,outline="black",dash=(4,4))
w.create_oval(300,115,350,180,outline="black",fill="white")
``` Mei Step 5: draw two black eyes (length: 22, width: 15)
The coordinate calculation is similar to the fourth step, not to be repeated

```#Two eyes
#w.create_rectangle(280,137,295,159,outline="black",dash=(1,1))
w.create_oval(280,137,295,159,outline = "black",fill = "black")
#w.create_rectangle(305,137,320,159,outline="black",dash=(1,1))
w.create_oval(305,137,320,159,outline="black",fill="black")
``` Mei Step 6: draw the white light in two eyes (length: 10, width: 5)

```#White light in two eyes
w.create_oval
w.create_oval(285,145,290,155,fill='white')
w.create_oval(315,145,310,155,fill='white')
``` Mei Step 7: red nose (length: 20, width: 20)
(for x1, according to the dotted line of Y axis, the upper left corner of the rectangle is not too far away from the dotted line. I have a distance of 10 pixels here, x1=300-10=290, y1=300-130=170. Because the distance between the position of the dotted line below and the white circle is 150, we can start from 127, 130 is not much different, x2=300+10, y2=300-130+20=190)

So: (x1, Y1) = (290170) and (X2, Y2) = (310190)

```#Red nose
w.create_oval(290,170,310,190,outline="black",fill="red")
``` Mei Step 8: straight line to nose
(x1 is overlapped with y-axis dotted line, so X1 = 300, y1 = 190190 is based on y2 of just red nose, let him draw to the center for a long time is 300300)
So: (x1, Y1) = (300190) and (X2, Y2) = (300300)

```#Black line to nose
w.create_line(300,190,300,300,fill='black',width=1)
``` Mei Step 9: curved mouth (start at 240 ° and draw at 60 °)
(the front is the bounding rectangle, style specifies the arc, start specifies the starting point of the arc, and extend specifies the radian of the arc.)

```#Arc mouth
#w.create_rectangle(175,50,425,300,outline="black",dash=(4,4))
w.create_arc(175,50,425,300,width=1,style="arc",start=240,extent=60)
``` Mei Step 10: beard (middle horizontal beard length 80, shorter on both sides 70)
(beard is 6 lines in total. According to the symmetry of y-axis dotted line, set left and right to be about 20 away from y-dotted line. First draw three lines on the left, X1 = (300-20-70), Y1 = (200) (because the height under his nose is 190, here is about 200), x2=(300-20),y2=(200+20), and the height difference is 20
The middle beard is very simple. x3=(300-20-80),y3=(200+40),x4=(300-20),y4=220+20
Then the third one and the first one are symmetrical about the middle one, then x5=(300-20-70,y5=(200+40+40), x6=(300-20),y6=(240+20)
Then the coordinate of the beard on the right is the variable addition of the x-axis subtraction, and the y-axis does not change.)

So: (x1, Y1) = (210200) and (X2, Y2) = (280220), (X3, Y3) = (200240) and (x4, Y4 = (280240)), (x5, Y5) = (210280) and (x6, y6 = (280260)

```#beard--Left section, top to bottom
w.create_line(210,200,280,220,fill='black',width=1.5)
w.create_line(200,240,280,240,fill='black',width=1.5)
w.create_line(210,280,280,260,fill='black',width=1.5)
#beard--The right part
w.create_line(320,220,390,200,fill='black',width=1.5)
w.create_line(320,240,400,240,fill='black',width=1.5)
w.create_line(320,260,390,280,fill='black',width=1.5)
``` Mei Step 11: draw a body(220 in length and 200 in width)
(estimate the coordinates from the middle symmetry, X1 = 300-110, Y1 = 300 + 50 (because 100 is left under the previous circle, it's better to take the middle here or you can change it by yourself), x2=300+110,y2=300+50+200)

```#Blue body
w.create_rectangle(190,350,410,550,fill=Light_blue,outline="black")
```

So: (x1, Y1) = (190350) and (X2, Y2) = (410550) Mei Step 12: draw a big belly bag (diameter 170)
(estimate the coordinates from the middle symmetry, X1 = 300-85, Y1 = 300 + 40 (the body is 350, which is 340 higher than the body or you can change it by yourself), x2=300+85,y2=340+170)

So: (x1, Y1) = (215340) and (X2, Y2) = (385510)

```#White round abdomen
#w.create_rectangle(215, 340,385,510,outline="black",dash=(4,4))
w.create_oval(215,340,385,510,outline="white",fill="white")
``` Mei Step 13: draw the red collar (length 224)
(just draw a straight line, set the capstyle option to round, and then the coordinate of the upper left corner of the body is 190. Here, show the body a little bit, set 188, the coordinate of the y axis to be the same as that of the body directly, and the one on the right is similar.)

So: (x1, Y1) = (198350) AND (X2, Y2) = (412350)

```#Red collar
w.create_line(188,350,412,350,fill='red',width=15,capstyle='round')
``` Mei Step 14: draw the bell (diameter 30)
(it's also drawn according to symmetry. If x1=300-15,y1 is lower than the body's 350, it's better. You can fine tune it directly. Here I take y1=348,x2=300+15,y2=348+30)

So: (x1, Y1) = (285348) and (X2, Y2) = (315378)

```#Bell part, yellow
w.create_oval(285, 348,315,378,outline="black",fill="yellow")
``` Mei Step 15: embellish the bell (rectangle length: 28, width: 4, red circle diameter: 8)
(first, draw a horizontal line, X1 = 300-14 = 286, the coordinate of Y1 should be below the body 350, adjust slowly, here I take y1=358,x2=300+14=314,y2=358+4=362
Then draw the circle x3=300-4=296,x4=300+4=304,y3 should be under the rectangle, take y3=365, then y4=365+8=373
The black line is from 373 under the red circle to 378 under the bell.)

```#The yellow line of the bell,Rectangle used
w.create_rectangle(286,358,314,362,fill="yellow",outline="black")
#The little red circle on the bell
w.create_oval(296, 365,304,373,outline="black",fill="red")
#Vertical black line
w.create_line(300,373,300,378)
``` Mei Step 16: Fan Baibao bag (start from 180 ° and draw 180 ° in radian)
(the principle is the same as drawing the arc of the mouth, only changing the style option to fan-shaped)

```#White treasure bag
#w.create_rectangle(240, 365,360,485,outline="black",dash=(4,4))
w.create_arc(240, 365,360,485,width=1,start=180,extent=180,style="pieslice",outline='black',fill='white')
``` Mei Step 17: draw crotch (start from 0 °, span 180 °)

```#White crotch, also fan-shaped
w.create_arc(280, 530,320,570,width=1,start=0,extent=180,style="pieslice",outline='white',fill='white')
``` Mei Step 18: draw two small feet (length: 120 width: 40)
(that is, draw two ellipses. Just like drawing a circle, draw inside a defined rectangle. First draw the left side, and then use the scale to subtract and add the x coordinate.)

```#Two white, oval, little feet
#w.create_rectangle(170, 530,290,570,outline="black",dash=(4,4))
w.create_oval(170, 530,290,570,outline="black",fill="white")
#w.create_rectangle(310, 530,430,570,outline="black",dash=(4,4))
w.create_oval(310, 530,430,570,outline="black",fill="white")
``` Mei Step 19: draw the blue arm, polygon and determine the coordinates of four points
(the length and thickness of the arm can be adjusted by yourself. As long as you are patient, you need to find the coordinates and adjust them slowly.)

```#Draw arm polygon
#Arm
points=[190,360,150,410,170,430,190,420]
w.create_polygon(points,outline="black",fill=Light_blue)
``` Mei Step 20: round the palm
(this is mainly to note that the ordinate of the upper left corner of the bounding rectangle should correspond to the ordinate of the outer arm, and the ordinate of the lower right corner of the bounding rectangle should correspond to the ordinate of the inner arm.)

```#Palm
#w.create_rectangle(130,410,170,450,outline="black",dash=(4,4))
w.create_oval(130,410,170,450, fill="white")
``` ❤ step 21: draw a simple and symmetrical arm and palm on the right. You can also draw a hand up one, but you should be patient and adjust it slowly. Here, subtract x coordinate and add it symmetrically. The y axis is the same

```#Right arm
points=[410,360,450,410,430,430,410,420]
w.create_polygon(points,outline="black",fill=Light_blue)
#right palm
#w.create_rectangle(470,410,430,450,outline="black",dash=(4,4))
w.create_oval(470,410,430,450, fill="white")
``` ```#Draw a crown
points2 = [220,110,200,50,240,65,300,20,360,65,400,50,380,110]
w.create_polygon(points2,outline="white",fill="yellow")
w.create_oval(288,8,312,32,outline="white",fill="red")
w.create_oval(193,43,207,57,outline="white",fill="red")
w.create_oval(393,43,407,57,outline="white",fill="red")

#Left recess
w.create_oval(238,63,242,67,outline="white",fill="yellow")
#Right concave
w.create_oval(358,63,362,67,outline="white",fill="yellow")

```          ❤ at last, don't forget to refuel yourself!! Don't forget to learn, hehe, the source code of picture Doraemon is attached below for the basin friend who needs it

```from tkinter import *
root = Tk()
w = Canvas(root,width = 600,height = 600,background = "white")
w.pack()
#Light blue with RGB
Light_blue ="#%02x%02x%02x" % (0, 159, 232)

#Draw two guides first
w.create_line(0,300,600,300,dash=(4,4))
w.create_line(300,0,300,600,dash=(4,4))

#Draw a crown
points2 = [220,110,200,50,240,65,300,20,360,65,400,50,380,110]
w.create_polygon(points2,outline="white",fill="yellow")
w.create_oval(288,8,312,32,outline="white",fill="red")
w.create_oval(193,43,207,57,outline="white",fill="red")
w.create_oval(393,43,407,57,outline="white",fill="red")

#Left recess
w.create_oval(238,63,242,67,outline="white",fill="yellow")
#Right concave
w.create_oval(358,63,362,67,outline="white",fill="yellow")

#w.create_rectangle(150,100,450,400,outline="black",dash=(4,4))
w.create_oval(150,100,450,400,outline="black",fill=Light_blue)

#White pancake face
#w.create_rectangle(175,150,425,400,outline="black",dash=(4,4))
w.create_oval(175,150,425,400,outline="black",fill="white")

#Two egg eyes
#w.create_rectangle(250,115,300,180,outline="black",dash=(4,4))
w.create_oval(250,115,300,180,outline="black",fill="white")
#w.create_rectangle(300,115,350,180,outline="black",dash=(4,4))
w.create_oval(300,115,350,180,outline="black",fill="white")

#Two eyes
#w.create_rectangle(280,137,295,159,outline="black",dash=(1,1))
w.create_oval(280,137,295,159,outline = "black",fill = "black")
#w.create_rectangle(305,137,320,159,outline="black",dash=(1,1))
w.create_oval(305,137,320,159,outline="black",fill="black")

#White light in two eyes
w.create_oval
w.create_oval(285,145,290,155,fill='white')
w.create_oval(315,145,310,155,fill='white')

#Red nose
w.create_oval(290,170,310,190,outline="black",fill="red")

#Black line to nose
w.create_line(300,190,300,300,fill='black',width=1)

#Arc mouth
#w.create_rectangle(175,50,425,300,outline="black",dash=(4,4))
w.create_arc(175,50,425,300,width=1,style="arc",start=240,extent=60)

#beard--Left section, top to bottom
w.create_line(210,200,280,220,fill='black',width=1.5)
w.create_line(200,240,280,240,fill='black',width=1.5)
w.create_line(210,280,280,260,fill='black',width=1.5)
#beard--The right part
w.create_line(320,220,390,200,fill='black',width=1.5)
w.create_line(320,240,400,240,fill='black',width=1.5)
w.create_line(320,260,390,280,fill='black',width=1.5)

#Blue body
w.create_rectangle(190,350,410,550,fill=Light_blue,outline="black")

#White round abdomen
#w.create_rectangle(215, 340,385,510,outline="black",dash=(4,4))
w.create_oval(215,340,385,510,outline="white",fill="white")

#Red collar
w.create_line(188,350,412,350,fill='red',width=15,capstyle='round')

#Bell part, yellow
w.create_oval(285, 348,315,378,outline="black",fill="yellow")
#The yellow line of the bell,Rectangle used
w.create_rectangle(286,358,314,362,fill="yellow",outline="black")
#The little red circle on the bell
w.create_oval(296, 365,304,373,outline="black",fill="red")
#Vertical black line
w.create_line(300,373,300,378)

#White treasure bag, fan-shaped
#w.create_rectangle(240, 365,360,485,outline="black",dash=(4,4))
w.create_arc(240, 365,360,485,width=1,start=180,extent=180,style="pieslice",outline='black',fill='white')

#White crotch, also fan-shaped
w.create_arc(280, 530,320,570,width=1,start=0,extent=180,style="pieslice",outline='white',fill='white')

#Two white, oval, little feet
#w.create_rectangle(170, 530,290,570,outline="black",dash=(4,4))
w.create_oval(170, 530,290,570,outline="black",fill="white")
#w.create_rectangle(310, 530,430,570,outline="black",dash=(4,4))
w.create_oval(310, 530,430,570,outline="black",fill="white")

#Draw arm polygon
#Arm
points=[190,360,150,410,170,430,190,420]
w.create_polygon(points,outline="black",fill=Light_blue)
#Palm
#w.create_rectangle(130,410,170,450,outline="black",dash=(4,4))
w.create_oval(130,410,170,450, fill="white")

#Right arm
points=[410,360,450,410,430,430,410,420]
w.create_polygon(points,outline="black",fill=Light_blue)
#right palm
#w.create_rectangle(470,410,430,450,outline="black",dash=(4,4))
w.create_oval(470,410,430,450, fill="white")

root.mainloop()

```  237 original articles published, 104 praised, 250000 visitors+