使用turtle库绘制一个红色五角星图形

import math
import turtle

RADIUS = 100

angleSin18 = math.sin(math.pi * 0.1) * RADIUS
angleCos18 = math.cos(math.pi * 0.1) * RADIUS
angleSin54 = math.sin(math.pi * 0.3) * RADIUS
angleCos54 = math.cos(math.pi * 0.3) * RADIUS

turtle.width(1)

turtle.fillcolor("red")
turtle.begin_fill()
turtle.penup()
turtle.goto(-angleCos18, angleSin18)
turtle.pendown()

turtle.goto(angleCos18, angleSin18)

turtle.goto(-angleCos54, -angleSin54)

turtle.goto(0, RADIUS)

turtle.goto(angleCos54, -angleSin54)

turtle.goto(-angleCos18, angleSin18)
turtle.end_fill()

 

posted @ 2020-03-11 14:14  哦噢  阅读(1661)  评论(0编辑  收藏  举报