#画太阳花
import turtle
import time
turtle.color('red','yellow')
turtle.begin_fill()
while True:
turtle.forward(200)
turtle.left(170)
if abs(turtle.pos()) < 1:
break
turtle.end_fill()
turtle.done()
time.sleep(10)
#绘制彩色螺旋线
import turtle
import time
turtle.pensize(2)
turtle.bgcolor("black")
colors = ["red","yellow","purple","blue"]
turtle.tracer(False)
for x in range(400):
turtle.forward(2*x)
turtle.color(colors[x % 4])
turtle.left(91)
turtle.tracer(True)
# input() 可以有效解决闪退问题,或者下面的方法
time.sleep(20)
import turtle
window = turtle.Screen()
bage = turtle.Turtle()
radius = 100
bage.width(3)
bage.color("black", "black")
bage.begin_fill()
bage.circle(radius/2, 180)
bage.circle(radius, 180)
bage.left(180)
bage.circle(-radius/2, 180)
bage.end_fill()
bage.left(90)
bage.up()
bage.forward(radius*0.35)
bage.right(90)
bage.down()
bage.color("white", "white")
bage.begin_fill()
bage.circle(radius*0.15)
bage.end_fill()
bage.left(90)
bage.up()
bage.backward(radius*0.7)
bage.down()
bage.left(90)
bage.color("black", "black")
bage.begin_fill()
bage.circle(radius*0.15)
bage.end_fill()
bage.right(90)
bage.up()
bage.backward(radius*0.65)
bage.right(90)
bage.down()
bage.circle(radius, 180)
bage.ht()
window.exitonclick()
import turtle
# 设置画笔和背景颜色
turtle.color('yellow')
turtle.bgcolor('red')
# 通过偏移量和尺寸大小画星星
def drawFillStarByOffsetAndSize(offsetX, offsetY, size):
# 移动画笔
def move(x, y):
turtle.up()
turtle.goto(x, y)
turtle.down()
# 通过尺寸画星星
def drawStar(starSize):
for i in range(5):
turtle.left(144)
turtle.back(starSize)
# 移动画笔且画出填充的星星
turtle.begin_fill()
move(offsetX, offsetY)
drawStar(size)
turtle.end_fill()
# 人工调节星星位置
drawFillStarByOffsetAndSize(-300, 150, 100)
drawFillStarByOffsetAndSize(-140, 250, 50)
drawFillStarByOffsetAndSize(-100, 180, 50)
drawFillStarByOffsetAndSize(-125, 100, 50)
drawFillStarByOffsetAndSize(-180, 30, 50)
turtle.done()
转载:https://blog.csdn.net/weixin_44517301/article/details/100598859
查看评论