Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson2_diy3
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
924e2ae9
authored
Sep 24, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
ef7dc539
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
meiguihua.py
yinghuashu.py
meiguihua.py
0 → 100644
View file @
924e2ae9
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
matplotlib
import
cm
# 创建figure窗口及axes坐标区域
fig
=
plt
.
figure
()
ax
=
plt
.
axes
(
projection
=
'3d'
)
# 构造玫瑰花曲面
x
=
np
.
linspace
(
0
,
1
,
200
)
theta
=
np
.
linspace
(
-
2
*
np
.
pi
,
15
*
np
.
pi
,
300
)
[
x
,
theta
]
=
np
.
meshgrid
(
x
,
theta
)
phi
=
(
np
.
pi
/
2
)
*
np
.
exp
(
-
theta
/
8
/
np
.
pi
)
X
=
1
-.
5
*
pow
(
1.25
*
pow
(
1
-
np
.
mod
(
3.6
*
theta
,
2
*
np
.
pi
)
/
np
.
pi
,
2
)
-
1
/
4
,
2
)
y
=
1.95653
*
pow
(
x
,
2
)
*
pow
(
1.27689
*
x
-
1
,
2
)
*
np
.
sin
(
phi
)
r
=
X
*
(
x
*
np
.
sin
(
phi
)
+
y
*
np
.
cos
(
phi
))
h
=
X
*
(
x
*
np
.
cos
(
phi
)
-
y
*
np
.
sin
(
phi
))
# 设置颜色并绘制曲面
c
=
cm
.
get_cmap
(
'magma'
)
surf
=
ax
.
plot_surface
(
r
*
np
.
cos
(
theta
),
r
*
np
.
sin
(
theta
),
h
,
rstride
=
1
,
cstride
=
1
,
cmap
=
c
,
linewidth
=
0
,
antialiased
=
True
)
# 减小空白区域并绘图
ax
.
set_position
((
0
,
0
,
1
,
1
))
plt
.
show
()
yinghuashu.py
0 → 100644
View file @
924e2ae9
import
turtle
,
random
def
tree
(
branchLen
,
t
):
if
branchLen
>
3
:
if
8
<=
branchLen
<=
12
:
if
random
.
randint
(
0
,
2
)
==
0
:
t
.
color
(
'snow'
)
else
:
t
.
color
(
'lightcoral'
)
t
.
pensize
(
branchLen
/
3
)
elif
branchLen
<
8
:
if
random
.
randint
(
0
,
1
)
==
0
:
t
.
color
(
'snow'
)
else
:
t
.
color
(
'lightcoral'
)
t
.
pensize
(
branchLen
/
2
)
else
:
t
.
color
(
'sienna'
)
t
.
pensize
(
branchLen
/
10
)
t
.
forward
(
branchLen
)
a
=
1.5
*
random
.
random
()
t
.
right
(
20
*
a
)
b
=
1.5
*
random
.
random
()
tree
(
branchLen
-
10
*
b
,
t
)
t
.
left
(
40
*
a
)
tree
(
branchLen
-
10
*
b
,
t
)
t
.
right
(
20
*
a
)
t
.
up
()
t
.
backward
(
branchLen
)
t
.
down
()
def
petal
(
m
,
t
):
for
i
in
range
(
m
):
a
=
200
-
400
*
random
.
random
()
b
=
10
-
20
*
random
.
random
()
t
.
up
()
t
.
forward
(
b
)
t
.
left
(
90
)
t
.
forward
(
a
)
t
.
down
()
t
.
color
(
'pink'
)
t
.
circle
(
1
)
t
.
up
()
t
.
backward
(
a
)
t
.
right
(
90
)
t
.
backward
(
b
)
def
main
():
t
=
turtle
.
Turtle
()
w
=
turtle
.
Screen
()
t
.
hideturtle
()
turtle
.
getscreen
()
.
tracer
(
5
,
0
)
w
.
screensize
(
bg
=
'wheat'
)
t
.
left
(
90
)
t
.
up
()
t
.
backward
(
150
)
t
.
down
()
t
.
color
(
'sienna'
)
tree
(
60
,
t
)
petal
(
200
,
t
)
w
.
exitonclick
()
main
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment