Highlights
In this assignment, you will use turtle graphics to create an interactive forest drawing application.
Start by creating a module ‘utilities.py’ which should contain four drawing functions as listed below.
draw_triangle(centre_x, centre_y, width, height, pen_color, fill_color)
draw_rectangle(centre_x, centre_y, width, height, pen_color, fill_color)
draw_circle(centre_x, centre_y, radius, pen_color, fill_color)
stamp_turtle(centre_x, centre_y, color)
The parameter names are self explanatory. For example, the draw_triangle() function should draw an upwards pointing triangle with (centre_x, centre_y) located as shown in figure.
Additionally, the module should also contain these functions:
distance(x1, y1, x2, y2) – to find the Cartesian distance between two points (x1, y1) and (x2, y2)
save_state() and restore_state() – the former should save turtle’s important parameters (position, pen color, fill color) in global (module-level) variables. The latter function will reload the turtle’s state from those same variables. The four drawing functions listed above should call these save and restore functions before and after a drawing respectively so that turtle’s state is restored to the same values as it was before a drawing.
In your main file ‘forest.py’ you should import the utility module and call its functions to do all drawings. No direct drawing should be needed from the main file.
At the program start, you should disable all turtle animations and change the turtle’s icon to a bird shape (see sample code). Then the turtle should be hidden from view. Next, your program should implement the following requirements.
Create a large rectangle to represent the drawing boundary.
On top of the rectangle, draw two small circles and write text to let the user choose between a bird and tree drawing. When the program starts, the tree must be chosen by default.
Handle mouse clicks in the turtle window. Clicks within the drawing rectangle will draw a tree or bird depending on the user’s selection. Mouse clicks outside the drawing rectangle are ignored, except for those within the selection circles which switch the drawing mode from bird to tree.
Drawing a tree consists of drawing one vertical rectangle (stem) and three overlapped triangles (branches and leaves).
The bird, on the other hand, should be drawn using turtle stamping at the clicked point.
Tree size should change randomly. First, you will choose a reference size for tree components (stem rectangle and leave triangles). Then at the drawing time, generate a random value between 0.7 and 1.3 which will act as a scale factor so that individual trees can be shorter, equal to or bigger than the reference size.
When the bird mode is selected, the (bird-shaped) turtle becomes visible in the top left corner. When tree mode is selected, turtle hides again.
While the bird mode is selected, your program should respond to the left (?) and right (?) keyboard buttons. The user will press these buttons in order to change the turtle’s tilt angle. By changing the title angle, birds can be drawn in many different orientations.
This Computer Science Assignment has been solved by our Computer Science Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.