用户:
炸图监管者查看:0 回复:0 评论:0 创建时间:2021-05-13T12:59:20
【作品展示】

【作品介绍】
添加自动画图功能
【作品源代码】
import turtle
print("欢迎使用中文海龟画图编辑器")
print("支持语法:颜色 底色 走路 旋转 画板 粗细 抬笔 落笔 隐藏 速度 移动 移动X 移动Y 清除 归位 重置 绘制 输入帮助获取")
while True:
a = input(">>>")
if a == "画板":
turtle.Pen()
print("OK")
if a == "粗细":
cu = input("粗细:")
turtle.pensize(cu)
print("OK")
if a == "颜色":
e = input('颜色[红/绿/蓝/橙/黄/黑/白/粉/紫]:')
if e == "红":
turtle.color('red')
if e == '绿':
turtle.color('green')
if e == '蓝':
turtle.color('blue')
if e == '橙':
turtle.color('orange')
if e == '黄':
turtle.color('yellow')
if e == '黑':
turtle.color('black')
if e == '白':
turtle.color('white')
if e == '粉':
turtle.color('pink')
if e == '紫':
turtle.color('purple')
print("OK")
if a == '走路':
bu = int(input('步数:'))
turtle.fd(bu)
bu = 0
print("OK")
if a == '旋转':
zhuan = int(input('度数:'))
turtle.left(zhuan)
print("OK")
if a == '底色':
s = input('颜色[红/绿/蓝/橙/黄/黑/白/粉/紫]:')
if s == '红':
turtle.bgcolor('red')
if s == '绿':
turtle.bgcolor('green')
if s == '蓝':
turtle.bgcolor('blue')
if s == '橙':
turtle.bgcolor('orange')
if s == '黄':
turtle.bgcolor('yellow')
if s == '黑':
turtle.bgcolor('black')
if s == '白':
turtle.bgcolor('white')
if s == '粉':
turtle.bgcolor('pink')
if s == '紫':
turtle.bgcolor('purple')
print("OK")
if a == '速度':
sudu = int(input('速度[1-100]:'))
turtle.speed(sudu)
print("OK")
if a == '抬笔':
turtle.penup()
print("OK")
if a == '落笔':
turtle.pendown()
print("OK")
if a == "隐藏":
turtle.hideturtle()
print("OK")
if a == "移动":
yiX = int(input('X:'))
yiY = int(input("Y:"))
turtle.goto(yiX, yiY)
print("OK")
if a == '移动X':
XXX = int(input('X:'))
turtle.setx(XXX)
print("OK")
if a == '移动Y':
YYY = int(input('Y:'))
turtle.sety(YYY)
print("OK")
if a == "清除":
turtle.clear()
print("OK")
if a == "归位":
turtle.home()
print("OK")
if a == '重置':
turtle.reset()
print("OK")
if a == "帮助":
print("支持语法:颜色 底色 走路 旋转 画板 粗细 抬笔 落笔 隐藏 速度 移动 移动X 移动Y 清除 归位 重置 绘制")
if a == "绘制":
print("圆形 正方形 长方形")
h = input("选择:")
if h == "圆形":
zhj = int(input("直径:"))
turtle.circle(zhj)
print("OK")
if h == '正方形':
an = int(input("边长:"))
turtle.fd(an)
turtle.left(90)
turtle.fd(an)
turtle.left(90)
turtle.fd(an)
turtle.left(90)
turtle.fd(an)
turtle.left(90)
print('OK')
if h == "长方形":
chang = int(input('长:'))
kuan = int(input('宽:'))
if chang > kuan:
heng = input("横/竖:")
if heng == "横":
turtle.fd(chang)
turtle.left(90)
turtle.fd(kuan)
turtle.left(90)
turtle.fd(chang)
turtle.left(90)
turtle.fd(kuan)
turtle.left(90)
print("OK")
if heng == '竖':
turtle.fd(kuan)
turtle.left(90)
turtle.fd(chang)
turtle.left(90)
turtle.fd(kuan)
turtle.left(90)
turtle.fd(chang)
turtle.left(90)
print("OK")
else:
print("长方形错误")
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn