diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-06-03 05:11:27 +0900 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-06-03 05:11:27 +0900 |
| commit | 2da0666bc94117d6551e33bd4046794116bfedf9 (patch) | |
| tree | e3cfbe3554d11543f86615eee9f77788e49bc4c7 /src/caskbench.cpp | |
| parent | 64090de8ae0d99efc6097d08e7de9ce42d4cb462 (diff) | |
| parent | 1bf0046da7b1c3f48f89764e328b0f7e27aff6c8 (diff) | |
Merge pull request #66 from Samsung/Issue_36
RGB Color code parsing.
ref: https://github.com/Samsung/caskbench/issues/36
Diffstat (limited to 'src/caskbench.cpp')
| -rw-r--r-- | src/caskbench.cpp | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/src/caskbench.cpp b/src/caskbench.cpp index ddcefe3..43710e4 100644 --- a/src/caskbench.cpp +++ b/src/caskbench.cpp @@ -36,6 +36,8 @@ typedef struct _caskbench_options { int width; int height; char *fill_type; + char *fill_color; + char *stroke_color; double red; double green; double blue; @@ -44,11 +46,6 @@ typedef struct _caskbench_options { char *stock_image_path; int stroke_width; int multi_shapes; - - double stroke_red; - double stroke_green; - double stroke_blue; - int cap_style; int join_style; int dash_style; @@ -151,22 +148,14 @@ process_options(caskbench_options_t *opt, int argc, char *argv[]) "Height of the shape object ", NULL}, {"fill-type", 'f', POPT_ARG_STRING, &opt->fill_type, 0, - "Controls the fill type of the objects draw either solid, gradient, image pattern type", - NULL}, -#if 0 - {"red", 'R', POPT_ARG_DOUBLE, &opt->red, 0, - "R Color Value", + "Controls the fill type of the objects. e.g 'solid', 'linear-gradient', 'radial-gradient', 'image-pattern'", NULL}, - {"green", 'G', POPT_ARG_DOUBLE, &opt->green, 0, - "g Color Value", + {"fill-color", '\0', POPT_ARG_STRING, &opt->fill_color, 0, + "RGBA color value for fill eg. ABCDEFFF ", NULL}, - {"blue", 'B', POPT_ARG_DOUBLE, &opt->blue, 0, - "B Color Value", + {"stroke-color", '\0', POPT_ARG_STRING, &opt->stroke_color, 0, + "RGBA color value for stroke eg. ABCDEFFF", NULL}, - {"alpha", 'A', POPT_ARG_DOUBLE, &opt->alpha, 0, - "Transparency value for the solid fill", - NULL}, -#endif {"animation", 'g', POPT_ARG_INT, &opt->animation, 0, "Controls the kinematics of the objects drawn", NULL}, @@ -181,17 +170,6 @@ process_options(caskbench_options_t *opt, int argc, char *argv[]) "represents stroke width of the object", NULL}, #if 0 - {"stroke-red", "SR", POPT_ARG_INT, &opt->multi_shapes, 0, - "represents r value for stroke color", - NULL}, - {"stroke-green", "SG", POPT_ARG_INT, &opt->multi_shapes, 0, - "represents represents g value for stroke color", - NULL}, - {"stroke-blue", "SB", POPT_ARG_INT, &opt->multi_shapes, 0, - "represents represents b value for stroke color", - NULL}, -#endif -#if 0 {"cap-style", 'C', POPT_ARG_INT, &opt->cap_style, 0, "represents r value for stroke color", NULL}, @@ -261,6 +239,21 @@ get_tick (void) return (double)now.tv_sec + (double)now.tv_usec / 1000000.0; } +uint32_t +convertToColorValue (const char* hexString) +{ + char *end_ptr; + uint32_t color_val = 0; + int r, g, b; + if ((hexString == NULL) || (strlen(hexString) != 8)) + { + color_val = -1; + return color_val; + } + color_val = strtoul(hexString, &end_ptr, 16); + return color_val; +} + void shape_defaults_init(shapes *shape_defaults, caskbench_options_t *opt) { @@ -274,17 +267,12 @@ shape_defaults_init(shapes *shape_defaults, caskbench_options_t *opt) shape_defaults->height = opt->height; shape_defaults->shape_type = convertToShapeType(opt->shape_name); shape_defaults->fill_type = convertToFillType(opt->fill_type); - shape_defaults->red = opt->red; - shape_defaults->green = opt->green; - shape_defaults->blue = opt->blue; - shape_defaults->alpha = opt->alpha; + shape_defaults->fill_color = convertToColorValue(opt->fill_color); + shape_defaults->stroke_color = convertToColorValue(opt->stroke_color); shape_defaults->stroke_width = opt->stroke_width; shape_defaults->multi_shapes = opt->multi_shapes; shape_defaults->animation = opt->animation; shape_defaults->stroke_width = opt->stroke_width; - shape_defaults->stroke_red = opt->stroke_red; - shape_defaults->stroke_green = opt->stroke_green; - shape_defaults->stroke_blue = opt->stroke_blue; shape_defaults->cap_style = opt->cap_style; shape_defaults->join_style = opt->join_style; shape_defaults->dash_style = opt->dash_style; |