728x90
반응형
#나무 가지 그리기
import turtle as t
def branch(pos, angle, lenth, thick):
if lenth < 10 : return
t.penup() #위
t.goto(pos) # 그리기
t.pendown() #아래
t.setheading(angle) # 각도
t.pensize(thick) # 굵기
t.forward(lenth)
pos_new = t.pos() #재귀함수
branch(pos_new, angle+25, lenth*0.75, thick*0.75)
branch(pos_new, angle-15, lenth*0.8, thick*0.75)
t.hideturtle() #화살표 숨기기
t.speed(0) # 빠르게 그리기
t.setundobuffer(None)
t.tracer(10000,0) # 10000번 forward하고 나서 한번
branch((0, -700), 90,300, 30)
컬러 넣기 import colorsys (참조 : www.vagrearg.org/content/hsvrgb)
import colorsys
import math
hue = math.log10(lenth) * - 0.17 + 0.52
color = colorsys.hsv_to_rgb(hue, 0.7, 0.8)
t.pencolor(color)
- 최종 코드
728x90
반응형
'프로그래밍 > Python_AI(영상처리)' 카테고리의 다른 글
영상처리 사전지식 5 : File_Read, write(증가율 계산) (0) | 2020.12.02 |
---|---|
영상처리 사전지식 4 : numpy array (0) | 2020.12.02 |
영상처리 사전지식 3 : 이미지 처리 (matplolib, numpy, 가변/불변 함수) (0) | 2020.12.02 |
영상처리 사전지식 2 : PySimpleGUI 생성 (0) | 2020.12.02 |