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 drawPath(canvas * const canvasP, path * const pathP) { /*---------------------------------------------------------------------------- Draw the path 'pathP' on the canvas 'canvasP'. -----------------------------------------------------------------------------*/ struct fillobj * fillObjP; if (traceDraw) pm_message("Drawing path '%s' with fill color (%u, %u, %u)", pathP->pathText, pathP->style.fillColor.r, pathP->style.fillColor.g, pathP->style.fillColor.b); fillObjP = ppmd_fill_create(); outlineObject(pathP, fillObjP); ppmd_fill(canvasP->pixels, canvasP->width, canvasP->height, canvasP->maxval, fillObjP, PPMD_NULLDRAWPROC, &pathP->style.fillColor); ppmd_fill_destroy(fillObjP); }
static void camo(pixel ** const pixels, unsigned int const cols, unsigned int const rows, pixval const maxval, bool const antiflag) { pixel color; int n, i, cx, cy; struct fillobj * fh; /* Clear background. */ if (antiflag) color = random_anticamo_color( maxval ); else color = random_camo_color( maxval ); ppmd_filledrectangle( pixels, cols, rows, maxval, 0, 0, cols, rows, PPMD_NULLDRAWPROC, &color); n = (rows * cols) / (BLOBRAD * BLOBRAD) * 5; for (i = 0; i < n; ++i) { int points, p, xs[MAX_POINTS], ys[MAX_POINTS], x0, y0; float a, b, c, theta, tang, tx, ty; cx = rand() % cols; cy = rand() % rows; points = rand() % ( MAX_POINTS - MIN_POINTS + 1 ) + MIN_POINTS; a = rnduni() * (MAX_ELLIPSE_FACTOR - MIN_ELLIPSE_FACTOR) + MIN_ELLIPSE_FACTOR; b = rnduni() * (MAX_ELLIPSE_FACTOR - MIN_ELLIPSE_FACTOR) + MIN_ELLIPSE_FACTOR; theta = rnduni() * 2.0 * M_PI; for (p = 0; p < points; ++p) { tx = a * sin(p * 2.0 * M_PI / points); ty = b * cos(p * 2.0 * M_PI / points); tang = atan2(ty, tx) + theta; c = rnduni() * (MAX_POINT_FACTOR - MIN_POINT_FACTOR) + MIN_POINT_FACTOR; xs[p] = cx + BLOBRAD * c * sin(tang); ys[p] = cy + BLOBRAD * c * cos(tang); } x0 = (xs[0] + xs[points - 1]) / 2; y0 = (ys[0] + ys[points - 1]) / 2; fh = ppmd_fill_create(); ppmd_polyspline( pixels, cols, rows, maxval, x0, y0, points, xs, ys, x0, y0, ppmd_fill_drawproc, fh ); if (antiflag) color = random_anticamo_color(maxval); else color = random_camo_color(maxval); ppmd_fill(pixels, cols, rows, maxval, fh, PPMD_NULLDRAWPROC, &color); ppmd_fill_destroy(fh); } }