使用turtle庫畫一朵玫瑰花帶文字


參考鏈接:https://jingyan.baidu.com/article/d169e18689f309026611d8c8.html

https://blog.csdn.net/weixin_41939278/article/details/88342406

 

哈哈哈,這個自己就沒畫了,百度里面畫得挺好的,就直接用了吧。

效果圖:

 

#!/usr/bin/env python
# _*_ coding: UTF-8 _*_
"""=================================================
@Project -> File    : Operate_system_ModeView_structure -> rose.py
@IDE     : PyCharm
@Author  : zihan
@Date    : 2020/5/20 15:09
@Desc    :https://jingyan.baidu.com/article/d169e18689f309026611d8c8.html
================================================="""
import turtle as t


def main():
    # 設置初始位置
    t.penup()
    t.left(90)
    t.fd(200)
    t.pendown()
    t.right(90)

    # 花蕊
    t.fillcolor("red")
    t.begin_fill()
    t.circle(10, 180)
    t.circle(25, 110)
    t.left(50)
    t.circle(60, 45)
    t.circle(20, 170)
    t.right(24)
    t.fd(30)
    t.left(10)
    t.circle(30, 110)
    t.fd(20)
    t.left(40)
    t.circle(90, 70)
    t.circle(30, 150)
    t.right(30)
    t.fd(15)
    t.circle(80, 90)
    t.left(15)
    t.fd(45)
    t.right(165)
    t.fd(20)
    t.left(155)
    t.circle(150, 80)
    t.left(50)
    t.circle(150, 90)
    t.end_fill()

    # 畫第一片花瓣
    t.left(150)
    t.circle(-90, 70)
    t.left(20)
    t.circle(75, 105)
    t.setheading(60)
    t.circle(80, 98)
    t.circle(-90, 40)

    # 花瓣2
    t.left(180)
    t.circle(90, 40)
    t.circle(-80, 98)
    t.setheading(-83)

    # 第一片葉子
    t.fd(30)
    t.left(90)
    t.fd(25)
    t.left(45)
    t.fillcolor("green")
    t.begin_fill()
    t.circle(-80, 90)
    t.right(90)
    t.circle(-80, 90)
    t.end_fill()

    t.right(135)
    t.fd(60)
    t.left(180)
    t.fd(85)
    t.left(90)
    t.fd(80)

    # 第二片葉子
    t.right(90)
    t.right(45)
    t.fillcolor("green")
    t.begin_fill()
    t.circle(80, 90)
    t.left(90)
    t.circle(80, 90)
    t.end_fill()

    t.left(135)
    t.fd(60)
    t.left(180)
    t.fd(60)
    t.right(90)
    t.circle(200, 60)

    printer = t.Turtle()
    printer.hideturtle()
    printer.penup()
    printer.back(200)
    printer.write("So beautiful rose!\n\n", align="right", font=("楷體", 16, "bold"))

    t.exitonclick()


if __name__ == '__main__':
    main()

 

ok.


免責聲明!

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



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