// Set libplot's filling-and-edging style. May set the line width to zero // to turn off edging. In libplot, a 0-width line is as narrow a line as // can be drawn. void drvplot::set_filling_and_edging_style() { switch (currentShowType()) { case drvbase::stroke: (void)plotter->flinewidth(currentLineWidth()); (void)plotter->pencolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); (void)plotter->filltype(0); // no filling break; case drvbase::fill: if (pathWasMerged()) { (void)plotter->flinewidth(currentLineWidth()); (void)plotter->pencolor(plotcolor(edgeR()), plotcolor(edgeG()), plotcolor(edgeB())); (void)plotter->fillcolor(plotcolor(fillR()), plotcolor(fillG()), plotcolor(fillB())); } else { (void)plotter->flinewidth(0.0); // little or no edging (void)plotter->pencolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); (void)plotter->fillcolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); } (void)plotter->filltype(1); (void)plotter->fillmod("winding"); break; case drvbase::eofill: if (pathWasMerged()) { (void)plotter->flinewidth(currentLineWidth()); (void)plotter->pencolor(plotcolor(edgeR()), plotcolor(edgeG()), plotcolor(edgeB())); (void)plotter->fillcolor(plotcolor(fillR()), plotcolor(fillG()), plotcolor(fillB())); } else { (void)plotter->flinewidth(0.0); // little or no edging (void)plotter->pencolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); (void)plotter->fillcolor(plotcolor(currentR()), plotcolor(currentG()), plotcolor(currentB())); } (void)plotter->filltype(1); (void)plotter->fillmod("even-odd"); break; default: // cannot happen errf << "unexpected ShowType " << (int) currentShowType(); break; } }
void drvSAMPL::show_path() { outf << "Path # " << currentNr(); if (isPolygon()) outf << " (polygon): " << endl; else outf << " (polyline): " << endl; outf << "\tcurrentShowType: "; switch (currentShowType()) { case drvbase::stroke: outf << "stroked"; break; case drvbase::fill: outf << "filled"; break; case drvbase::eofill: outf << "eofilled"; break; default: // cannot happen outf << "unexpected ShowType " << (int) currentShowType(); break; } outf << endl; outf << "\tcurrentLineWidth: " << currentLineWidth() << endl; outf << "\tcurrentR: " << currentR() << endl; outf << "\tcurrentG: " << currentG() << endl; outf << "\tcurrentB: " << currentB() << endl; outf << "\tedgeR: " << edgeR() << endl; outf << "\tedgeG: " << edgeG() << endl; outf << "\tedgeB: " << edgeB() << endl; outf << "\tfillR: " << fillR() << endl; outf << "\tfillG: " << fillG() << endl; outf << "\tfillB: " << fillB() << endl; outf << "\tcurrentLineCap: " << currentLineCap() << endl; outf << "\tdashPattern: " << dashPattern() << endl; outf << "\tPath Elements 0 to " << numberOfElementsInPath() - 1 << endl; print_coords(); }
void drvCAIRO::show_path() { DashPattern dp(dashPattern()); outf << endl; outf << " /*" << endl; outf << " * Path # " << currentNr() ; if (isPolygon()) outf << " (polygon):" << endl; else outf << " (polyline):" << endl; outf << " */" << endl; outf << endl; outf << " cairo_save (cr);" << endl; outf << " cairo_set_line_width (cr, " << currentLineWidth() << ");" << endl; // CAIRO_LINE_CAP_BUTT - start(stop) the line exactly at the start(end) point // CAIRO_LINE_CAP_ROUND - use a round ending, the center of the circle is the end point // CAIRO_LINE_CAP_SQUARE - use squared ending, the center of the square is the end point outf << " cairo_set_line_cap (cr, "; switch( currentLineCap() ) { case 0: outf << "CAIRO_LINE_CAP_BUTT);" << endl; break; case 1: outf << "CAIRO_LINE_CAP_ROUND);" << endl; break; case 2: outf << "CAIRO_LINE_CAP_SQUARE);" << endl; break; default: errf << "Unexpected currentLineCap() in cairo driver: " << currentLineCap() << endl; outf << "CAIRO_LINE_CAP_ROUND);" << endl; break; } // cairo_set_dash (cairo_t *cr, const double *dashes, int num_dashes, double offset); // dashes : // an array specifying alternate lengths of on and off stroke portions // // num_dashes : // the length of the dashes array // // offset : // an offset into the dash pattern at which the stroke should start // // dashPattern: has nrOfEntries, float *numbers, float offset if (dp.nrOfEntries > 0) { outf << " {" << endl; outf << " double pat[" << dp.nrOfEntries << "] = {" << endl; for (int i = 0; i < dp.nrOfEntries; i++) { outf << " " << dp.numbers[i] << ", " << endl; } outf << " };" << endl; outf << endl; outf << " cairo_set_dash (cr, pat, " << dp.nrOfEntries << ", " << dp.offset << ");" << endl; outf << " }" << endl; } else { outf << " cairo_set_dash (cr, NULL, 0, 0.0);" << endl; } // cairo_move_to (cr, 0.25, 0.25); // cairo_line_to (cr, 0.5, 0.375); outf << " /* Path Elements 0 to " << numberOfElementsInPath() - 1 << " */" << endl; print_coords(); switch (currentShowType()) { case drvbase::stroke: outf << " cairo_set_source_rgb (cr, " << edgeR() << "," << edgeG() << "," << edgeB() << ");" << endl; outf << " cairo_stroke (cr);" << endl; break; case drvbase::eofill: outf << " cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);" << endl; evenoddmode = true; case drvbase::fill: outf << " cairo_set_source_rgb (cr, " << fillR() << "," << fillG() << "," << fillB() << ");" << endl; outf << " cairo_fill_preserve (cr);" << endl; if (evenoddmode) { outf << " cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);" << endl; evenoddmode = false; } outf << " cairo_set_source_rgb (cr, " << edgeR() << "," << edgeG() << "," << edgeB() << ");" << endl; outf << " cairo_stroke (cr);" << endl; break; default: // cannot happen outf << " // unexpected ShowType " << (int) currentShowType(); break; } outf << " cairo_restore (cr);" << endl; }