如何用Python做成这个效果

 

import turtle as t
import math
 
rads=[200,160,120,80]
colors=['red','white','red','blue']

rad2s=80
color2s='white'
 
def init():
    t.shape("turtle")
    t.width(3)
 
#画笔定位子程序模块是画圆和画五角星模块都要调用到的
def set_pos(y):
    t.pu()
    t.sety(y)
    t.pd()
 
#drawCircle()画圆子程序模块
def draw_circle(c,r):
    t.color(c)
    t.begin_fill()
    t.circle(r)
    t.end_fill()
 
#画五角星子程序模块
def draw_fivestar(c,r):
    t.color(c)
    t.seth(-72) # 90-18=72 原理同前
    t.begin_fill()
    for i in range(5):
        t.fd(2*r*math.cos(18*math.pi/180)) # 2*80*cos(18)=152.2 原理同前  cos(18)=0.951
        t.right(144)
    t.end_fill()
 
#drawShield()画盾牌子程序模块
def drawShield():
    for i in range(4):
        set_pos(-rads[i])
        draw_circle(colors[i],rads[i])
 
    set_pos(rad2s)
    draw_fivestar(color2s,rad2s)
 
#采用“模块化”设计方案。if __name__=='__main__' 为主程序入口
if __name__=='__main__':
    #调用
    init()
    drawShield()
 
    #隐藏画笔
    t.ht() #t.hideturtle()的简写
    t.done()

我把上面那个回答改了一下,这样就和你要的图完全一样了

 

import turtle as t
import math
 
rads=[200,160,120,80]
colors=['red','white','red','blue']
 
 
rad2s=[80,40,20]
color2s=['white','yellow','red']
 
def init():
    t.shape("turtle")
    t.width(3)
 
#画笔定位子程序模块是画圆和画五角星模块都要调用到的
def set_pos(y):
    t.pu()
    t.sety(y)
    t.pd()
 
#drawCircle()画圆子程序模块
def draw_circle(c,r):
    t.color(c)
    t.begin_fill()
    t.circle(r)
    t.end_fill()
 
#画五角星子程序模块
def draw_fivestar(c,r):
    t.color(c)
    t.seth(-72) # 90-18=72 原理同前
    t.begin_fill()
    for i in range(5):
        t.fd(2*r*math.cos(18*math.pi/180)) # 2*80*cos(18)=152.2 原理同前  cos(18)=0.951
        t.right(144)
    t.end_fill()
 
#drawShield()画盾牌子程序模块
def drawShield():
    for i in range(4):
        set_pos(-rads[i])
        draw_circle(colors[i],rads[i])
 
    for i in range(3):
        set_pos(rad2s[i])
        draw_fivestar(color2s[i],rad2s[i])
 
#采用“模块化”设计方案。if __name__=='__main__' 为主程序入口
if __name__=='__main__':
    #调用
    init()
    drawShield()
 
    #隐藏画笔
    t.ht() #t.hideturtle()的简写
    t.done()

 

您的问题已经有小伙伴解答了,请点击【采纳】按钮,采纳帮您提供解决思路的答案,给回答的人一些鼓励哦~~

ps:开通问答VIP,享受5次/月 有问必答服务,了解详情↓↓↓

【电脑端】戳>>>  https://vip.csdn.net/askvip?utm_source=1146287632
【APP 】  戳>>>  https://mall.csdn.net/item/52471?utm_source=1146287632