# HG changeset patch # User alpar # Date 1155217976 0 # Node ID f9e43b5cc6174fec84ccb2e91878c18e11552119 # Parent b4de9aed7709ebe6ac6267c9cac2be3f9427c4a2 Some color constants added (BLACK, WHITE, RED etc) diff -r b4de9aed7709 -r f9e43b5cc617 demo/disjoint_paths_demo.cc --- a/demo/disjoint_paths_demo.cc Thu Aug 10 12:26:29 2006 +0000 +++ b/demo/disjoint_paths_demo.cc Thu Aug 10 13:52:56 2006 +0000 @@ -41,7 +41,7 @@ using namespace std; Color color(bool b) { - return b ? Color(1.0, 0.0, 0.0) : Color(0.0, 0.0, 0.0); + return b ? RED : BLACK; } int main() { diff -r b4de9aed7709 -r f9e43b5cc617 demo/strongly_connected_orientation.cc --- a/demo/strongly_connected_orientation.cc Thu Aug 10 12:26:29 2006 +0000 +++ b/demo/strongly_connected_orientation.cc Thu Aug 10 13:52:56 2006 +0000 @@ -45,7 +45,7 @@ UGRAPH_TYPEDEFS(UGraph) Color color(bool c) { - return c ? Color(0.0, 0.0, 0.0) : Color(1.0, 0.0, 0.0); + return c ? BLACK : RED; } template diff -r b4de9aed7709 -r f9e43b5cc617 demo/topology_demo.cc --- a/demo/topology_demo.cc Thu Aug 10 12:26:29 2006 +0000 +++ b/demo/topology_demo.cc Thu Aug 10 13:52:56 2006 +0000 @@ -40,7 +40,7 @@ Color color(bool val) { - return val ? Color(1.0, 0.0, 0.0) : Color(0.0, 0.0, 1.0); + return val ? RED : BLUE; } diff -r b4de9aed7709 -r f9e43b5cc617 lemon/Makefile.am --- a/lemon/Makefile.am Thu Aug 10 12:26:29 2006 +0000 +++ b/lemon/Makefile.am Thu Aug 10 13:52:56 2006 +0000 @@ -10,6 +10,7 @@ lemon/lp_base.cc \ lemon/lp_skeleton.cc \ lemon/base.cc \ + lemon/color.cc \ lemon/eps.cc \ lemon/bits/mingw32_rand.cc \ lemon/bits/mingw32_time.cc diff -r b4de9aed7709 -r f9e43b5cc617 lemon/color.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lemon/color.cc Thu Aug 10 13:52:56 2006 +0000 @@ -0,0 +1,44 @@ + /* -*- C++ -*- + * + * This file is a part of LEMON, a generic C++ optimization library + * + * Copyright (C) 2003-2006 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +///\file +///\brief Color constants + +#include + +namespace lemon { + + const Color WHITE(1,1,1); + + const Color BLACK(0,0,0); + const Color RED(1,0,0); + const Color GREEN(0,1,0); + const Color BLUE(0,0,1); + const Color YELLOW(1,1,0); + const Color MAGENTA(1,0,1); + const Color CYAN(0,1,1); + + const Color GREY(0,0,0); + const Color DARK_RED(.5,0,0); + const Color DARK_GREEN(0,.5,0); + const Color DARK_BLUE(0,0,.5); + const Color DARK_YELLOW(.5,.5,0); + const Color DARK_MAGENTA(.5,0,.5); + const Color DARK_CYAN(0,.5,.5); + +} //namespace lemon diff -r b4de9aed7709 -r f9e43b5cc617 lemon/color.h --- a/lemon/color.h Thu Aug 10 12:26:29 2006 +0000 +++ b/lemon/color.h Thu Aug 10 13:52:56 2006 +0000 @@ -44,6 +44,9 @@ namespace lemon { + /// \addtogroup misc + /// @{ + ///Data structure representing RGB colors. ///Data structure representing RGB colors. @@ -72,6 +75,37 @@ void set(double r,double g,double b) { _r=r;_g=g;_b=b; }; }; + /// White color constant + extern const Color WHITE; + /// Black color constant + extern const Color BLACK; + /// Red color constant + extern const Color RED; + /// Green color constant + extern const Color GREEN; + /// Blue color constant + extern const Color BLUE; + /// Yellow color constant + extern const Color YELLOW; + /// Magenta color constant + extern const Color MAGENTA; + /// Cyan color constant + extern const Color CYAN; + /// Grey color constant + extern const Color GREY; + /// Dark red color constant + extern const Color DARK_RED; + /// Dark green color constant + extern const Color DARK_GREEN; + /// Drak blue color constant + extern const Color DARK_BLUE; + /// Dark yellow color constant + extern const Color DARK_YELLOW; + /// Dark magenta color constant + extern const Color DARK_MAGENTA; + /// Dark cyan color constant + extern const Color DARK_CYAN; + ///Maps ints to different \ref Color "Color"s ///This map assigns one of the predefined \ref Color "Color"s @@ -91,8 +125,8 @@ ///\param have_white indicates whether white is ///amongst the provided color (\c true) or not (\c false). If it is true, ///white will be assigned to \c 0. - ///\param num the number of the allocated colors. If it is \c 0 - ///the default color configuration is set up (26 color plus the while). + ///\param num the number of the allocated colors. If it is \c 0, + ///the default color configuration is set up (26 color plus the white). ///If \c num is less then 26/27 then the default color list is cut. Otherwise ///the color list is filled repeatedly with the default color list. ///(The colors can be changed later on.) @@ -167,10 +201,11 @@ ///Returns black for light colors and white for the dark ones. inline Color distantBW(const Color &c){ - double v=(.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5?1:0; - return Color(v,v,v); + return (.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5 ? WHITE : BLACK; } +/// @} + } //END OF NAMESPACE LEMON #endif // LEMON_COLOR_H diff -r b4de9aed7709 -r f9e43b5cc617 lemon/eps.h --- a/lemon/eps.h Thu Aug 10 12:26:29 2006 +0000 +++ b/lemon/eps.h Thu Aug 10 13:52:56 2006 +0000 @@ -286,7 +286,7 @@ ///\param col Color of the node. The default color is white ///\param brd Color of the node border. The default color is black EpsDrawer &node(NodeShapes t, double x, double y, double r, - Color col=Color(1,1,1), Color brd=Color(0,0,0)); + Color col=WHITE, Color brd=BLACK); ///Draw a node shape ///Draw a node shape. @@ -297,7 +297,7 @@ ///\param brd Color of the node border. The default color is black template EpsDrawer &node(NodeShapes t, xy pos, double r, - Color col=Color(1,1,1), Color brd=Color(0,0,0)) + Color col=WHITE, Color brd=BLACK) { return node(t,pos.x,pos.y,r,col,brd); } diff -r b4de9aed7709 -r f9e43b5cc617 lemon/graph_to_eps.h --- a/lemon/graph_to_eps.h Thu Aug 10 12:26:29 2006 +0000 +++ b/lemon/graph_to_eps.h Thu Aug 10 13:52:56 2006 +0000 @@ -144,7 +144,7 @@ bool _pros=false) : g(_g), os(_os), _coords(xy(1,1)), _nodeSizes(1.0), _nodeShapes(0), - _nodeColors(Color(1,1,1)), _edgeColors(Color(0,0,0)), + _nodeColors(WHITE), _edgeColors(BLACK), _edgeWidths(1), _edgeWidthScale(0.3), _nodeScale(1.0), _xBorder(10), _yBorder(10), _scale(1.0), _nodeBorderQuotient(.1), @@ -155,7 +155,7 @@ _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0), _undirected(false), _pleaseRemoveOsStream(_pros), _scaleToA4(false), - _nodeTextColorType(SAME_COL), _nodeTextColors(Color(0,0,0)), + _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK), _autoNodeScale(false), _autoEdgeWidthScale(false), _negY(false)