C++ drawing pixels lines rectangles implementing functions Implement all of the
ID: 3813700 • Letter: C
Question
C++ drawing pixels lines rectangles implementing functions
Implement all of the functions in the class and make driver for testing
This is what i have so far:
const int MAX_WIDTH = 640;
const int MAX_HEIGHT = 480;
const int MAX_COLOR = 255;
enum COLOR{ RED, GREEN, BLUE};
using namespace std;
class ImageMaker
{
private:
int width;
int height;
int red;
int green;
int blue;
short image[MAX_WIDTH][MAX_HEIGHT][3];
public:
ImageMaker::ImageMaker()
{
int height = 0;
int width = 0;
}
ImageMaker(string filename)
{
}
void LoadImage(string filename)
{
outf.open("out1.txt");
}
void SaveImage(string filename)
{
outf<<image[][];
}
// Write the matrix to file
void DrawPixel(int x, int y)
{
}
void DrawRectangle(int x1, int y1, int x2, int y2)
{
}
void DrawLine(int x1, int y1, int x2, int y2)
{
}
ImageMaker::setWidth(int w)
{
width = w;
}
ImageMaker::setHeight(int h)
{
height = h;
}
ImageMaker::getWidth()
{
return width;
}
ImageMaker::getHeight()
{
return height;
}
imageMaker::SetRed(int newR)
{
red = newR;
}
void SetGreen(int newG)
{
green = newG;
}
void SetBlue(int newB)
{
blue = newB;
}
int GetRed()
{
return Red;
}
int GetGreen()
{
return green;
}
int GetBlue()
{
return blue;
}
};
Explanation / Answer
#include <iostream>
#include <list>
using namespace std;
// a category that represents Associate in Nursing adrift graph
class Graph
closeness lists
public:
// builder and destructor
Graph(int V)
~Graph()
// perform to feature a foothold to graph
void addEdge(int v, int w);
// Prints greedy coloring of the vertices
void greedyColoring();
};
void Graph::addEdge(int v, int w)
{
adj[v].push_back(w);
adj[w].push_back(v); // Note: the graph is adrift
}
// Assigns colours (starting from 0) to all or any vertices and prints
// the assignment of colours
void Graph::greedyColoring()
1st|the primary} color to first vertex
result[0] = 0;
// Initialize remaining guided missile vertices as unassigned
for (int u = 1; u < V; u++)
result[u] = -1; // no color is assigned to u
// a brief array to store the on the market colours. True
// worth of available[cr] would mean that the colour metal is
// assigned to at least one of its adjacent vertices
bool available[V];
for (int metal = 0; metal < V; cr++)
available[cr] = false;
// Assign colours to remaining guided missile vertices
for (int u = 1; u < V; u++)
method all adjacent vertices and flag their colours
// as unobtainable
list<int>::iterator i;
for (i = adj[u].begin(); i != adj[u].end(); ++i)
if (result[*i] != -1)
available[result[*i]] = true;
// realize the primary on the market color
int cr;
for (cr = 0; metal < V; cr++)
if (available[cr] == false)
break;
result[u] = cr; // Assign the found color
// Reset the values back to false for successive iteration
for (i = adj[u].begin(); i != adj[u].end(); ++i)
if (result[*i] != -1)
available[result[*i]] = false;
}
// print the result
for (int u = 0; u < V; u++)
cout << "Vertex " << u << " ---> Color "
<< result[u] << endl;
}
// Driver program to check higher than perform
int main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.