心血来潮突然想用python画一面五星红旗,由于我对程序的掌握还不是特别全面不知道怎么缩短,所以代码比较多,还有五角星的代码也是参考其他人的。整个程序都是以坐标绘图为主是比较基础的,还有五角星也是。以下是原代码,可以直接食用
import turtle
turtle.fillcolor("red")
turtle.begin_fill()
turtle.penup()
turtle.goto(-60,0)
turtle.pendown()
turtle.goto(-60,160)
turtle.goto(240,160)
turtle.goto(240,0)
turtle.goto(-60,0)
turtle.end_fill()
import turtle
turtle.penup()
turtle.goto(-50,110)
turtle.fillcolor("yellow")
turtle.begin_fill()
count = 1
while count <= 5:
turtle.forward(45)
turtle.right(144)
count += 1
turtle.end_fill()
import turtle
turtle.penup()
turtle.goto(-10,145)
turtle.fillcolor("yellow")
turtle.begin_fill()
count = 1
while count <= 5:
turtle.forward(20)
turtle.right(144)
count += 1
turtle.end_fill()
import turtle
turtle.penup
turtle.goto(10,120)
turtle.fillcolor("yellow")
turtle.begin_fill()
count = 1
while count <= 5:
turtle.forward(20)
turtle.right(144)
count += 1
turtle.end_fill()
import turtle
turtle.penup()
turtle.goto(10,95)
turtle.fillcolor("yellow")
turtle.begin_fill()
count = 1
while count <= 5:
turtle.forward(20)
turtle.right(144)
count += 1
turtle.end_fill()
import turtle
turtle.up()
turtle.goto(-10,70)
turtle.fillcolor("yellow")
turtle.begin_fill()
count = 1
while count <= 5:
turtle.forward(20)
turtle.right(144)
count += 1
turtle.end_fill()
import turtle
turtle.fillcolor("grey")
turtle.begin_fill()
turtle.penup()
turtle.goto(-60,170)
turtle.pendown()
turtle.goto(-70,170)
turtle.goto(-70,-450)
turtle.goto(-60,-450)
turtle.goto(-60,170)
turtle.end_fill()
import turtle
turtle.fillcolor("grey")
turtle.begin_fill()
turtle.penup()
turtle.goto(-65,170)
turtle.pendown()
turtle.circle(10)
turtle.end_fill()
效果还是挺好的,手已经残了就不加说明注释了