首页 > 其他分享 >绘制正方形内嵌圆形

绘制正方形内嵌圆形

时间:2022-10-15 10:00:42浏览次数:43  
标签:内嵌 draw 50 正方形 forward 90 circle 绘制 left

image

基本方法:

import turtle as t
def draw():
    t.hideturtle()
    t.pensize(4)
    t.color("red")
    t.goto(50,0)
    t.seth(90)
    t.forward(50)
    t.left(90)
    t.forward(100)
    t.left(90)
    t.forward(100)
    t.left(90)
    t.forward(100)
    t.left(90)
    t.forward(50)

def draw_circle():
    t.begin_fill()
    t.hideturtle()
    t.pensize(4)
    l=50
    t.color("red")
    t.circle(l,360)
    t.fillcolor("yellow")
    t.end_fill()

draw()
draw_circle()



t.exitonclick() #turtle执行完后保留那个页面



image
image

用循环来实现

import turtle as t
def draw():
    t.hideturtle()
    t.pensize(4)
    t.color("red")
    t.forward(100)
    t.left(90)
def draw_circle():
    t.begin_fill()
    t.hideturtle()
    t.pensize(4)
    l=50
    t.color("red")
    t.circle(l,360)
    t.fillcolor("yellow")
    t.end_fill()

t.goto(50,0)
t.left(90)
t.back(50)
t.clear()
for i in range(4):
    draw()

t.seth(90)
t.forward(50)
draw_circle()



t.exitonclick() #turtle执行完后保留那个页面



image

标签:内嵌,draw,50,正方形,forward,90,circle,绘制,left
From: https://www.cnblogs.com/JK8395/p/16793613.html

相关文章