python turtle工具繪制四葉草的實例分享
更新時間:2020年02月14日 10:59:13 作者:unlock1835
在本篇文章里小編給各位整理的是關(guān)于python turtle工具繪制四葉草的實例分享,有興趣的朋友們可以跟著學(xué)習(xí)下。
本篇文章介紹了python使用turtle庫繪制四葉草的方法,代碼很簡單,希望對學(xué)習(xí)python的朋友有幫助。
import turtle import time turtle.setup(650.,350,200,200) turtle.pendown() turtle.pensize(10) turtle.pencolor('green') #四葉草 def draw_clover(radius,rotate): #參數(shù)radius控制葉子的大小,rotate控制葉子的旋轉(zhuǎn) for i in range(4): direction = i*90 turtle.seth(60+direction+rotate) #控制葉子根部的角度為60度 # turtle.fd(2*radius*pow(2,1/2)) #控制葉子根部的角度為90度 turtle.fd(4*radius) for j in range(2): turtle.seth(90+direction+rotate) turtle.circle(radius,180) turtle.seth(-60+direction+rotate) turtle.fd(4*radius) turtle.seth(-90) turtle.fd(6*radius) draw_clover(30,45) time.sleep(5)
內(nèi)容擴展
import turtle def draw_shapes(): window = turtle.Screen() window.bgcolor("red") flower = turtle.Turtle() flower.speed(10) flower.shape("arrow") flower.right(45) for i in range(1,37): for j in range(1,5): draw_circle(flower,i,"green") flower.left(90) flower.right(45) flower.color("green") flower.forward(500) window.exitonclick() def draw_circle(circle,radius,color): circle.color(color) circle.circle(radius) draw_shapes()
以上就是python繪圖四葉草的詳細內(nèi)容,感謝大家的學(xué)習(xí)和對腳本之家的支持。
您可能感興趣的文章:
- Python使用turtle模塊繪制愛心圖案
- Python繪圖之turtle庫的基礎(chǔ)語法使用
- Python turtle實現(xiàn)貪吃蛇游戲
- python基于turtle繪制幾何圖形
- Python趣味挑戰(zhàn)之turtle庫繪畫飄落的銀杏樹
- 教你利用Python+Turtle繪制簡易版愛心表白
- 關(guān)于Python turtle庫使用時坐標(biāo)的確定方法
- 使用python圖形模塊turtle庫繪制櫻花、玫瑰、圣誕樹代碼實例
- 使用python的turtle函數(shù)繪制一個滑稽表情
- Python如何使用turtle庫繪制圖形
- python使用turtle庫繪制奧運五環(huán)
- 解決Python3.8用pip安裝turtle-0.0.2出現(xiàn)錯誤問題
- python使用Turtle庫畫畫寫名字
相關(guān)文章
python 利用百度API進行淘寶評論關(guān)鍵詞提取
這篇文章主要介紹了python 利用百度API進行淘寶評論關(guān)鍵詞提取,幫助大家更好的理解和學(xué)習(xí)使用python,感興趣的朋友可以了解下2021-03-03解決python遞歸函數(shù)及遞歸次數(shù)受到限制的問題
這篇文章主要介紹了解決python遞歸函數(shù)及遞歸次數(shù)受到限制的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-06-06pandas使用apply多列生成一列數(shù)據(jù)的實例
今天小編就為大家分享一篇pandas使用apply多列生成一列數(shù)據(jù)的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-11-11