Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

=+associated with political parties and if so, which ones? Are

Answered: 1 week ago