from turtle import * from math import sqrt from superturtledraw import * def draw_leaf(size, rcolor, gcolor, bcolor): pencolor('black') fillcolor((rcolor, gcolor, bcolor)) begin_fill() circle(size,90) right(270) circle(.75*size,90) circle(-.25*size,90) end_fill() def draw_leaves(rcolor, gcolor, bcolor): with restore_state_when_finished(): for number in range(11): draw_leaf(20, rcolor, gcolor, bcolor) penup() forward(10) right(115) pendown() def draw_branch_nl(size): angles = [165, 150, 150, 150, 150, 150, 150, 165, 105] for angle in angles: branch_end_nl(size) circle(size/8,angle) def draw_branch_wl(size, rcolor, gcolor, bcolor): angles = [165, 150, 150, 150, 150, 150, 150, 165, 105] for angle in angles: branch_end_wl(size, rcolor, gcolor, bcolor) circle(size/8,angle) draw_leaves(rcolor, gcolor, bcolor) def draw_turn(d1,a1,d2,a2,d3,a3,d4): forward(d1) right(a1) forward(d2) right(a2) forward(d3) right(a3) forward(d4) def tip_nl(size): draw_turn(size,45,size/10,90,size/10,45,size) def tip_wl(size, rcolor, gcolor, bcolor): tip_nl(size) draw_leaves(rcolor, gcolor, bcolor) def branching_nl(ang1, d1, ang2, d2, ang3): draw_turn(0,ang1,d1,ang2,d2,ang3,0) def branching_wl(ang1, d1, ang2, d2, ang3, rcolor, gcolor, bcolor): branching_nl(ang1, d1, ang2, d2, ang3) draw_leaves(rcolor, gcolor, bcolor) def branch_end_wl(size, rcolor, gcolor, bcolor): for number in range(3): forward(size) draw_leaves(rcolor, gcolor, bcolor) forward(size) right(300) tip_wl(size, rcolor, gcolor, bcolor) branching_wl(240,size,330,size,330, rcolor, gcolor, bcolor) tip_wl(size, rcolor, gcolor, bcolor) branching_wl(30,size,240,size,30, rcolor, gcolor, bcolor) tip_wl(size, rcolor, gcolor, bcolor) branching_wl(330,size,330,size,240, rcolor, gcolor, bcolor) tip_wl(size, rcolor, gcolor, bcolor) right(300) forward(4*size) def branch_end_nl(size): forward(4*size) right(300) tip_nl(size) branching_nl(240,size,330,size,330) tip_nl(size) branching_nl(30,size,240,size,30) tip_nl(size) branching_nl(330,size,330,size,240) tip_nl(size) right(300) forward(4*size) def draw_tree_nl(size): fillcolor('rosybrown4') begin_fill() circle(size/4,90) forward(10*size) circle(size/8,105) draw_branch_nl(size) forward(10*size) circle(size/4,90) end_fill() def draw_tree_wl(size, rcolor, gcolor, bcolor): penup() circle(size/4,90) forward(10*size) circle(size/8,105) draw_branch_wl(size, rcolor, gcolor, bcolor) forward(10*size) circle(size/4,90)