Improved color generation
This commit is contained in:
parent
b2c5f704dd
commit
827043ab3e
2 changed files with 30 additions and 15 deletions
|
@ -174,22 +174,36 @@ void KV::PrintPrimImplikanten()
|
||||||
if (currentPI->name.find("|") != string::npos) // define a color for this PI
|
if (currentPI->name.find("|") != string::npos) // define a color for this PI
|
||||||
{
|
{
|
||||||
random = -1;
|
random = -1;
|
||||||
color = RED;
|
uint r = rand() % 128 + 128;
|
||||||
|
uint gb = rand() % 100;
|
||||||
|
color = RGB(r, gb, gb); // some red color
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
random = rand() % 10;
|
random = rand() % 10;
|
||||||
if (currentPI->implikanten.size() == 1)
|
if (currentPI->elements.size() == 1)
|
||||||
color = GREEN;
|
color = GREEN;
|
||||||
else
|
else
|
||||||
color = RGB(rand() % 256; rand() % 256; rand() % 256);
|
{
|
||||||
|
uint r, g, b;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
r = rand() % 256;
|
||||||
|
g = rand() % 256;
|
||||||
|
b = rand() % 256;
|
||||||
|
}
|
||||||
|
while (
|
||||||
|
(r + g + b) / 3 > 200 || // avoid light colors
|
||||||
|
r > g + b); // avoid red colors
|
||||||
|
color = RGB(r, g, b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<KV_PiEleLoc*>* locations = currentPI->locations();
|
vector<KV_PiEleLoc*>* locations = currentPI->locations();
|
||||||
for (uint j = 0; j < locations.size(); j++) // for each Element in PrimImplikant
|
for (uint j = 0; j < locations->size(); j++) // for each Element in PrimImplikant
|
||||||
{
|
{
|
||||||
KV_PiEleLoc* currentEl = locations[j];
|
KV_PiEleLoc* currentEl = locations->at(j);
|
||||||
|
|
||||||
bool foundGroup = false;
|
bool foundGroup = false;
|
||||||
for (uint k = 0; k < piGroups.size(); k++) // for each Group/Kuller of this PrimImplikant
|
for (uint k = 0; k < piGroups.size(); k++) // for each Group/Kuller of this PrimImplikant
|
||||||
|
@ -207,7 +221,7 @@ void KV::PrintPrimImplikanten()
|
||||||
{
|
{
|
||||||
KV_PiGroup* newGroup = new KV_PiGroup();
|
KV_PiGroup* newGroup = new KV_PiGroup();
|
||||||
newGroup->Add(currentEl);
|
newGroup->Add(currentEl);
|
||||||
piGroups.add(newGroup);
|
piGroups.push_back(newGroup);
|
||||||
}
|
}
|
||||||
} // for each Element in PrimImplikant
|
} // for each Element in PrimImplikant
|
||||||
|
|
||||||
|
@ -215,7 +229,6 @@ void KV::PrintPrimImplikanten()
|
||||||
{
|
{
|
||||||
this->PrintPrimImplikantenGroup(piGroups[k], random, color); // draw it
|
this->PrintPrimImplikantenGroup(piGroups[k], random, color); // draw it
|
||||||
|
|
||||||
piGroups[k]->Dispose(); // delete all KV_PiEleLocs
|
|
||||||
delete piGroups[k];
|
delete piGroups[k];
|
||||||
piGroups[k] = NULL;
|
piGroups[k] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -224,9 +237,9 @@ void KV::PrintPrimImplikanten()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints the Kuller of a KV_PiGroup
|
// Prints the Kuller of a KV_PiGroup
|
||||||
void KV::PrintPrimImplikantenGroup(KV_PiGroup* &group, char &random, uint &color)
|
void KV::PrintPrimImplikantenGroup(KV_PiGroup* &group, char random, uint &color)
|
||||||
{
|
{
|
||||||
group->MakeCoords(); // makes X1, X2, Y1, Y2
|
group->MakeCoords(this->edgeLength, this->VarX_Length, this->VarY_Length); // makes X1, X2, Y1, Y2
|
||||||
uint X1 = group->X1;
|
uint X1 = group->X1;
|
||||||
uint X2 = group->X2;
|
uint X2 = group->X2;
|
||||||
uint Y1 = group->Y1;
|
uint Y1 = group->Y1;
|
||||||
|
@ -235,10 +248,12 @@ void KV::PrintPrimImplikantenGroup(KV_PiGroup* &group, char &random, uint &color
|
||||||
|
|
||||||
if (random == -1) // make hazard groups as small as possible
|
if (random == -1) // make hazard groups as small as possible
|
||||||
{
|
{
|
||||||
X1 += 12;
|
random = rand() % 2;
|
||||||
X2 -= 12;
|
X1 += 12 - random;
|
||||||
Y1 += 9;
|
X2 -= 12 - random;
|
||||||
Y2 -= 9;
|
random = rand() % 2;
|
||||||
|
Y1 += 9 - random;
|
||||||
|
Y2 -= 9 - random;
|
||||||
}
|
}
|
||||||
else // make size random, so the groups won't overlap
|
else // make size random, so the groups won't overlap
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Cell.h"
|
#include "Cell.h"
|
||||||
#include "CellCollection.h"
|
#include "CellCollection.h"
|
||||||
|
#include "KV_PiGroup.h"
|
||||||
#include "PrimImplikantCollection.h"
|
#include "PrimImplikantCollection.h"
|
||||||
#include "Implikant_localisation.h"
|
|
||||||
|
|
||||||
extern uint dimension;
|
extern uint dimension;
|
||||||
extern uint numElements;
|
extern uint numElements;
|
||||||
|
@ -65,7 +65,7 @@ private:
|
||||||
void PrintVariables(); // Erstellt die Werte der Variablen in der ersten X- und Y-Spalte
|
void PrintVariables(); // Erstellt die Werte der Variablen in der ersten X- und Y-Spalte
|
||||||
void PrintCellValues(); // Erstellt die Werte der jeweiligen Zellen
|
void PrintCellValues(); // Erstellt die Werte der jeweiligen Zellen
|
||||||
void PrintPrimImplikanten(); // Generiert die einzelnen PrimImplikanten-Kuller (Gruppen)
|
void PrintPrimImplikanten(); // Generiert die einzelnen PrimImplikanten-Kuller (Gruppen)
|
||||||
void PrintPrimImplikantenGroup(KV_PiGroup* &group, char &random, uint &color); // Erstellt die einzelnen PrimImplikanten-Kuller
|
void PrintPrimImplikantenGroup(KV_PiGroup* &group, char random, uint &color); // Erstellt die einzelnen PrimImplikanten-Kuller
|
||||||
void PrintString_Var(); // Erstellt den horizontalen TextVariable & vertikalen Textvariable
|
void PrintString_Var(); // Erstellt den horizontalen TextVariable & vertikalen Textvariable
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue