使用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()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM