diff options
-rw-r--r-- | doc/HISTORY | 3 | ||||
-rw-r--r-- | editor/ppmdraw.c | 46 |
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) |