Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson3-1-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
41bc895f
authored
Sep 05, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
c66a449e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
22 deletions
diy1.py
diy1.py
View file @
41bc895f
# 利用write()帮助悟空给诺依回信吧~
import
turtle
# 导入turtle模块
import
turtle
screen
=
turtle
.
Screen
()
# 创建画布
screen
=
turtle
.
Screen
()
screen
.
bgcolor
(
"light blue"
)
# 设置背景颜色,括号里填颜色的英文单词
screen
.
bgcolor
(
"light blue"
)
p
=
turtle
.
Pen
()
# 创建一支名为p的画笔
len
=
screen
.
textinput
(
"100"
,
"100"
)
p
.
penup
()
len
=
int
(
len
)
p
.
goto
(
100
,
-
100
)
pen
=
turtle
.
Pen
()
p
.
write
(
"但愿人长久,
\n
千里共婵娟。"
,
font
=
(
"Times"
,
20
,
"normal"
))
# 用turtle在画布上写字
pen
.
write
(
"你好
\n
SB."
,
font
=
(
"Times"
,
30
,
"normal"
))
# 画爱心
pen
.
hideturtle
()
n
=
screen
.
textinput
(
"画爱心"
,
"你想画多大的爱心?"
)
len
=
60
r
=
int
(
n
)
pen
.
penup
()
z
=
turtle
.
Pen
()
# 创建一支名为z的画笔
pen
.
goto
(
100
,
100
)
z
.
pensize
(
5
)
# 设置画笔粗细为5
pen
.
pendown
()
z
.
pencolor
(
"red"
)
# 设置画笔颜色
pen
.
pensize
(
5
)
z
.
left
(
45
)
pen
.
pencolor
(
"red"
)
z
.
fd
(
2
*
r
)
pen
.
left
(
45
)
z
.
circle
(
r
,
180
)
# 画右边半圆
pen
.
forward
(
2
*
len
)
z
.
right
(
90
)
pen
.
circle
(
len
,
180
)
z
.
circle
(
r
,
180
)
# 画左边半圆
pen
.
right
(
90
)
z
.
fd
(
2
*
r
)
pen
.
circle
(
len
,
180
)
z
.
hideturtle
()
# 隐藏画笔
pen
.
forward
(
2
*
len
)
p
.
hideturtle
()
turtle
.
done
()
turtle
.
done
()
# 保存画布
# 画圆
# pen.circle(半径) 正数逆时针,负数顺时针
# 画圆弧
# pen.circle(半径,角度)
# "#"在python中是注释符号
# 多行注释:ctrl+/
#画笔默认向右
# pen.pensize() # 设置画笔粗细(大小),括号里填数字,数字越大,画笔越粗。
# pen.pencolor() # 设置画笔颜色,括号里填颜色的英文单词
# pen.goto(x坐标,y坐标) # 画笔移到具体位置
# pen.penup() # 抬笔
# pen.pendown() # 落笔
# screen.textinput("窗口标题","提示语") # 在画布上弹出一个对话框
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