Question
#include #include using namespace std; class Pixel { public: Pixel() { random_device device; mt19937 engine(device()); uniform_int_distribution dist{ 0, UINT8_MAX }; _color = { static_cast (dist(engine)),
#include
class Pixel { public: Pixel() { random_device device; mt19937 engine(device()); uniform_int_distribution
_color = { static_cast
// TODO: add a public member function with signature 'void Fade()' // this method should divide the color values in half // i.e. if _color = {120, 230, 56}, then final _color = {60, 115, 28}
private: array
// A pixel holds color values as a three-component array where Red, Green, and Blue are stored // as individual components. The above class generates a randomly colored Pixel when it is // instantiated by randomly setting the Red, Green, and Blue values. In our class, we are using // a uint8_t to store the pixel value, so it will be an int between 0 and 255. // In some applications, it is useful to manipulate a pixel, for example, we may want to fade the // color by reducing the strength of each of the component values // OBJECTIVE: Add a public member function to the Pixel class with the signature: 'void Fade()'. // This function should reduce each of the individual components of _color by half. Then, in main // below, add code to call "Fade" on every pixel in the screen. int main() { // create an array of 1000 Pixel objects array
// TODO - fade all of the pixels }
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