Answered step by step
Verified Expert Solution
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 You'll soon see why!
When the user clicks the mouse, the scene should be redrawn, with its brightness depending on the xcoordinate 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 drawscene that will draw your landscape. The function should have a parameter to determine the brightness a number from to of the different scene elements. Make sure to include a docstring with this function.
In your mouseClicked function, you can call drawscene passing in the xcoordinate of the mouse as its argument.
The output of your program might look like the following:
Figure : Landscape scene with full brigthness left and partial brightness right
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