Skip to content

Commit 9db05e8

Browse files
committed
m
1 parent a5c322f commit 9db05e8

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

yeke/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
+ [py-recogLP](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-recogLP) :如何用 Python 识别车牌
77
+ [py-plane](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-plane) :用 Python 实现微信版飞机大战
88
+ [py-rain](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-rain) :用 Python 实现黑客帝国中的数字雨落既视感
9+
+ [py-facepalm](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-facepalm) :用 Python 画一个捂脸表情
910

1011
---
1112

yeke/py-facepalm/__init__.py

Whitespace-only changes.

yeke/py-facepalm/facepalm.py

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
import turtle
2+
3+
# 画圆弧
4+
def arc(sa, ea, x, y, r):
5+
turtle.penup()
6+
turtle.goto(x, y)
7+
turtle.setheading(0)
8+
turtle.left(sa)
9+
turtle.fd(r)
10+
turtle.pendown()
11+
turtle.left(90)
12+
turtle.circle(r, (ea - sa))
13+
return turtle.position()
14+
15+
# 画脸
16+
turtle.speed(5)
17+
turtle.setup(500, 500)
18+
turtle.pensize(5)
19+
turtle.right(90)
20+
turtle.penup()
21+
turtle.fd(100)
22+
turtle.left(90)
23+
turtle.pendown()
24+
turtle.begin_fill()
25+
turtle.pencolor("#B8860B") # head side color
26+
turtle.circle(150)
27+
turtle.fillcolor("#FFFF99") # face color
28+
turtle.end_fill()
29+
30+
# 画嘴
31+
turtle.penup()
32+
turtle.goto(77, 20)
33+
turtle.pencolor("#B8860B")
34+
turtle.goto(0, 50)
35+
turtle.right(30)
36+
turtle.fd(110)
37+
turtle.right(90)
38+
turtle.pendown()
39+
turtle.begin_fill()
40+
turtle.fillcolor("#925902") # mouth color
41+
turtle.circle(-97, 160)
42+
turtle.goto(92, -3)
43+
turtle.end_fill()
44+
turtle.penup()
45+
turtle.goto(77, -25)
46+
# 画牙齿
47+
turtle.pencolor("white")
48+
turtle.begin_fill()
49+
turtle.fillcolor("white")
50+
turtle.goto(77, -24)
51+
turtle.goto(-81, 29)
52+
turtle.goto(-70, 43)
53+
turtle.goto(77, -8)
54+
turtle.end_fill()
55+
turtle.penup()
56+
turtle.goto(0, -100)
57+
turtle.setheading(0)
58+
turtle.pendown()
59+
60+
# 画左边眼泪
61+
turtle.left(90)
62+
turtle.pensize(3)
63+
turtle.penup()
64+
turtle.fd(150)
65+
turtle.right(60)
66+
turtle.fd(-150)
67+
turtle.pendown()
68+
turtle.left(20)
69+
turtle.pencolor("#155F84")
70+
turtle.fd(150)
71+
turtle.right(180)
72+
position1 = turtle.position()
73+
turtle.begin_fill()
74+
turtle.fillcolor("#B0E0E6")
75+
turtle.fd(150)
76+
turtle.right(20)
77+
turtle.left(270)
78+
turtle.circle(-150, 18)
79+
turtle.right(52)
80+
turtle.fd(110)
81+
position2 = turtle.position()
82+
turtle.goto(-33, 90)
83+
turtle.end_fill()
84+
# 画右边眼泪
85+
turtle.penup()
86+
turtle.goto(0, 0)
87+
turtle.setheading(0)
88+
turtle.left(90)
89+
turtle.fd(50)
90+
turtle.right(150)
91+
turtle.fd(150)
92+
turtle.left(150)
93+
turtle.fd(100)
94+
turtle.pendown()
95+
turtle.begin_fill()
96+
turtle.fd(-100)
97+
turtle.fillcolor("#B0E0E6")
98+
turtle.right(60)
99+
turtle.circle(150, 15)
100+
turtle.left(45)
101+
turtle.fd(66)
102+
turtle.goto(77, 20)
103+
turtle.end_fill()
104+
# 画眼睛
105+
turtle.pensize(5)
106+
turtle.penup()
107+
turtle.pencolor("black") # eye color
108+
turtle.goto(-65, 75)
109+
turtle.setheading(0)
110+
turtle.left(27)
111+
turtle.fd(30)
112+
turtle.pendown()
113+
turtle.begin_fill()
114+
turtle.fillcolor("black") # eye color
115+
turtle.left(90)
116+
turtle.circle(30, 86)
117+
turtle.goto(position2[0], position2[1])
118+
turtle.goto(position1[0], position1[1])
119+
turtle.end_fill()
120+
121+
# 画手
122+
turtle.pencolor("#B8860B")
123+
turtle.fillcolor("#FFFF99")
124+
# 第一个手指
125+
arc(-110, 10, 110, -40, 30)
126+
turtle.begin_fill()
127+
turtle.circle(300, 35)
128+
turtle.circle(13, 120)
129+
turtle.setheading(-50)
130+
turtle.fd(20)
131+
turtle.setheading(130)
132+
# 第二个手指
133+
turtle.circle(200, 15)
134+
turtle.circle(12, 180)
135+
turtle.fd(40)
136+
turtle.setheading(137)
137+
# 第三个手指
138+
turtle.circle(200, 16)
139+
turtle.circle(12, 160)
140+
turtle.setheading(-35)
141+
turtle.fd(45)
142+
turtle.setheading(140)
143+
# 第四个手指
144+
turtle.circle(200, 13)
145+
turtle.circle(11, 160)
146+
turtle.setheading(-35)
147+
turtle.fd(40)
148+
turtle.setheading(145)
149+
# 第五个手指
150+
turtle.circle(200, 9)
151+
turtle.circle(10, 180)
152+
turtle.setheading(-31)
153+
turtle.fd(50)
154+
# 画最后手腕的部分
155+
turtle.setheading(-45)
156+
turtle.pensize(7)
157+
turtle.right(5)
158+
turtle.circle(180, 35)
159+
turtle.end_fill()
160+
turtle.begin_fill()
161+
turtle.setheading(-77)
162+
turtle.fd(50)
163+
turtle.left(-279)
164+
turtle.fd(16)
165+
turtle.circle(29, 90)
166+
turtle.end_fill()
167+
turtle.hideturtle()
168+
turtle.done()

0 commit comments

Comments
 (0)