用Python的turtle庫畫玫瑰
參考文章:
(3條消息) 情人節用Python畫玫瑰花_python小廣的博客-CSDN博客_用python畫玫瑰花https://blog.csdn.net/qq_45723275/article/details/122788685?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165961175516782390568033%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=165961175516782390568033&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-25-122788685-null-null.142^v39^control&utm_term=%E7%94%A8python%E7%94%BB%E7%8E%AB%E7%91%B0%E8%8A%B1&spm=1018.2226.3001.4187(3條消息) 用python畫一個心形_python怎麼畫愛心_發現廚房的博客-CSDN博客https://blog.csdn.net/weixin_35067976/article/details/112052775?ops_request_misc=&request_id=&biz_id=102&utm_term=Python%20%E5%BF%83%E5%BD%A2&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-2-112052775.142^v39^control&spm=1018.2226.3001.4187效果圖:
import turtle
#設置速度
turtle.speed(10)#速度
turtle.delay(1)#延遲
turtle.setup(1100,800)#設置畫布大小
#畫玫瑰
turtle.penup()
turtle.goto(400,-550)
turtle.pensize(5)
turtle.pencolor("black")
turtle.seth(140)
turtle.pendown()
turtle.circle(-400,60)
turtle.fd(100)
turtle.seth(10)
turtle.fd(50)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.right(40)
turtle.circle(120,80)
turtle.left(100)
turtle.circle(120,80)
turtle.end_fill()
turtle.seth(10)
turtle.fd(90)
turtle.penup()
turtle.fd(-140)
turtle.seth(80)
turtle.pendown()
turtle.fd(70)
turtle.seth(160)
turtle.fd(50)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.right(40)
turtle.circle(120,80)
turtle.left(100)
turtle.circle(120,80)
turtle.end_fill()
turtle.seth(160)
turtle.fd(90)
turtle.penup()
turtle.fd(-140)
turtle.seth(80)
turtle.pendown()
turtle.fd(100)
turtle.seth(-20)
turtle.fillcolor("crimson")
turtle.begin_fill()
turtle.circle(100,100)
turtle.circle(-110,70)
turtle.seth(179)
turtle.circle(223,76)
turtle.end_fill()
turtle.fillcolor("red")
turtle.begin_fill()
turtle.left(180)
turtle.circle(-223,60)
turtle.seth(70)
turtle.circle(-213,15)#55
turtle.left(70)#125
turtle.circle(200,70)
turtle.seth(-80)
turtle.circle(-170,40)
turtle.circle(124,94)
turtle.end_fill()
turtle.penup()
turtle.right(180)
turtle.circle(-124,94)
turtle.circle(170,40)
turtle.pendown()
turtle.seth(-60)
turtle.circle(175,70)
turtle.seth(235)
turtle.circle(300,12)
turtle.right(180)
turtle.circle(-300,12)
turtle.seth(125)
turtle.circle(150,60)
turtle.seth(70)
turtle.fd(-20)
turtle.fd(20)
turtle.seth(-45)
turtle.circle(150,40)
turtle.seth(66)
turtle.fd(-18.5)
turtle.fd(18.5)
turtle.seth(140)
turtle.circle(150,27)
turtle.seth(60)
turtle.fd(-8)
turtle.penup()
turtle.left(20.8)
turtle.fd(-250.5)
turtle.pendown()
turtle.fillcolor("crimson")
turtle.begin_fill()
turtle.seth(160)
turtle.circle(-140,85)
turtle.circle(100,70)
turtle.right(165)
turtle.circle(-200,32)
turtle.seth(-105)
turtle.circle(-170,14.5)
turtle.circle(123,94)
turtle.end_fill()
#畫心形
turtle.pencolor('red')
turtle.fillcolor('pink')
turtle.penup()
turtle.goto(-200,60)
turtle.pendown()
turtle.begin_fill()
turtle.left(90)
turtle.circle(120,180)
turtle.circle(360,70)
turtle.left(38)
turtle.circle(360,70)
turtle.circle(120,180)
turtle.end_fill()
#寫字
turtle.penup()
turtle.goto(-400,-50)
turtle.pendown()
turtle.color("black")
turtle.write("七夕快樂!",font=('Arial',50,'normal'))
turtle.hideturtle()
turtle.done()