- Added '--lightness' switch.

This commit is contained in:
ccremers 2006-05-26 12:57:27 +00:00
parent 07cc2c2b55
commit 6ac5e2a428
3 changed files with 41 additions and 7 deletions

View File

@ -33,7 +33,6 @@ extern Role I_RRSD;
#define RUNCOLORDELTA 0.2 // maximum hue delta between roles (0.2): smaller means role colors of a protocol become more similar.
#define RUNCOLORCONTRACT 0.8 // contract from protocol edges: smaller means more distinction between protocols.
#define UNTRUSTEDCOLORS 0.4
#define MONOCHROMEFACTOR 0.7 // Monochrome settings. 0.0: all colors become white. 1.0: all colors remain the same lightness as the color versions.
#define CHOOSEWEIGHT "2.0"
#define RUNWEIGHT "10.0"
@ -317,21 +316,35 @@ hlsrgbreal (int *r, int *g, int *b, double h, double l, double s)
void
hlsrgb (int *r, int *g, int *b, double h, double l, double s)
{
double closer (double l, double factor)
{
return l + ((1.0 - l) * factor);
}
if (switches.monochrome)
{
// No colors: make lighter
// No colors
s = 0;
h = 0;
l = 1 - ((1 - l) * MONOCHROMEFACTOR);
hlsrgbreal (r, g, b, h, l, s);
}
if (switches.lightness > 0)
{
// correction switch for lightness
if (switches.lightness == 100)
{
l = 1.0;
}
else
{
// colors
hlsrgbreal (r, g, b, h, l, s);
l = closer (l, ((double) switches.lightness / 100.0));
}
}
// convert
hlsrgbreal (r, g, b, h, l, s);
}
//! print color from h,l,s triplet
void

View File

@ -78,6 +78,7 @@ switchesInit (int argc, char **argv)
switches.extendTrivial = 0; // default off
switches.plain = false; // default colors for terminal
switches.monochrome = false; // default colors for dot
switches.lightness = 0; // lightness correction
switches.clusters = false; // default is no clusters for now
// Process the environment variable SCYTHERFLAGS
@ -908,6 +909,25 @@ switcher (const int process, int index, int commandline)
}
}
if (detect (' ', "lightness", 1))
{
if (!process)
{
/* discourage: hide
*/
}
else
{
switches.lightness = integer_argument ();
if ((switches.lightness < 0) || (switches.lightness > 100))
{
error
("--lightness=x only accepts integer values between 0 and 100");
}
return index;
}
}
if (detect (' ', "clusters", 0))
{
if (!process)

View File

@ -58,6 +58,7 @@ struct switchdata
int extendTrivial; //!< Show further events in arachne xml output, based on knowledge underapproximation. (Includes at least the events of the nonreads extension)
int plain; //!< Disable color output on terminal
int monochrome; //!< Disable colors in dot output
int lightness; //!< Lightness increment 0-100
int clusters; //!> Enable clusters in output
};