我是新人,最近在学习python,想记录下自己的学习体会,留存备忘。与大家共勉。
在十一国庆前夕,学习python的turtle绘图体系,按照我理解的标准的国旗画法,画了一个国旗。横线、竖线、五个星星的连线为辅助线,用于定位,可以注释掉。
在这里插入代码片
import turtle as t
import math as m
t.setup(960,640,10,10)
t.bgcolor("red")
t.pencolor("blue")
t.speed(10)
# 画横线
t.penup()
for i in range(10):
t.goto(-480,288-i*32)
t.pendown()
t.fd(480)
t.penup()
# 画竖线
t.penup()
t.seth(-90)
for i in range(15):
t.goto(-448+i*32,320)
t.pendown()
t.fd(320)
t.penup()
# 画五个星星连线
t.speed(10)
t.pencolor("white")
t.goto(-32*10,32*5)
t.pendown()
t.goto(-32*5,32*8)
t.penup()
t.goto(-32*10,32*5)
t.pendown()
t.goto(-32*3,32*6)
t.penup()
t.goto(-32*10,32*5)
t.pendown()
t.goto(-32*3,32*3)
t.penup()
t.goto(-32*10,32*5)
t.pendown()
t.goto(-32*5,32*1)
t.penup()
t.clear()
# 画大五角星
t.penup()
t.pencolor("yellow")
t.fillcolor("yellow")
t.goto(-32*10,32*5)
t.pendown()
t.seth(90)
t.fd(96)
t.ri