Skip to content

Instantly share code, notes, and snippets.

@renyuanL
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renyuanL/b11b92e9596cd92bbb7a to your computer and use it in GitHub Desktop.
Save renyuanL/b11b92e9596cd92bbb7a to your computer and use it in GitHub Desktop.
ryFractal_tree.py
'''
ryFractal_tree.py
本程式需要中文龜模組 turtle_tc.py
https://github.com/renyuanL/pythonTurtleInChinese/blob/master/turtle_tc.py
呂仁園,2014/07/08
'''
from turtle_tc import *
寬度= 10
角度= 10
長度= 80
長度差= 10
速度(0) # 1: 慢, 10: 快, 0: 最快
def 畫樹(枝寬, 枝長):
if 枝長 <= 10: # 最終長度
return
else:
if 枝長 <= 20: # 綠枝長度
顏色(綠)
else:
顏色(紅)
筆大小(枝寬); 前進(枝長)
右轉(角度); 畫樹(枝寬 *0.8, 枝長 -長度差)
左轉(角度 *2); 畫樹(枝寬 *0.8, 枝長 -長度差)
右轉(角度); 後退(枝長); 顏色(紅)
提筆(); 左轉(90); 後退(200); 下筆();
畫樹(寬度, 長度)
進入主迴圈()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment