用户:
RainDawn_SATA查看:0 回复:0 评论:0 创建时间:2021-08-12T20:00:43
【作品展示】

【作品介绍】
图片仅供参考
【作品源代码】
import turtle as t
import time
import easygui
bgcolor = t.textinput('write your backgroudcolor',
'write your backgroudcolor(string)[you have to write by yourself]')
pencolor = t.textinput('write your pencolor',
'write your pencolor(string)[you have to write by yourself]')
fillcolor = t.textinput('write your fillcolor',
'write your fillcolor(string)[you have to write by yourself]')
y_n = t.textinput('Do you want to hide the turtle',
'Do you want to hide the turtle(yes/no)')
pensize = t.numinput('write your pensize',
'wirte your pensize(must be num)[be careful if you want to set the high num]')
pen_speed = t.numinput('write the speed of your pen',
'wirte the speed of your pen(must be num)[I hope you can choose from 0 to 3]')
if y_n == "yes" or y_n == "y":
y_n = 0
elif y_n == "no" or y_n == "n":
y_n = 1
t.speed(int(pen_speed))
t.pensize(int(pensize))
t.bgcolor(str(bgcolor))
t.pencolor(str(pencolor))
t.fillcolor(str(fillcolor))
t.screensize(int(400), int(400))
if y_n == 0:
t.hideturtle()
elif y_n == 1:
t.showturtle()
class Graph():
def graph():
n = 0
distance = t.numinput(
'Write the the length of each side', 'Write the the length of each side(边的长度)')
where_x = t.numinput('where you want to start_draw',
'where you want to start_draw(x-axis)[x]')
where_y = t.numinput('where you want to start_draw',
'where you want to start_draw(y-axis)[y]')
fill_vule = t.numinput('Do you want fill the graph',
'Do you want fill the graph(fill = 0, not fill = 1 [numinput]{number数字})')
if easygui.ynbox('Do you want to change your fillcolor?', ' ', ('yes', 'no')):
t.fillcolor(t.textinput('write your fillcolor',
'write your fillcolor(string)[you have to write by yourself]'))
else:
pass
if easygui.ynbox('Do you want to change your pencolor?', ' ', ('yes', 'no')):
t.pencolor(t.textinput('write your pencolor',
'write your pencolor(string)[you have to write by yourself]'))
else:
pass
graph = t.textinput('What graph do you want to draw',
'What graph do you want to draw(triangle/三角形,rectangle/矩形, pentagon/五边形')
if str(graph) == "triangle" or str(graph) == "三角形":
graph = 0
elif str(graph) == "rectangle" or str(graph) == "矩形":
graph = 1
elif str(graph) == "pentagon" or str(graph) == "五边形":
graph = 2
t.penup()
t.goto(where_x, where_y)
t.pendown()
if fill_vule == 0:
if graph == 0:
n = 3
t.begin_fill()
for i in range(n):
t.fd(distance)
t.lt(360/n)
t.end_fill()
elif graph == 1:
n = 4
t.begin_fill()
for i in range(n):
t.fd(distance)
t.lt(360/n)
t.end_fill()
elif graph == 2:
n = 5
t.begin_fill()
for i in range(n):
t.fd(distance)
t.lt(360/n)
t.end_fill()
elif graph == 3:
t.begin_fill()
pass
t.end_fill()
elif fill_vule == 1:
if graph == 0:
n = 3
for i in range(n):
t.fd(distance)
t.lt(360/n)
elif graph == 1:
n = 4
for i in range(n):
t.fd(distance)
t.lt(360/n)
elif graph == 2:
n = 5
for i in range(n):
t.fd(distance)
t.lt(360/n)
elif graph == 3:
pass
if __name__ == "__main__":
m = t.numinput('How many graph you want to draw',
'How many graph you want to draw')
for i in range(int(m)):
Graph.graph()
time.sleep(1)
time.sleep(2)
t.clear()
t.write(str("graph_org_drawing"), font=("Comic Sans Ms", 60))
t.up()
t.goto(100, -100)
t.down()
t.write("---RainDawn", font=("Brush Script MT", 60))
time.sleep(2)
t.clear()
t.write("THANKS", font=("Brush Script MT", 90))
time.sleep(3)
t.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn