diff --git a/src/dotout.c b/src/dotout.c index eea70a2..6a241e7 100644 --- a/src/dotout.c +++ b/src/dotout.c @@ -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,19 +316,33 @@ 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); } - else + + if (switches.lightness > 0) { - // colors - hlsrgbreal (r, g, b, h, l, s); + // correction switch for lightness + if (switches.lightness == 100) + { + l = 1.0; + } + else + { + l = closer (l, ((double) switches.lightness / 100.0)); + } } + +// convert + hlsrgbreal (r, g, b, h, l, s); } diff --git a/src/switches.c b/src/switches.c index acdc766..d453805 100644 --- a/src/switches.c +++ b/src/switches.c @@ -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) diff --git a/src/switches.h b/src/switches.h index 441eb15..4f280df 100644 --- a/src/switches.h +++ b/src/switches.h @@ -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 };