Question: In this task you will be creating an image to display game stats such as electricity and health. 4 Your program should take several inputs
In this task you will be creating an image to display game stats such as electricity and health.
Your program should take several inputs from the user:
Current value: an integer representing the current value of this stat
Max value: the integer maximum value that this stat can take
Colour: a whitespaceseparated sequence of integers representing an rgba colour red green, blue, alpha The alpha channel determines the opacitytransparency of the colour.
Icon filename: the location of the icon file eg heart.png
Output filename: the filename of where to save the image you create. You may assume that inputs are correctly formatted and valid eg input files exist, the user inputs valid digits when asked for a value, output filename has a valid path
For this task you should use the PIL.Image library that you learnt about in worksheet
The image you create should have a transparent background use "RGBA" mode and initialise the background colour to and be exactly wide enough to fit the components you will need to calculate the appropriate width and height
The icon will be a x pixel image that should be copied on to the left of the bar, with a margin of pixels on each side.
The coloured part of bar will have a height of pixels and a width of pixels for each unit it represents. The colour of this part of the bar is the colour tuple passed in to the function.
There should be a pixel wide black border around the maximally filled bar.
For this task you will write a program that asks the user for input. You may define functions, but make sure to call them. You may ignore a PEP warning about Line : N camelcase 'PIL.Image' imported as lowercase 'pim' if one occurs, but should fix issues from any other warnings.
Examples
When given input like this:
Current value:
Max value:
Colour:
Icon filename: heart.png
Output filename: healthbar.png
Your program should produce this image:
healthbar.png
The health bar that the function should output
Note the transparent background of the png
When given input like this:
Current value:
Max value:
Colour:
Icon filename: lightning.png
Output filename: electricitybar.png
Your program should produce this image:
electricitybar.png
The electricity bar that the function should output
When given input like this:
Current value:
Max value:
Colour:
Icon filename: heart.png
Output filename: healthbarpng
Your program should produce this image:
healthbarpng
The health bar that the function should output
Watch for transparency of the colour input!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
