Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2e3de5a

Browse files
add blog
1 parent 35e6b16 commit 2e3de5a

File tree

6 files changed

+231
-0
lines changed

6 files changed

+231
-0
lines changed

‎doudou/2022-04-29-turtle/t_3.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import turtle
2+
3+
t = turtle.Pen()
4+
t.speed(100)
5+
turtle.bgcolor("black")
6+
sides = 6
7+
colors = ["red", "yellow", "green", "blue", "orange", "purple"]
8+
for x in range(360):
9+
t.pencolor(colors[x % sides])
10+
t.forward(x * 3 / sides + x)
11+
t.left(360 / sides + 1)
12+
t.width(x * sides / 200)
13+
14+
print("####结束####")
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import turtle
2+
aj = turtle.Pen()
3+
y = 0
4+
aj.speed(100)
5+
turtle.bgcolor("black")
6+
7+
# aj.shape("turtle")
8+
def head():
9+
aj.color("green")
10+
aj.fd(160)
11+
x = aj.xcor()
12+
aj.seth(90)
13+
aj.begin_fill()
14+
# aj.color("green")
15+
aj.circle(x / 2, 180)
16+
aj.end_fill()
17+
aj.penup()
18+
aj.goto(33, 37)
19+
aj.pendown()
20+
aj.dot(13, "black")
21+
aj.penup()
22+
aj.goto(126, 37)
23+
aj.pendown()
24+
aj.dot(13, "black")
25+
aj.penup()
26+
aj.home()
27+
aj.pendown()
28+
aj.hideturtle()
29+
aj.fd(160)
30+
aj.seth(90)
31+
aj.circle(x / 2, 60)
32+
aj.right(90)
33+
aj.pensize(5)
34+
aj.fd(30)
35+
36+
aj.penup()
37+
aj.home()
38+
# aj.pendown()
39+
aj.hideturtle()
40+
aj.fd(160)
41+
aj.seth(90)
42+
aj.circle(x / 2, 120)
43+
aj.right(90)
44+
aj.pensize(5)
45+
aj.pendown()
46+
aj.fd(30)
47+
aj.penup()
48+
aj.home()
49+
aj.penup()
50+
51+
52+
def body():
53+
aj.pensize(0)
54+
55+
aj.home()
56+
aj.showturtle()
57+
aj.goto(0, -7)
58+
aj.pendown()
59+
aj.begin_fill()
60+
aj.fd(160)
61+
aj.right(90)
62+
aj.fd(120)
63+
aj.right(90)
64+
aj.fd(160)
65+
y = aj.ycor()
66+
aj.right(90)
67+
aj.fd(120)
68+
aj.end_fill()
69+
70+
71+
def legs():
72+
aj.penup()
73+
# turtle.color("red")
74+
aj.goto(33, -169)
75+
aj.pendown()
76+
aj.pensize(32)
77+
aj.fd(43)
78+
aj.penup()
79+
aj.goto(130, -169)
80+
aj.pendown()
81+
aj.fd(43)
82+
aj.penup()
83+
84+
85+
def hands():
86+
aj.home()
87+
aj.pensize(30)
88+
aj.goto(-18, -77)
89+
aj.pendown()
90+
aj.left(90)
91+
aj.fd(65)
92+
aj.penup()
93+
aj.goto(179, -77)
94+
aj.pendown()
95+
aj.fd(65)
96+
aj.penup()
97+
aj.fd(100)
98+
aj.hideturtle()
99+
aj.circle(100)
100+
aj.circle(100, 360, 59)
101+
102+
head()
103+
body()
104+
legs()
105+
hands()
106+
turtle.done()

‎doudou/2022-04-29-turtle/t_feiji.py‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import turtle
2+
3+
# 太阳
4+
turtle.color('red')
5+
turtle.penup()
6+
turtle.goto(250,200)
7+
turtle.pendown()
8+
turtle.begin_fill()
9+
turtle.circle(50)
10+
turtle.end_fill()
11+
turtle.color('black','blue')
12+
turtle.begin_fill()
13+
#飞机
14+
turtle.penup()
15+
turtle.home()
16+
turtle.pendown()
17+
turtle.pensize(5)
18+
turtle.goto(-300,150)
19+
turtle.goto(100,50)
20+
turtle.goto(0,0)
21+
turtle.end_fill()
22+
turtle.goto(-30,-125)
23+
turtle.goto(-50,-50)
24+
turtle.begin_fill()
25+
turtle.goto(-300,150)
26+
turtle.goto(-125,-125)
27+
turtle.goto(-50,-50)
28+
turtle.goto(-30,-125)
29+
turtle.goto(-85,-85)
30+
turtle.end_fill()
31+
#线条
32+
turtle.pensize(3)
33+
turtle.penup()
34+
turtle.goto(75,25)
35+
turtle.pendown()
36+
turtle.goto(200,0)
37+
turtle.penup()
38+
turtle.goto(50,-5)
39+
turtle.pendown()
40+
turtle.goto(250,-30)
41+
turtle.penup()
42+
turtle.goto(10,-80)
43+
turtle.pendown()
44+
turtle.goto(100,-150)
45+
turtle.penup()
46+
turtle.goto(-80,-125)
47+
turtle.pendown()
48+
turtle.goto(120,-200)
49+
turtle.done()

‎doudou/2022-04-29-turtle/t_view.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import turtle as t
2+
from turtle import *
3+
4+
angle = 60 # 通过改变角度,绘制出各种多边形
5+
t.bgcolor('black')
6+
t.pensize(2)
7+
randomColor = ['red', 'blue', 'green', 'purple', 'gold', 'pink']
8+
t.speed(0)
9+
for i in range(200):
10+
t.color(randomColor[i % 6])
11+
t.circle(i)
12+
t.rt(angle + 1)
13+
up()
14+
color("#0fe6ca")
15+
goto(0, 0)
16+
down()
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import turtle
2+
3+
toplevel = 8 # 一共递归6层
4+
angle = 30
5+
rangle = 15
6+
7+
8+
def drawTree(length, level):
9+
turtle.left(angle) # 绘制左枝
10+
turtle.color("black")
11+
turtle.forward(length)
12+
13+
if level == toplevel: # 叶子
14+
turtle.color("pink")
15+
turtle.circle(2, 360)
16+
17+
if level < toplevel: # 在左枝退回去之前递归
18+
drawTree(length - 10, level + 1)
19+
turtle.back(length)
20+
21+
turtle.right(angle + rangle) # 绘制右枝
22+
turtle.color("black")
23+
turtle.forward(length)
24+
25+
if level == toplevel: # 叶子
26+
turtle.color("pink")
27+
turtle.circle(2, 360)
28+
29+
if level < toplevel: # 在右枝退回去之前递归
30+
drawTree(length - 10, level + 1)
31+
turtle.color("black")
32+
turtle.back(length)
33+
turtle.left(rangle)
34+
35+
36+
turtle.left(90)
37+
turtle.penup()
38+
turtle.back(300)
39+
turtle.pendown()
40+
turtle.forward(100)
41+
turtle.speed(500)
42+
drawTree(80, 1)
43+
44+
turtle.done()

‎doudou/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Python技术 公众号文章代码库
88

99
## 实例代码
1010

11+
[画画](https://github.com/JustDoPython/python-examples/tree/master/doudou/2022-04-29)
12+
1113
[ffmpeg](https://github.com/JustDoPython/python-examples/tree/master/doudou/2022-04-25-ffmpeg)
1214

1315
[视频号视频下载](https://github.com/JustDoPython/python-examples/tree/master/doudou/2022-03-23-channel)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /