I made a shapes.py file to keep my good shapes once I've finished them.

I made a draw_leaf function and put it into a shapes.py because I think
the leaf is pretty good. I started trying to draw the trunk / branches /
roots of the tree, but it's not finished so I didn't put it into
shapes.py yet.

It was easy to make the leaf, I used two 90 degree arcs and a straight
line between them equal to the chord length.
I was trying to make branches with more branches coming off of them,
but it was difficult to make the branches repeat the way I wanted to,
so I am now just trying some basic rods for the main branches, and then
once I figure out the loops for that I will figure out how to do loops
to make little branches off of the main branches.
This commit is contained in:
root 2024-09-21 22:33:06 -04:00
parent 4e07a15cb3
commit 8f1bc7512c
4 changed files with 73 additions and 2 deletions

View File

@ -16,6 +16,8 @@ image, move the image to this directory, and then use the following syntax:
For this project, I want to make an animated tree with the leaves changing color and falling down.
---I am adding this line so it lets me do a commit message.---
)
## Planning

Binary file not shown.

View File

@ -1,7 +1,67 @@
# drawing.py
# ----------
# By ____(you)___________
# By Stacy S
#
# (Briefly describe what this program does.)
# (Trying to draw a tree.)
from turtle import *
from math import sqrt
from shapes import draw_leaf
def draw_trunk(height):
right(270)
forward(2*height)
circle(-height/16,90)
def draw_branch(length):
forward(length)
circle(length/8,180)
forward(length)
circle(-length/16,135)
forward(length)
circle(length/8,180)
forward(length)
circle(-length/16,135)
forward(length)
circle(length/8,180)
forward(length)
circle(-length/16,135)
forward(length)
circle(length/8,180)
forward(length)
circle(-length/16,135)
forward(length)
circle(length/8,180)
forward(length)
circle(-length/16,90)
forward(2*length)
# roots
# [1,3,3,1]
circle(-length/16,45)
forward(length)
circle(length/8,180)
forward(length)
circle(-length/16,135)
forward(length)
circle(length/8,180)
forward(length)
circle(-length/16,135)
forward(length)
circle(length/8,180)
forward(length)
circle(-length/16,45)
input()

9
shapes.py Normal file
View File

@ -0,0 +1,9 @@
from turtle import *
from math import sqrt
def draw_leaf(size):
circle(size,90)
right(270)
circle(size,90)
right(225)
forward(size*sqrt(2))