Commit d3b2ac9b authored by Dirk Wilden's avatar Dirk Wilden

choose a random baseColor that differs from background

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4821 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 2d7bb290
......@@ -43,6 +43,8 @@
#include "OpenFlipper/widgets/loadWidget/loadWidget.hh"
#include "OpenFlipper/widgets/addEmptyWidget/addEmptyWidget.hh"
#include <time.h>
void Core::resetScenegraph() {
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() ) {
......@@ -179,22 +181,35 @@ void Core::slotLoad(QString _filename, DataType _type, int& _id) {
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
if ( OpenFlipper::Options::randomBaseColor() )
object->setBaseColor(ACG::Vec4f((float)(rand()%255)/255.0,
(float)(rand()%255)/255.0,
(float)(rand()%255)/255.0,
1.0 ));
else{
ACG::Vec4f color;
QColor defColor = OpenFlipper::Options::defaultBaseColor();
QColor color;
if ( OpenFlipper::Options::randomBaseColor() ){
//init random seed
srand ( time(NULL) );
QColor bckgrnd = OpenFlipper::Options::defaultBackgroundColor();
int diff;
color[0] = defColor.redF();
color[1] = defColor.greenF();
color[2] = defColor.blueF();
color[3] = defColor.alphaF();
do{
color.setRgb(rand()%255, rand()%255, rand()%255);
object->setBaseColor( color );
diff = (bckgrnd.red() - color.red()) *(bckgrnd.red() - color.red())
+(bckgrnd.green() - color.green())*(bckgrnd.green() - color.green())
+(bckgrnd.blue() - color.blue()) *(bckgrnd.blue() - color.blue());
}while (diff < 25);
}
else{
color = OpenFlipper::Options::defaultBaseColor();
}
ACG::Vec4f colorV;
colorV[0] = color.redF();
colorV[1] = color.greenF();
colorV[2] = color.blueF();
colorV[3] = color.alphaF();
object->setBaseColor( colorV );
resetScenegraph();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment