Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson3-4-1_DIY1
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
c3862812
authored
Jun 10, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
ad89a433
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
29 deletions
diy.py
diy.py
View file @
c3862812
import
turtle
#导入turtle模块
import
turtle
#设置画布
pen
=
turtle
.
Pen
()
screen
=
turtle
.
Screen
()
#创建背景
screen
=
turtle
.
Screen
()
screen
.
bgcolor
(
"light blue"
)
#设置背景颜色
size
=
screen
.
textinput
(
"提示"
,
"你想要多大的魔法阵呀?"
)
aa
=
screen
.
textinput
(
"对话框"
,
"你想要多大的爱心?"
)
len
=
int
(
size
)
#写字
pen
.
circle
(
len
)
pen
=
turtle
.
Pen
()
#创建画笔
pen
.
circle
(
len
,
360
,
3
)
pen
.
penup
()
#起笔
pen
.
circle
(
len
,
60
)
pen
.
goto
(
100
,
-
100
)
#画笔落到坐标(100,-100)处
pen
.
circle
(
len
,
360
,
3
)
pen
.
write
(
"你好,
\n
老六"
,
font
=
(
"times"
,
20
,
"normal"
))
#设置写的字
turtle
.
done
()
pen
.
hideturtle
()
#隐藏画笔
\ No newline at end of file
#画爱心
import
random
#导入随机模块
len
=
int
(
aa
)
pen1
=
turtle
.
Pen
()
#创建画笔
pen1
.
pensize
(
5
)
#设置画笔大小
pen1
.
pencolor
(
"pink"
)
#设置画笔颜色
pen1
.
fillcolor
(
"pink"
)
#设置填充颜色
pen1
.
begin_fill
()
#开始填充
pen1
.
left
(
45
)
#左转45度
pen1
.
forward
(
len
*
2
)
#将随机数作为参数
pen1
.
circle
(
len
,
180
)
#将随机数作为参数
pen1
.
right
(
90
)
#右转45度
pen1
.
circle
(
len
,
180
)
#将随机数作为参数
pen1
.
forward
(
len
*
2
)
#将随机数作为参数
pen1
.
end_fill
()
#填充结束
pen1
.
hideturtle
()
#隐藏画笔
turtle
.
done
()
#保存画布
\ 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