Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Background: As noted in the previous exercises, we can represent colors as RGB values. That is , as 3 integers representing the amount of red,
Background: As noted in the previous exercises, we can represent colors as RGB values. That is as integers representing the amount of red, green, and blue in the color. In this exercise, we will represent RGB values as digit integers, where the leftmost three digits represent red, the next three digits represent green, and the last three digits represent blue. Each of the red, green, and blue values are between and inclusive where is "entirely on and is "entirely off".
For example, the RGB values of orchid a purplish color are and We will represent that as the single integer
Note that the integer does not necessarily have to be nine digits, since it could contain leading zeroes. For example, if the RGB values are then we will represent that as the single integer
With this in mind, write the function blendColorsrgb rgb which takes two rgb values, and returns a new rgb value where the red, green, and blue are each halfway between the corresponding part of the two original colors. For Example, blendColors should return the value because is halfway between and is halfway between and and is halfway between and
Hint: Each of the red, green, and blue parts must be rounded to the nearest integer should be rounded up not kept as floats.
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