Question
# Import the functions from the Draw 2-D library # so that they can be used in this program. from draw2d import start_drawing, draw_line,
# Import the functions from the Draw 2-D library # so that they can be used in this program. from draw2d import \ start_drawing, draw_line, draw_oval, draw_arc, \ draw_rectangle, draw_polygon, draw_text, finish_drawing # Define functions to draw each object in the scene def draw_sky(canvas, x1, y1, x2, y2): draw_rectangle(canvas, x1, y1, x2, y2, fill_color='light blue') def draw_cloud(canvas, x, y): draw_oval(canvas, x, y, 50, 30, fill_color='white') def draw_ground(canvas, x1, y1, x2, y2): draw_rectangle(canvas, x1, y1, x2, y2, fill_color='green') # Start drawing on a canvas canvas = start_drawing() # Draw the sky draw_sky(canvas, 0, 0, canvas.width, canvas.height/2) # Draw clouds in the sky for i in range(5): draw_cloud(canvas, 50*i, 50) # Draw the ground draw_ground(canvas, 0, canvas.height/2, canvas.width, canvas.height) # Define additional functions to draw other objects in the scene def draw_tree(canvas, x, y): draw_rectangle(canvas, x, y, 30, 80, fill_color='brown') draw_polygon(canvas, [x-50, y, x, y-70, x+50, y], fill_color='green') def draw_bird(canvas, x, y): draw_oval(canvas, x, y, 20, 10, fill_color='yellow') draw_polygon(canvas, [x, y, x+10, y-10, x+20, y], fill_color='black') def draw_flower(canvas, x, y): draw_oval(canvas, x, y, 10, 10, fill_color='red') draw_oval(canvas, x-5, y-5, 5, 5, fill_color='yellow') # Draw trees and other objects in the scene for i in range(3): draw_tree(canvas, 100*i, canvas.height/2) for i in range(5): draw_bird(canvas, 50*i, 50) for i in range(10): draw_flower(canvas, 20*i, canvas.height/2+30) # Finish drawing on the canvas finish_drawing()
Here is my sample code. I am having an issue having my code run. Also, I need to add pine_tree using draw2d. Can you please assist?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started