#Square_Screw.py
from turtle import * #导入turtle库
pensize(3) #画笔的宽度(3)
bgcolor('black') #背景颜色黑色
colormode(255) #颜色模式为0-255
pencolor((51,204,120)) #画笔rgb值
for i in range(100): #循环画100次
fd(i + (i * 2 )) #循环长度i+(i*2)
left(90) #左转90度
hideturtle() #隐藏
done() #停留
#正五角形
import turtle
turtle.setup(500, 500) # 画布尺寸
turtle.pensize(7) # 画笔尺寸
turtle.pencolor("yellow") # 画笔颜色
turtle.fillcolor("red") # 填充颜色
turtle.penup() # 提起画笔
turtle.goto(-120, 50) # 画笔从中心移动往X轴负方向移动120像素点,往y轴正方向移动50像素点
turtle.pendown() # 放下画笔
turtle.begin_fill() # 画笔开始填充
for i in range(5): # 设置循环次数为5,两条边为一次循环
turtle.fd(100) # 画笔向前画100像素单位
turtle.left(72) # 左72度
turtle.fd(100) # 画笔向前画100像素单位
turtle.right(144) # 右144度
turtle.end_fill() # 结束填充
turtle.done() # 程序运行完,画布窗体不关闭
#正方形
import turtle as tl #导入库turtle为tl
tl.color("red") #画笔颜色
tl.forward(100) #向正前方爬行100
tl.left(90) #左转90度
tl.forward(100) #向正前方爬行100
tl.left(90) #左转90度
tl.color("green") #重新设置画笔颜色
tl.forward(100) #向正前方爬行100
tl.left(90) #左转90度
tl.forward(100) #向正前方爬行100
#正三角形
import turtle as tl #取别名为tl
tl.color("red") #颜色
tl.pensize(7)
tl.fillcolor("blue")
tl.begin_fill()
tl.forward(200) #向正前方200
tl.left(120) #左转120度
tl.forward(200) #向正前方200
tl.left(120) #左转120度
tl.forward(200) #向正前方200
tl.end_fill()
862

被折叠的 条评论
为什么被折叠?



