使用turtle庫繪制一個六角形,效果如下:


import turtle
turtle.setup(650,350,200,200)
turtle.penup()
turtle.pensize(1)
turtle.pencolor("red")
turtle.fillcolor("yellow")
turtle.fd(100)
turtle.seth(30)
turtle.pendown()
turtle.begin_fill()
turtle.fd(80)
turtle.seth(-90)
turtle.fd(80)
turtle.seth(150)
turtle.fd(80)
turtle.end_fill()
turtle.penup()
turtle.seth(30)
turtle.fd(80/3)
turtle.seth(90)
turtle.fd(80/3)
turtle.pendown()
turtle.begin_fill()
turtle.seth(-30)
turtle.fd(80)
turtle.seth(-150)
turtle.fd(80)
turtle.seth(90)
turtle.fd(80)
turtle.end_fill()

printer = turtle.Turtle()
printer.hideturtle()
printer.penup()
printer.back(200)
printer.write("           from 鄧浩宗", align="center", font=("楷體", 12, "normal"))

 


免責聲明!

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



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