summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4610b6f)
raw | patch | inline | side by side (parent: 4610b6f)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 12 Jul 2008 15:33:37 +0000 (15:33 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 12 Jul 2008 15:33:37 +0000 (15:33 +0000) |
src/display/inkscape-cairo.cpp | patch | blob | history | |
src/display/inkscape-cairo.h | patch | blob | history |
index 0697270648960f21cfba4b828413c25ed353f1fe..9210af1f41c35ed18e6280c6c79a9ee436fb8501 100644 (file)
@@ -156,8 +156,12 @@ feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::
}
+/*
+ * Can be called recursively.
+ * If optimize_stroke == false, the view Rect is not used.
+ */
static void
-feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix & trans, Geom::Rect view, bool optimize_stroke)
+feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix const & trans, Geom::Rect view, bool optimize_stroke)
{
if( dynamic_cast<Geom::LineSegment const*>(&c) ||
dynamic_cast<Geom::HLineSegment const*>(&c) ||
@@ -229,7 +233,32 @@ feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix & trans, Geo
}
-/** Feeds path-creating calls to the cairo context translating them from the SPCurve, with the given transform and shift */
+/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */
+void
+feed_path_to_cairo (cairo_t *ct, Geom::Path const &path)
+{
+ if (path.empty())
+ return;
+
+ cairo_move_to(ct, path.initialPoint()[0], path.initialPoint()[1] );
+
+ for(Geom::Path::const_iterator cit = path.begin(); cit != path.end_open(); ++cit) {
+ feed_curve_to_cairo(ct, *cit, Geom::identity(), Geom::Rect(), false); // optimize_stroke is false, so the view rect is not used
+ }
+
+ if (path.closed()) {
+ cairo_line_to(ct, path.initialPoint()[0], path.initialPoint()[1]);
+// cairo_close_path(ct);
+ /* I think we should use cairo_close_path(ct) here but it doesn't work. (the closing line is not rendered completely)
+ According to cairo documentation:
+ The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate
+ in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead,
+ there is a line join connecting the final and initial segments of the sub-path.
+ */
+ }
+}
+
+/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */
void
feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width)
{
@@ -255,8 +284,9 @@ feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR:
if (path.closed()) {
cairo_line_to(ct, initial[0], initial[1]);
- // I think we should use cairo_close_path(ct) here but it doesn't work. (the closing line is not rendered completely)
- /* according to cairo documentation:
+// cairo_close_path(ct);
+ /* I think we should use cairo_close_path(ct) here but it doesn't work. (the closing line is not rendered completely)
+ According to cairo documentation:
The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate
in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead,
there is a line join connecting the final and initial segments of the sub-path.
@@ -264,7 +294,7 @@ feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR:
}
}
-/** Feeds path-creating calls to the cairo context translating them from the SPCurve, with the given transform and shift */
+/** Feeds path-creating calls to the cairo context translating them from the PathVector, with the given transform and shift */
void
feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width)
{
@@ -278,6 +308,18 @@ feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matr
}
}
+/** Feeds path-creating calls to the cairo context translating them from the PathVector */
+void
+feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv)
+{
+ if (pathv.empty())
+ return;
+
+ for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) {
+ feed_path_to_cairo(ct, *it);
+ }
+}
+
/*
Local Variables:
mode:c++
index 5ac073c529188c5a1bb12319344cca1549156a72..02a145a331913ee4eff768b5961d62a805ed984e 100644 (file)
cairo_t *nr_create_cairo_context_canvasbuf (NRRectL *area, SPCanvasBuf *b);
cairo_t *nr_create_cairo_context (NRRectL *area, NRPixBlock *pb);
void feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width);
+void feed_path_to_cairo (cairo_t *ct, Geom::Path const &path);
void feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width);
void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width);
+void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv);
#endif
/*