summaryrefslogtreecommitdiffstatsci
path: root/src/shapes.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-06-24 11:58:53 -0700
committerBryce Harrington <b.harrington@samsung.com>2014-06-24 17:23:21 -0700
commitfb506c0829135d4ac35d0fbbdc76f19c6a58ca21 (patch)
treebb1c68da62a2c4a413d8936b3592e0e4d6e740ef /src/shapes.cpp
parent9dae77010a6efc5beb8b8b5cbe713c02494c87e0 (diff)
Add CB_FILL_RANDOM to select a random fill type
Also, make command line parsing of fill and shape types more strict
Diffstat (limited to 'src/shapes.cpp')
-rw-r--r--src/shapes.cpp18
1 files changed, 15 insertions, 3 deletions
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 <err.h>
#include <string.h>
#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++