void pdf__setdash(PDF *p, pdc_scalar b, pdc_scalar w) { pdc_scalar darray[2]; int length = 2; pdc_check_number_limits(p->pdc, "b", b, 0.0, PDC_FLOAT_MAX); pdc_check_number_limits(p->pdc, "w", w, 0.0, PDC_FLOAT_MAX); /* both zero means solid line */ if (b == 0.0 && w == 0.0) { length = 0; } else { darray[0] = b; darray[1] = w; } pdf_setdashpattern_internal(p, darray, length, 0); }
void pdf__setdashpattern(PDF *p, const char *optlist) { pdc_resopt *results; char **strlist; pdc_scalar *darray = NULL, phase = 0; int length; /* parsing optlist */ results = pdc_parse_optionlist(p->pdc, optlist, pdf_dashoptions, NULL, pdc_true); length = pdc_get_optvalues("dasharray", results, NULL, &strlist); darray = (pdc_scalar *) strlist; pdc_get_optvalues("dashphase", results, &phase, NULL); pdf_setdashpattern_internal(p, darray, length, phase); pdc_cleanup_optionlist(p->pdc, results); }
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); }