示例#1
0
文件: p_draw.c 项目: xharbour/core
void
pdf__circle(PDF *p, pdc_scalar x, pdc_scalar y, pdc_scalar r)
{
    pdc_check_number(p->pdc, "x", x);
    pdc_check_number(p->pdc, "y", y);
    pdc_check_number_limits(p->pdc, "r", r, PDC_FLOAT_PREC, PDC_FLOAT_MAX);

    /*
     * pdf_begin_path() not required since we descend to other
     * path segment functions.
     */

    /* draw four Bezier curves to approximate a circle */
    pdf__moveto(p, x + r, y);
    pdf__curveto(p, x + r, y + r*ARC_MAGIC, x + r*ARC_MAGIC, y + r, x, y + r);
    pdf__curveto(p, x - r*ARC_MAGIC, y + r, x - r, y + r*ARC_MAGIC, x - r, y);
    pdf__curveto(p, x - r, y - r*ARC_MAGIC, x - r*ARC_MAGIC, y - r, x, y - r);
    pdf__curveto(p, x + r*ARC_MAGIC, y - r, x + r, y - r*ARC_MAGIC, x + r, y);

    pdf__closepath(p);
}
示例#2
0
void
pdf_draw_mbox_rectangle(PDF *p, pdf_mbox *mbox, int flags)
{
    pdc_bool drawleft, drawright, drawbottom, drawtop;
    pdc_bool saverestore = (flags & mbox_saverestore) &&
        ((flags & mbox_area &&
          mbox->fillcolor.type != (int) color_none) ||
         (flags & mbox_border &&
          mbox->strokecolor.type != (int) color_none && mbox->borderwidth > 0));

    if (saverestore)
        pdf__save(p);

    if (flags & mbox_area && mbox->fillcolor.type != (int) color_none &&
        mbox->rect.llx != mbox->rect.urx &&
        mbox->rect.lly != mbox->rect.ury)
    {
        pdf_set_coloropt(p, pdf_fill, &mbox->fillcolor);
        pdf__moveto(p, mbox->rect.llx, mbox->rect.lly);
        pdf__lineto(p, mbox->rect.urx, mbox->rect.lly);
        pdf__lineto(p, mbox->rect.urx, mbox->rect.ury);
        pdf__lineto(p, mbox->rect.llx, mbox->rect.ury);
        pdf__lineto(p, mbox->rect.llx, mbox->rect.lly);
        pdf__fill(p);
    }

    if (flags & mbox_border &&
        mbox->strokecolor.type != (int) color_none && mbox->borderwidth > 0)
    {
        pdf_set_coloropt(p, pdf_stroke, &mbox->strokecolor);
        pdf__setlinewidth(p, mbox->borderwidth);
        pdf_setdashpattern_internal(p, mbox->dasharray, mbox->dashlength,
                                    mbox->dashphase);
        pdf__setlinecap(p, mbox->linecap);
        pdf__setlinejoin(p, mbox->linejoin);

        drawbottom = mbox->drawbottom &&
                    (!(flags & mbox_openbottom) || !mbox->openrect);
        if (drawbottom)
        {
            pdf__moveto(p, mbox->rect.llx, mbox->rect.lly);
            pdf__lineto(p, mbox->rect.urx, mbox->rect.lly);
        }

        drawright = mbox->drawright &&
                    (!(flags & mbox_openright) || !mbox->openrect);
        if (drawright)
        {
            if (!drawbottom)
                pdf__moveto(p, mbox->rect.urx, mbox->rect.lly);
            pdf__lineto(p, mbox->rect.urx, mbox->rect.ury);
        }

        drawtop = mbox->drawtop &&
                    (!(flags & mbox_opentop) || !mbox->openrect);
        if (drawtop)
        {
            if (!drawright)
                pdf__moveto(p, mbox->rect.urx, mbox->rect.ury);
            pdf__lineto(p, mbox->rect.llx, mbox->rect.ury);
        }

        drawleft = mbox->drawleft &&
                    (!(flags & mbox_openleft) || !mbox->openrect);
        if (drawleft)
        {
            if (!drawtop)
                pdf__moveto(p, mbox->rect.llx, mbox->rect.ury);
            if (drawbottom && drawright && drawtop)
                pdf__closepath(p);
            else
                pdf__lineto(p, mbox->rect.llx, mbox->rect.lly);
        }

        pdf__stroke(p);
    }

    if (saverestore)
        pdf__restore(p);
}