Last active
August 29, 2015 14:03
-
-
Save renyuanL/b11b92e9596cd92bbb7a to your computer and use it in GitHub Desktop.
ryFractal_tree.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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