aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-11-11 02:48:07 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2014-11-11 03:40:59 +0100
commit07f3985059df48a0d664f294aae3fc64e6e1a6de (patch)
treec48a6b7d804dc83f0aabbf7740a8c6f02643a7d6 /src
parent66acb21dbbe3e8fb69b2bbd950bc225d4ed4cb4f (diff)
downloadyawa-07f3985059df48a0d664f294aae3fc64e6e1a6de.tar.xz
Add replacement for -addd using --add and --distance
To overrife the nth distance you need n number of --distance flags, distance defaulting to 1 for each color.
Diffstat (limited to 'src')
-rw-r--r--src/yawa.c16
-rw-r--r--src/yawa.h11
2 files changed, 20 insertions, 7 deletions
diff --git a/src/yawa.c b/src/yawa.c
index 453421a..9a78eea 100644
--- a/src/yawa.c
+++ b/src/yawa.c
@@ -46,6 +46,13 @@ parse_opt(signed key, char *arg, struct argp_state *state)
num_add_colors += 1;
break;
+ case 'D':
+ ;
+ signed distance = parse_int(arg, "add distance");
+ arguments->distance[num_distances] = distance;
+ num_distances += 1;
+ break;
+
case 'g':
arguments->gradient = true;
arguments->angle = parse_int(arg, "gradient angle");
@@ -274,13 +281,17 @@ signed
main(signed argc, char **argv)
{
struct arguments arguments = {
- "", "", {{0}}, "", "", 0, 0, 0, 0, 0, 0, 0,
+ "", "", {{0}}, {0}, "", "", 0, 0, 0, 0, 0, 0, 0,
false, false, false, false, false, false,
false, false, false, false, false, false,
false, false, false, false, false, false,
false,
};
+ for(unsigned long i = 0; i < (sizeof arguments.distance)/(sizeof (signed)); i++) {
+ arguments.distance[i] = 1;
+ }
+
// Where the magic happens
argp_parse(&argp, argc, argv, 0, 0, &arguments);
@@ -353,7 +364,6 @@ main(signed argc, char **argv)
imlib_free_color_range();
imlib_context_set_color_range(imlib_create_color_range());
}
- // TODO: Add back -addd
if (arguments.add) {
for (i = 0; i < num_add_colors; i++) {
Color c;
@@ -362,7 +372,7 @@ main(signed argc, char **argv)
exit(-2);
}
imlib_context_set_color(c.r, c.g, c.b, c.a);
- imlib_add_color_to_color_range(1);
+ imlib_add_color_to_color_range(arguments.distance[i]);
}
}
if (arguments.gradient) {
diff --git a/src/yawa.h b/src/yawa.h
index 458050b..9fe8cb2 100644
--- a/src/yawa.h
+++ b/src/yawa.h
@@ -27,12 +27,14 @@ load_image(ImageMode mode, const char *arg, signed rootW, signed rootH,
/// Argument parsing
-static signed num_add_colors;
+static signed num_add_colors = 0;
+static signed num_distances = 0;
struct arguments {
char *image;
char *write_file;
- char add_color[8][8];
+ char add_color[8][8];
+ signed distance[8];
char *solid_color;
char *tint_color;
@@ -73,8 +75,9 @@ struct arguments {
// Order of fields: {NAME, KEY, ARG, FLAGS, DOC, GROUP}.
static struct argp_option options[] = {
{0, 0, 0, 0, "Gradients:", 1},
- {"add", 'a', "COLOR", 0, "Add color to range using distance 1", 1},
- // TODO: Figure out what to do about `-addd <color> <distance>
+ {"add", 'a', "COLOR", 0, "Add color to range", 1},
+ {"distance", 'D', "DISTANCE", 0, "Distance to use for adding color to range. "
+ "Defaults to 1 for each color", 1},
{"gradient", 'g', "ANGLE", 0, "Render gradient using specified angle", 1},
{"clear", 'c', 0, 0, "Clear the color range", 1},