generated from mwc/project_drawing
I made a python program file with the superturtle functions I needed,
because I couldn't figure out how to get superturtle to import right. I also added the leaves in, added a branch because the leaves didn't look thick enough, and then I colored in the leaves and the trunk. I'm not sure if it was the best way to do it, but I couldn't figure out how to color in the woody part of the tree and the leaves at first (I was trying to do like nested fillcolors, but only the leaves would color in still), so I duplicated all of the tree drawing functions and made one without leaves and one with leaves, and I colored in the wood in the former, and colored in the leaves in the latter.
This commit is contained in:
102
shapes.py
102
shapes.py
@@ -1,23 +1,53 @@
|
||||
from turtle import *
|
||||
from math import sqrt
|
||||
from superturt import *
|
||||
|
||||
def draw_leaf(size):
|
||||
pencolor('black')
|
||||
fillcolor('green')
|
||||
begin_fill()
|
||||
circle(size,90)
|
||||
right(270)
|
||||
circle(.75*size,90)
|
||||
circle(-.25*size,90)
|
||||
end_fill()
|
||||
|
||||
def draw_leaves():
|
||||
with restore_state_when_finished():
|
||||
for number in range(11):
|
||||
draw_leaf(20)
|
||||
penup()
|
||||
forward(10)
|
||||
right(115)
|
||||
pendown()
|
||||
|
||||
def draw_trunk(size):
|
||||
forward(10*size)
|
||||
circle(size/8,90)
|
||||
|
||||
def draw_branch(size):
|
||||
angles = [135, 135, 135, 135, 90]
|
||||
def draw_branch_nl(size):
|
||||
angles = [150, 150, 150, 150, 150, 150, 90]
|
||||
for angle in angles:
|
||||
branch_end(size)
|
||||
branch_end_nl(size)
|
||||
circle(size/8,angle)
|
||||
|
||||
def tip(size):
|
||||
def draw_branch_wl(size):
|
||||
angles = [150, 150, 150, 150, 150, 150, 90]
|
||||
for angle in angles:
|
||||
branch_end_wl(size)
|
||||
circle(size/8,angle)
|
||||
draw_leaves()
|
||||
|
||||
def tip_nl(size):
|
||||
forward(size)
|
||||
right(45)
|
||||
forward(size/10)
|
||||
right(90)
|
||||
forward(size/10)
|
||||
right(45)
|
||||
forward(size)
|
||||
|
||||
def tip_wl(size):
|
||||
forward(size)
|
||||
right(45)
|
||||
forward(size/10)
|
||||
@@ -25,32 +55,70 @@ def tip(size):
|
||||
forward(size/10)
|
||||
right(45)
|
||||
forward(size)
|
||||
draw_leaves()
|
||||
|
||||
def branching(ang1, d1, ang2, d2, ang3):
|
||||
def branching_nl(ang1, d1, ang2, d2, ang3):
|
||||
right(ang1)
|
||||
forward(d1)
|
||||
right(ang2)
|
||||
forward(d2)
|
||||
right(ang3)
|
||||
|
||||
def branch_end(size):
|
||||
forward(4*size)
|
||||
def branching_wl(ang1, d1, ang2, d2, ang3):
|
||||
right(ang1)
|
||||
forward(d1)
|
||||
right(ang2)
|
||||
forward(d2)
|
||||
right(ang3)
|
||||
draw_leaves()
|
||||
|
||||
def branch_end_wl(size):
|
||||
for number in range(3):
|
||||
forward(size)
|
||||
draw_leaves()
|
||||
forward(size)
|
||||
right(300)
|
||||
tip(size)
|
||||
branching(240,size,330,size,330)
|
||||
tip(size)
|
||||
branching(30,size,240,size,30)
|
||||
tip(size)
|
||||
branching(330,size,330,size,240)
|
||||
tip(size)
|
||||
tip_wl(size)
|
||||
branching_wl(240,size,330,size,330)
|
||||
tip_wl(size)
|
||||
branching_wl(30,size,240,size,30)
|
||||
tip_wl(size)
|
||||
branching_wl(330,size,330,size,240)
|
||||
tip_wl(size)
|
||||
right(300)
|
||||
forward(4*size)
|
||||
|
||||
def draw_tree(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('brown')
|
||||
begin_fill()
|
||||
circle(size/4,90)
|
||||
draw_trunk(size)
|
||||
draw_branch(size)
|
||||
draw_branch_nl(size)
|
||||
forward(10*size)
|
||||
circle(size/4,90)
|
||||
right(180)
|
||||
forward(2*size)
|
||||
end_fill()
|
||||
|
||||
|
||||
def draw_tree_wl(size):
|
||||
penup()
|
||||
circle(size/4,90)
|
||||
draw_trunk(size)
|
||||
draw_branch_wl(size)
|
||||
forward(10*size)
|
||||
circle(size/4,90)
|
||||
right(180)
|
||||
forward(2*size)
|
||||
Reference in New Issue
Block a user