學習Python 畫玫瑰花

2021-10-02 01:46:02 字數 3430 閱讀 9371

### 畫玫瑰花.py

import turtle as tt

### 定義曲線繪製函式

deffunccurve

(n, r, d=1)

:for i in

range

(n):

tt.left(d)

tt.circle(r,

abs(d)

)### 畫玫瑰花

deffuncmyrose()

:# 初始位置設定

floatsize =

0.2# size

tt.setup(

450*

5*floatsize,

750*

5*floatsize)

tt.pencolor(

"black"

) tt.fillcolor(

"red"

) tt.speed(

100)

tt.penup(

) tt.goto(0,

900*floatsize)

tt.pendown(

)# 繪製花朵形狀

tt.begin_fill(

) tt.circle(

200*floatsize,30)

funccurve(60,

50*floatsize)

tt.circle(

200*floatsize,30)

funccurve(4,

100*floatsize)

tt.circle(

200*floatsize,50)

funccurve(50,

50*floatsize)

tt.circle(

350*floatsize,65)

funccurve(40,

70*floatsize)

tt.circle(

150*floatsize,50)

funccurve(20,

50*floatsize,-1

) tt.circle(

400*floatsize,60)

funccurve(18,

50*floatsize)

tt.fd(

250*floatsize)

tt.right(

150)

tt.circle(

-500

*floatsize,12)

tt.left(

140)

tt.circle(

550*floatsize,

110)

tt.left(27)

tt.circle(

650*floatsize,

100)

tt.left(

130)

tt.circle(

-300

*floatsize,20)

tt.right(

123)

tt.circle(

220*floatsize,57)

tt.end_fill(

)# 繪製花枝形狀

tt.left(

120)

tt.fd(

280*floatsize)

tt.left(

115)

tt.circle(

300*floatsize,33)

tt.left(

180)

tt.circle(

-300

*floatsize,33)

funccurve(70,

225*floatsize,-1

) tt.circle(

350*floatsize,

104)

tt.left(90)

tt.circle(

200*floatsize,

105)

tt.circle(

-500

*floatsize,63)

tt.penup(

) tt.goto(

170*floatsize,-30

*floatsize)

tt.pendown(

) tt.left(

160)

funccurve(20,

2500

*floatsize)

funccurve(

220,

250*floatsize,-1

)# 繪製乙個綠色葉子

tt.fillcolor(

'green'

) tt.penup(

) tt.goto(

670*floatsize,

-180

*floatsize)

tt.pendown(

) tt.right(

140)

tt.begin_fill(

) tt.circle(

300*floatsize,

120)

tt.left(60)

tt.circle(

300*floatsize,

120)

tt.end_fill(

) tt.penup(

) tt.goto(

180*floatsize,

-550

*floatsize)

tt.pendown(

) tt.right(85)

tt.circle(

600*floatsize,40)

# 繪製另乙個綠色葉子

tt.penup(

) tt.goto(

-150

*floatsize,

-1000

*floatsize)

tt.pendown(

) tt.begin_fill(

) tt.rt(

120)

tt.circle(

300*floatsize,

115)

tt.left(75)

tt.circle(

300*floatsize,

100)

tt.end_fill(

) tt.penup(

) tt.goto(

430*floatsize,

-1070

*floatsize)

tt.pendown(

) tt.right(30)

tt.circle(

-600

*floatsize,35)

tt.done(

)

funcmyrose(

)

Python 玫瑰花繪製

設定初始位置 turtle.penup 提起畫筆 turtle.pensize 5 turtle.left 90 逆時針旋轉九十度 turtle.fd 200 向前移動一段距離 fd forward turtle.pendown 放下畫筆移動畫筆開始繪製 turtle.right 90 順時針旋轉九...

python玫瑰花數量的含義 玫瑰花數量代表的含義

1朵玫瑰代表 我的心中只有你 only you!2朵玫瑰代表 這世界只有我倆!3朵玫瑰代表 我愛你 i love you!4朵玫瑰代表 至死不渝!5朵玫瑰代表 由衷欣賞!6朵玫瑰代表 互敬 互愛 互諒!7朵玫瑰代表 我偷偷地愛著你!8朵玫瑰代表 感謝你的關懷扶持及鼓勵!9朵玫瑰代表 長久 alway...

python玫瑰花數量的含義 玫瑰花數量多少的含義

一 1朵玫瑰 1朵玫瑰花大多數是在剛剛相戀時贈送,1朵玫瑰花所代表的含義就是一見鐘情,或者是我的心中只有你乙個人。二 11朵玫瑰 11朵玫瑰花是很多人都經常選擇的玫瑰數量,通常是情侶之間表達愛意時送花,11朵玫瑰代表著一生一世,同時也是在向愛人表達 一生相伴,一世相隨 的美好愛情寓意。三 50朵玫瑰...