/*
* File: Color.cpp
* Author: Sam
*
* Created on 26 March, 2017, 3:50 PM
*/
#include <iostream>
using namespace::std;
class Color {
private:
int red,green,blue;
public:
int GetBlue() const { //Getter
return blue;
}
void SetBlue(int B) { //Setter
this->blue = B;
}
int GetGreen() const { //Getter
return green;
}
void SetGreen(int G) { //Setter
this->green =
G;
}
int GetRed() const { //Getter
return red;
}
void SetRed(int R) { //Setter
this->red = R;
}
Color(int R, int G, int B) : //param
constructor
blue(B), green(G), red(R) {
}
Color() { //default constructor
blue = red = green =
0;
}
Color(const Color& other) : //Copy
constructor
red(other.red), green(other.green),
blue(other.blue) {
}
void Print() { //to print
cout<<"R =
"<<red<<endl;
cout<<"G =
"<<green<<endl;
cout<<"B =
"<<blue<<endl;
}
void IncrementAll() {
red++; //Increase R G
B
green++;
blue++;
if(red>255) //If they
cross their limit, set to max
red=255;
if(green>255)
green=255;
if(blue>255)
blue=255;
}
void addColor(const Color& other){ //Add
another color
red =
red+other.red;
green =
green+other.green;
blue =
blue+other.blue;
if(red>255) //If
threshold is crossed set to max values
red=255;
if(green>255)
green=255;
if(blue>255)
blue=255;
}
};
int main() {
Color c1;
c1.Print();
cout<<endl;
Color c2 = Color(10,20,100);
c2.Print();
c2.addColor(Color(200,200,200));
c2.Print();
return 0;
}
Here you go champ, I commented the code as far as possible. But still if you can't understand, feel free to comment below
In computer systems color is represented by RGB format (Red. Green and Blue color components) where...
3.22 LAB: Remove gray from RGB Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded...
in C++ An unsigned int, x, represents 4 color values: alpha, red, green, blue (in that order). Each value is a number from 0..255. Using bit manipulation only (<<, |, & , etc.), write code to pull the red value from x. Then using arithmetic operators only (+, /, %, etc.), write code to pull the red value from x.
class Circle { public: enum Color {UNDEFINED, BLACK, BLUE, GREEN, CYAN, RED}; Circle(int = 0, int = 0, double = 0.0, Color = UNDEFINED); void setX(int); void setY(int); void setRadius(double); void setColor(Color); int getX() const; int getY() const; double getRadius() const; Color getColor() const; private: int x; int y; ...
Program 2: BACK AWAY FROM THE TV! If you sat close enough to an old TV, you could see individual (R)ed, (G)reen and (B)lue (or RGB) “phosphors” that could represent just about any color you could imagine (using “additive color model”). When these three-color components are at their maximum values, the resulting color is white from a distance (which is amazing – look at your screen with a magnifying glass!). When all are off, the color results in black. If...
IN C++!! Program 2: BACK AWAY FROM THE TV! If you sat close enough to an old TV, you could see individual (R)ed, (G)reen and (B)lue (or RGB) “phosphors” that could represent just about any color you could imagine (using “additive color model”). When these three color components are at their maximum values, the resulting color is white from a distance (which is amazing – look at your screen with a magnifying glass!). When all are off, the color results...
please help with the marked ones the programming language is python code. 23.16 Write an RGB class that represents an RGB color. Store the red, green. and blue components. Include a _str_0 method and a luminance method that returns the luminance of the color. Write a main() function to test your code. 23.17 Write a CD class that represents a single music cd. Store the artist, title, genre, year of release, and playing time in minutes and seconds. However, instead...
Summary: Given integer values for red, green, and blue, subtract the gray from each value. Python Language Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the...
Task In this challenge you parse RGB colors represented by strings. The formats are primarily used in HTML and CSS. Your task is to implement a function which takes a color as a string and returns the parsed color as a map (see Examples). Input represents one of the following: color The input string 1.6-digit hexadecimal "#RRGGBB" - Each pair of digits represents a value of the channel in hexadecimal: 00 to FF 2.3-digit hexadecimal "#RGB" - Each digit represents...
This is assignment and code from this site but it will not compile....can you help? home / study / engineering / computer science / computer science questions and answers / c++ this assignment requires several classes which interact with each other. two class aggregations ... Question: C++ This assignment requires several classes which interact with each other. Two class aggregatio... (1 bookmark) C++ This assignment requires several classes which interact with each other. Two class aggregations are formed. The program...
Part 1. (60 pts) 1. Define an Address class in the file Address.h and implement the Address class in Address.cpp. a. This class should have two private data members, m_city and m_state, that are strings for storing the city name and state abbreviation for some Address b. Define and implement public getter and setter member functions for each of the two data members above. Important: since these member functions deal with objects in this case strings), ensure that your setters...