fz_error * pdf_setpattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v) { pdf_gstate *gs = csi->gstate + csi->gtop; fz_error *error; pdf_material *mat; error = pdf_flushtext(csi); if (error) return fz_rethrow(error, "cannot finish text node (state change)"); mat = what == PDF_MFILL ? &gs->fill : &gs->stroke; if (mat->pattern) pdf_droppattern(mat->pattern); mat->kind = PDF_MPATTERN; if (pat) mat->pattern = pdf_keeppattern(pat); else mat->pattern = nil; if (v) { error = pdf_setcolor(csi, what, v); if (error) return fz_rethrow(error, "cannot set color"); } return fz_okay; }
/* Normal output: black on transparent */ static int render0(potrace_path_t *plist) { potrace_path_t *p; pdf_setcolor(info.color); list_forall (p, plist) { pdf_path(&p->curve); ship("h\n"); if (p->next == NULL || p->next->sign == '+') { ship("f\n"); } }
void pdf_setpattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v) { pdf_gstate *gs = csi->gstate + csi->gtop; pdf_material *mat; pdf_flushtext(csi); mat = what == PDF_MFILL ? &gs->fill : &gs->stroke; if (mat->pattern) pdf_droppattern(mat->pattern); mat->kind = PDF_MPATTERN; if (pat) mat->pattern = pdf_keeppattern(pat); else mat->pattern = nil; if (v) pdf_setcolor(csi, what, v); }