查看全部 #每日一题#-基础-124按需绘制图形
-
阅读:527 回复:2 2022-11-30 12:58:31
-
import turtle as t
t.setup(900,900)
t.speed(100)
t.penup()
t.pencolor("red")
t.pensize(3)
'''x中间'''
#正方形左
for i in range(3):
t.goto(-300+200*i,0)
t.pendown()
t.setheading(45)
for x in range(4):
t.forward(50)
t.right(90)
t.penup()
#正方形右
for i in range(3):
t.goto(300-200*i,0)
t.pendown()
t.setheading(135)
for x in range(4):
t.forward(50)
t.left(90)
t.penup()
#圆形
for h in range(7):
t.goto(-290+100*h,10)#first
t.pendown()
t.fillcolor('yellow')
t.begin_fill()
t.circle(15,360)
t.end_fill()
t.penup()
'''靠近中'''
#正方形左
for z in range(2):
for i in range(3):
t.goto(-265+200*i,70-140*z+50*z)
t.pendown()
t.setheading(0)
for x in range(4):
t.forward(50)
t.right(90)
t.penup()
#圆形
for h in range(3):
t.goto(-265+200*h,60-120*z)#first
t.pendown()
t.fillcolor('yellow')
t.begin_fill()
t.circle(15-30*z,360)
t.end_fill()
t.penup()
#正方形右
for i in range(3):
t.goto(265-200*i,70-140*z+50*z)
t.pendown()
t.setheading(180)
for x in range(4):
t.forward(50)
t.left(90)
t.penup()
#圆形
for h in range(3):
t.goto(265-200*h,60-120*z)#first
t.pendown()
t.fillcolor('yellow')
t.begin_fill()
t.circle(-15+30*z,360)
t.end_fill()
t.penup()
'''上左'''
t.goto(-65,70)
#正方形2
for z in range(2):
for i in range(1,3):
t.goto(-65,(70+100*i)*(-1)**z)
t.pendown()
t.setheading(0)
for x in range(4):
t.forward(50)
t.right(90*(-1)**z)
t.penup()
#圆形
for i in range(2):
t.goto(-65,(260-150*i)*(-1)**z)
t.pendown()
t.fillcolor('yellow')
t.begin_fill()
t.circle(15*(-1)**z,360)
t.end_fill()
t.penup()
#正方形+圆
t.goto(-100,0)
for y in range(2):
t.goto(-100,195*(-1)**y)
t.pendown()
t.setheading(45)
for x in range(4):
t.forward(50)
t.right(90)
t.penup()
t.goto(-90,180*(-1)**y)
t.pendown()
t.setheading(0)
t.fillcolor('yellow')
t.begin_fill()
t.circle(15*(-1)**y,360)
t.end_fill()
t.penup()
'''上右'''
t.goto(65,70)
#正方形2
for z in range(2):
for i in range(1,3):
t.goto(65,(70+100*i)*(-1)**z)
t.pendown()
t.setheading(180)
for x in range(4):
t.forward(50)
t.left(90*(-1)**z)
t.penup()
#圆形
for i in range(2):
t.goto(65,(260-150*i)*(-1)**z)
t.pendown()
t.fillcolor('yellow')
t.begin_fill()
t.circle(15*(-1)**(z+1),360)
t.end_fill()
t.penup()
#正方形+圆
t.goto(100,0)
for y in range(2):
t.goto(100,195*(-1)**y)
t.pendown()
t.setheading(135)
for x in range(4):
t.forward(50)
t.left(90)
t.penup()
t.goto(90,180*(-1)**y)
t.pendown()
t.setheading(0)
t.fillcolor('yellow')
t.begin_fill()
t.circle(15*(-1)**(y),360)
t.end_fill()
t.penup()
'''y中间'''
#正方形下
for i in range(3):
t.goto(0,-300+200*i)
t.pendown()
t.setheading(135)
for x in range(4):
t.forward(50)
t.right(90)
t.penup()
#正方形上
for i in range(3):
t.goto(0,300-200*i)
t.pendown()
t.setheading(-45)
for x in range(4):
t.forward(50)
t.right(90)
t.penup()
#圆形
for h in range(7):
t.goto(10,-290+100*h)#first
t.pendown()
t.fillcolor('yellow')
t.begin_fill()
t.circle(-15,360)
t.end_fill()
t.penup()
'''中左'''
#正方形+圆
t.goto(-200,100)
for y in range(2):
t.goto(-200,100*(-1)**y)
t.pendown()
t.setheading(-45+180*y)
for x in range(4):
t.forward(50)
t.right(90)
t.penup()
t.goto(-200,90*(-1)**y)
t.pendown()
t.setheading(0)
t.fillcolor('yellow')
t.begin_fill()
t.circle(15*(-1)**y,360)
t.end_fill()
t.penup()
'''中右'''
#正方形+圆
t.goto(200,100)
for y in range(2):
t.goto(200,100*(-1)**y)
t.pendown()
t.setheading(-45+180*y)
for x in range(4):
t.forward(50)
t.right(90)
t.penup()
t.goto(200,90*(-1)**y)
t.pendown()
t.setheading(0)
t.fillcolor('yellow')
t.begin_fill()
t.circle(15*(-1)**y,360)
t.end_fill()
t.penup()
2022-12-01 08:51:10