diff --git a/pipi/context.c b/pipi/context.c index 4c8cde7..f2053ea 100644 --- a/pipi/context.c +++ b/pipi/context.c @@ -663,6 +663,29 @@ int pipi_command(pipi_context_t *ctx, char const *cmd, ...) (val - 1) * sizeof(*ctx->images)); ctx->images[ctx->nimages - 1] = tmp; } + else if(!strcmp(cmd, "line")) + { + char const *arg; + va_list ap; + int x1, y1, x2, y2, aa = 0, ret; + uint32_t color = 0; + + if(ctx->nimages < 1) + return -1; + + va_start(ap, cmd); + arg = va_arg(ap, char const *); + va_end(ap); + + ret = sscanf(arg, "%d,%d,%d,%d,%08x,%d", + &x1, &y1, &x2, &y2, &color, &aa); + if(ret < 5) return -1; + + ctx->images[ctx->nimages] = pipi_copy(ctx->images[ctx->nimages - 1]); + pipi_draw_line(ctx->images[ctx->nimages], + x1, y1, x2, y2, color, aa); + ctx->nimages++; + } else { return -1; diff --git a/src/pipi.c b/src/pipi.c index fabde16..0f55deb 100644 --- a/src/pipi.c +++ b/src/pipi.c @@ -228,6 +228,14 @@ int main(int argc, char *argv[]) if(pipi_command(ctx, "overlay") != 0) return EXIT_FAILURE; } + else if(!strcmp(argv[0], "--line")) + { + if(argv[6] == NULL) + return EXIT_FAILURE; + if(pipi_command(ctx, "line", argv[1]) != 0) + return EXIT_FAILURE; + argv++; + } else if(!strcmp(argv[0], "--output") || !strcmp(argv[0], "-o")) { if(argv[1] == NULL)