Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Adjusting the brigthness of a computer screen is a common task. For this question, you'll write a program that allows the user to adjust the

Adjusting the brigthness of a computer screen is a common task. For this question, you'll write a program that allows the user to adjust the brightness of a simple landscape scene by clicking on the canvas.
When your program starts, it should display a scene with the following elements on the canvas:
A blue sky
A green field (or ground)
A red mountain
A yellow sun
An instructions bar (depicting how to adjust the brightness)
Normally, you can use a canvas size of whatever you like, but for this question, set the width of the canvas to 255. You'll soon see why!
When the user clicks the mouse, the scene should be redrawn, with its brightness depending on the x-coordinate of the mouse. Thus if the mouse is clicked close to the right edge of the canvas, a bright scene should be drawn. If the mouse is clicked closer to the left edge, the whole scene will be darker. Note however that the brigthness of the instruction bar at the bottom should always be the same, no matter where the mouse is clicked.
To achieve this, define a function called draw_scene () that will draw your landscape. The function should have a parameter to determine the brightness (a number from 0 to 255) of the different scene elements. Make sure to include a docstring with this function.
In your mouseClicked() function, you can call draw_scene(), passing in the x-coordinate of the mouse as its argument.
The output of your program might look like the following:
Figure 2: Landscape scene with full brigthness (left) and partial brightness (right)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions