about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-04-28 02:26:22 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-04-28 02:26:22 +0000
commit31569bde18b131ebf34f03bd01a3854130078f29 (patch)
tree2159d36fb18be5f0a309e294ec412a382ddb63dd
parent6234f28e80e12318b03432ae849ca40ca702108f (diff)
downloadnetpbm-mirror-31569bde18b131ebf34f03bd01a3854130078f29.tar.gz
netpbm-mirror-31569bde18b131ebf34f03bd01a3854130078f29.tar.xz
netpbm-mirror-31569bde18b131ebf34f03bd01a3854130078f29.zip
Add filledcircle command class
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1683 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY3
-rw-r--r--editor/ppmdraw.c46
2 files changed, 49 insertions, 0 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 69aa35eb..c1d5d4a2 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -6,6 +6,9 @@ CHANGE HISTORY
 
 not yet  BJH  Release 10.59.00
 
+              ppmdraw: Add 'filledcircle' command class.  Thanks
+              Elijah Griffin <eli@panix.com>.
+
               pamstereogram: fix crash introduced in 10.54 (March 2011).
 
               pamstereogram: fix crash introduced in 10.53 (December 2010).
diff --git a/editor/ppmdraw.c b/editor/ppmdraw.c
index 1305a313..ba513581 100644
--- a/editor/ppmdraw.c
+++ b/editor/ppmdraw.c
@@ -189,6 +189,7 @@ enum drawVerb {
     VERB_LINE_HERE,
     VERB_SPLINE3,
     VERB_CIRCLE,
+    VERB_FILLEDCIRCLE,
     VERB_FILLEDRECTANGLE,
     VERB_TEXT,
     VERB_TEXT_HERE
@@ -301,6 +302,8 @@ freeDrawCommand(const struct drawCommand * const commandP) {
         break;
     case VERB_CIRCLE:
         break;
+    case VERB_FILLEDCIRCLE:
+        break;
     case VERB_FILLEDRECTANGLE:
         break;
     case VERB_TEXT:
@@ -346,6 +349,35 @@ freeScript(struct script * const scriptP) {
 
 
 static void
+doFilledCircle(pixel **                   const pixels,
+               unsigned int               const cols,
+               unsigned int               const rows,
+               pixval                     const maxval,
+               const struct drawCommand * const commandP,
+               const struct drawState *   const drawStateP) {
+
+    struct fillobj * fhP;
+
+    fhP = ppmd_fill_create();
+            
+    ppmd_circle(pixels, cols, rows, maxval,
+                commandP->u.circleArg.cx,
+                commandP->u.circleArg.cy,
+                commandP->u.circleArg.radius,
+                ppmd_fill_drawproc,
+                fhP);
+            
+    ppmd_fill(pixels, cols, rows, maxval,
+              fhP,
+              PPMD_NULLDRAWPROC,
+              &drawStateP->color);
+
+    ppmd_fill_destroy(fhP);
+} 
+
+
+
+static void
 doTextHere(pixel **                   const pixels,
            unsigned int               const cols,
            unsigned int               const rows,
@@ -463,6 +495,9 @@ executeScript(struct script * const scriptP,
                         PPMD_NULLDRAWPROC,
                         &drawState.color);
             break;
+        case VERB_FILLEDCIRCLE:
+            doFilledCircle(pixels, cols, rows, maxval, commandP, &drawState);
+            break;
         case VERB_FILLEDRECTANGLE:
             ppmd_filledrectangle(pixels, cols, rows, maxval,
                                  commandP->u.filledrectangleArg.x,
@@ -611,6 +646,17 @@ parseDrawCommand(struct tokenSet             const commandTokens,
                 argP->cy     = atoi(commandTokens.token[2]);
                 argP->radius = atoi(commandTokens.token[3]);
             } 
+        } else if (streq(verb, "filledcircle")) {
+            drawCommandP->verb = VERB_FILLEDCIRCLE;
+            if (commandTokens.count < 4)
+                pm_error("Not enough tokens for a 'filledcircle' command.  "
+                         "Need %u.  Got %u", 4, commandTokens.count);
+            else {
+                struct circleArg * const argP = &drawCommandP->u.circleArg;
+                argP->cx     = atoi(commandTokens.token[1]);
+                argP->cy     = atoi(commandTokens.token[2]);
+                argP->radius = atoi(commandTokens.token[3]);
+            } 
         } else if (streq(verb, "filledrectangle")) {
             drawCommandP->verb = VERB_FILLEDRECTANGLE;
             if (commandTokens.count < 5)