Answered step by step
Verified Expert Solution
Link Copied!

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 3 integers representing the amount of red, green, and blue in the color. In this exercise, we will represent RGB values as 9 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 0 and 255(inclusive), where 255 is "entirely on" and 0 is "entirely off".
For example, the RGB values of orchid (a purplish color) are 218,112, and 214. We will represent that as the single integer 218112214.
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 000,032,175, then we will represent that as the single integer 32175.
With this in mind, write the function blendColors(rgb1, rgb2), 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(204153050,104000152) should return the value 154077101 because 154 is halfway between 204 and 104,77 is halfway between 153 and 0, and 101 is halfway between 50 and 152.
Hint: Each of the red, green, and blue parts must be rounded to the nearest integer (0.5 should be rounded up), not kept as floats.

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What are our strategic aims?pg 87

Answered: 1 week ago