Skip to content

Commit

Permalink
allow user to reduce contrast
Browse files Browse the repository at this point in the history
  • Loading branch information
jclulow committed Mar 17, 2015
1 parent ce8a281 commit 320c37c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions heatmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef enum { B_FALSE, B_TRUE } boolean_t;
/* NB: The darkest gray is probably too dark. */
#define GRAYMIN (232 + 1)
#define GRAYMAX 255
#define GRAYRNG (GRAYMAX - GRAYMIN)
#define GRAYRNG (graymax - graymin)

#define LEGEND_WIDTH 10

Expand All @@ -43,6 +43,9 @@ int bucket_count = -1;

int debug = 0;

int graymax = GRAYMAX;
int graymin = GRAYMIN;


void
xcb(int idx)
Expand Down Expand Up @@ -291,9 +294,9 @@ new_row(int *vals)
* If all buckets are the same value, just use the
* highest intensity.
*/
colour = GRAYMAX;
colour = graymax;
} else {
colour = GRAYMIN + (GRAYMAX - GRAYMIN) *
colour = graymin + (graymax - graymin) *
(rem_distinct_vals - 1) / (distinct_vals - 1);
}
/*
Expand Down Expand Up @@ -463,14 +466,15 @@ main(int argc, char **argv)
int c;
int opt_base = -1, opt_min = -1, opt_max = -1;
int opt_lin = 0, opt_loglin = 0;
int opt_grayskip = 0;
char *opt_title = NULL;
char *linebuf = NULL;
size_t linebufsz = 0;

/*
* Process flags...
*/
while ((c = getopt(argc, argv, ":b:DlLm:M:t:")) != -1) {
while ((c = getopt(argc, argv, ":b:DG:lLm:M:t:")) != -1) {
switch (c) {
case 'l':
opt_lin++;
Expand All @@ -493,6 +497,9 @@ main(int argc, char **argv)
case 't':
opt_title = strdup(optarg);
break;
case 'G':
opt_grayskip = atoi(optarg);
break;
case ':':
fprintf(stderr, "Option -%c requires an operand\n",
optopt);
Expand All @@ -511,6 +518,13 @@ main(int argc, char **argv)
}
}

graymin += opt_grayskip;
if (opt_grayskip < 0 || GRAYRNG < 1) {
fprintf(stderr, "There are not %d shades of gray.\n",
opt_grayskip);
exit(1);
}

/*
* Signals...
*/
Expand Down

0 comments on commit 320c37c

Please sign in to comment.