Python绘图Turtle库详解情人节玫瑰花
生活随笔
收集整理的這篇文章主要介紹了
Python绘图Turtle库详解情人节玫瑰花
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
https://blog.csdn.net/zengxiantao1994/article/details/76588580
(https://mp.weixin.qq.com/s/80bGWMuzg5VwDls87FCrJQ)
from turtle import * # 導入海龜模塊 import time setup(600,800,0,0) # 畫布(寬,高,矩形窗口左上角頂點的位置,為空則表示窗口位于屏幕中心) speed(0) # 設置畫筆移動速度,畫筆繪制的速度范圍[0,10]整數,數字越大越快 penup() # 提起筆移動,不繪制圖形,用于另起一個地方繪制 seth(90) # 設置當前朝向為angle角度 fd(340) # forward(distance) 向當前畫筆方向移動distance像素長度 seth(0) pendown() # 移動時繪制圖形,缺省時也為繪制speed(5) begin_fill() # 準本填充圖形 fillcolor('red') # 繪制圖形的填充顏色 circle(50,30) # 畫圓,半徑為正(負),表示圓心在畫筆的左邊(右邊)畫圓for i in range(10):fd(1)left(10) # left(degree)逆時針移動degreecircle(40,40)for i in range(6):fd(1)left(3)circle(80,40)for i in range(20):fd(0.5)left(5)circle(80,45)for i in range(10):fd(2)left(1)circle(80,25)for i in range(20):fd(1)left(4)circle(50,50)time.sleep(0.1) # 沉睡0.1秒circle(120,55)speed(0)seth(-90) fd(70)right(150) fd(20)left(140) circle(140,90)left(30) circle(160,100)left(130) fd(25)penup() right(150) circle(40,80) pendown()left(115) fd(60)penup() left(180) fd(60) pendown()end_fill()right(120) circle(-50,50) circle(-20,90)speed(1) fd(75)speed(0) circle(90,110)penup() left(162) fd(185) left(170) pendown() circle(200,10) circle(100,40) circle(-52,115) left(20) circle(100,20) circle(300,20) speed(1) fd(250)penup() speed(0) left(180) fd(250) circle(-300,7) right(80) circle(200,5) pendown()left(60) begin_fill() fillcolor('green') circle(-80,100) right(90) fd(10) left(20) circle(-63,127) end_fill()penup() left(50) fd(20) left(180)pendown() circle(200,25)penup() right(150)fd(180)right(40) pendown() begin_fill() fillcolor('green') circle(-100,80) right(150) fd(10) left(60) circle(-80,98) end_fill()penup() left(60) fd(13) left(180)pendown() speed(1) circle(-200,23)exitonclick() from turtle import * import timesetup(600,800,0,0) speed(0) penup() seth(90) fd(340) seth(0) pendown()speed(5) begin_fill() fillcolor('red') circle(50,30)for i in range(10):fd(1)left(10)circle(40,40)for i in range(6):fd(1)left(3)circle(80,40)for i in range(20):fd(0.5)left(5)circle(80,45)for i in range(10):fd(2)left(1)circle(80,25)for i in range(20):fd(1)left(4)circle(50,50)time.sleep(0.1)circle(120,55)speed(0)seth(-90) fd(70)right(150) fd(20)left(140) circle(140,90)left(30) circle(160,100)left(130) fd(25)penup() right(150) circle(40,80) pendown()left(115) fd(60)penup() left(180) fd(60) pendown()end_fill()right(120) circle(-50,50) circle(-20,90)speed(1) fd(75)speed(0) circle(90,110)penup() left(162) fd(185) left(170) pendown() circle(200,10) circle(100,40) circle(-52,115) left(20) circle(100,20) circle(300,20) speed(1) fd(250)penup() speed(0) left(180) fd(250) circle(-300,7) right(80) circle(200,5) pendown()left(60) begin_fill() fillcolor('green') circle(-80,100) right(90) fd(10) left(20) circle(-63,127) end_fill()penup() left(50) fd(20) left(180)pendown() circle(200,25)penup() right(150)fd(180)right(40) pendown() begin_fill() fillcolor('green') circle(-100,80) right(150) fd(10) left(60) circle(-80,98) end_fill()penup() left(60) fd(13) left(180)pendown() speed(1) circle(-200,23)exitonclick()總結
以上是生活随笔為你收集整理的Python绘图Turtle库详解情人节玫瑰花的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HPA控制器介绍以及实战案例
- 下一篇: 总结:K8s之HPA