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 #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)), static_cast(dist(engine)), static_cast(dist(engine)) }; }

// 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 _color; };

// 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 screen;

// TODO - fade all of the pixels }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!