From fb506c0829135d4ac35d0fbbdc76f19c6a58ca21 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 24 Jun 2014 11:58:53 -0700 Subject: Add CB_FILL_RANDOM to select a random fill type Also, make command line parsing of fill and shape types more strict --- src/shapes.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/shapes.cpp') diff --git a/src/shapes.cpp b/src/shapes.cpp index b866bad..b2ae017 100644 --- a/src/shapes.cpp +++ b/src/shapes.cpp @@ -4,6 +4,7 @@ * Use of this source code is governed by the 3-Clause BSD license * specified in the COPYING file included with this source code. */ +#include #include #include "shapes.h" @@ -29,10 +30,9 @@ convertToFillType(const char *fill_name) return (fill_type_t) i ; i++; } - return (fill_type_t) 0; + errx(1, "Unknown fill type '%s' specified", fill_name); } - const char *gShapes[] = { "circle", "rectangle", @@ -53,7 +53,7 @@ convertToShapeType(const char* shape_name) return (shape_type_t)(i + 1); i++; } - return (shape_type_t) 0; + errx(1, "Unknown shape type '%s' specified", shape_name); } @@ -95,6 +95,18 @@ generate_random_shape() return (shape_type_t) ((((double)(CB_SHAPE_END-1) * rand())/RAND_MAX) + 1); } +fill_type_t +generate_random_fill_type() +{ +#if 0 + // TODO: Not all fill styles are implemented yet + return (fill_type_t) ((((double)(CB_FILL_END-1) * rand())/RAND_MAX) + 1); +#else + // TODO: So for now only go up to solid fills + return (fill_type_t) ((((double)(CB_FILL_SOLID) * rand())/RAND_MAX) + 1); +#endif +} + /* Local Variables: mode:c++ -- cgit v1.3.1-4-g156e