Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON PROGRAMMING drawTree() : draws a tree comprised of only rectangles and triangles (as shown above) using the basic shape functions from lab03 drawForest(): draws

PYTHON PROGRAMMING

drawTree() : draws a tree comprised of only rectangles and triangles (as shown above) using the basic shape functions from lab03

drawForest(): draws a row of trees with different shades of green placed randomly along a row

drawHut(): draws a hut (as shown above) comprising only of rectangles reusing the basic rectangle function from lab03

drawVillage(): draws a collection of huts placed randomly along a row

drawScene(): draws the final scene as shown above using the drawForest() and drawVillage()

functions functions from lab3:

import turtle

import math

def drawRectangle(t, width, height, tilt, penColor, fillColor):

t.color(penColor, fillColor)

t.begin_fill()

t.seth(tilt)

t.forward(width)

t.left(90)

t.forward(height)

t.left(90)

t.forward(width)

t.left(90)

t.forward(height)

t.end_fill()

t.seth(0)

def drawTriangle(t, base, height, penColor, fillColor):

t.begin_fill()

t.color(penColor, fillColor)

t.forward(base)

turnAngle = 180 - math.degrees(math.atan2(height,base/2))

t.left(turnAngle)

side = math.sqrt((base/2)**2 +(height**2))

t.forward(side)

t.left(2*(180-turnAngle))

t.forward(side)

t.seth(0)

t.end_fill()

if __name__=="__main__":

jane = turtle.Turtle()

jane.shape("turtle")

jane.speed(0)

jane.width(8)

drawTriangle(jane, 100, 200, "blue", "green")

jane.getscreen().exitonclick()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions