diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2012-04-28 02:26:22 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2012-04-28 02:26:22 +0000 |
commit | 31569bde18b131ebf34f03bd01a3854130078f29 (patch) | |
tree | 2159d36fb18be5f0a309e294ec412a382ddb63dd /editor/ppmdraw.c | |
parent | 6234f28e80e12318b03432ae849ca40ca702108f (diff) | |
download | netpbm-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
Diffstat (limited to 'editor/ppmdraw.c')
-rw-r--r-- | editor/ppmdraw.c | 46 |
1 files changed, 46 insertions, 0 deletions
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) |