五星红旗

import turtle as t import math as m pi=3.1415926535 def star5(x,y,r): if x==-300: a=-pi/10 else: a=m.atan((y-150)/(x+300)) b=18+a/pi*180 x=x-m.cos(a)*r y=y-m.sin(a)*r s=m.sin(27/180*pi)/m.sin(135/180*pi)*r t.pu() t.goto(x,y) t.pd() t.left(b) t.begin_fill() for i in range(5): t.forward(s) t.left(72) t.forward(s) t.right(144) t.end_fill() t.left(-b) t.bgcolor('red') t.color('yellow') star5(-300,150,90) star5(-150,240,30) star5(-90,180,30) star5(-90,90,30) star5(-150,30,30) t.pensize(3) t.pu() t.goto(-450,300) t.pd() t.goto(450,300) t.goto(450,-300) t.goto(-450,-300) t.goto(-450,300)

posted @ 2025-03-09 11:15  黎孜  阅读(25)  评论(0)    收藏  举报