Code

add dashed path option
authorbuliabyak <buliabyak@users.sourceforge.net>
Wed, 6 Aug 2008 05:20:51 +0000 (05:20 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Wed, 6 Aug 2008 05:20:51 +0000 (05:20 +0000)
src/display/canvas-bpath.cpp
src/display/canvas-bpath.h

index 15acece5e403791fba7e227c9483aafbf7a7c1b9..5f1262ced61a726eb6a30869da20e77d5c42ad8a 100644 (file)
@@ -197,6 +197,9 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf)
         // RGB / BGR
         cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(cbp->stroke_rgba), SP_RGBA32_G_F(cbp->stroke_rgba), SP_RGBA32_R_F(cbp->stroke_rgba), SP_RGBA32_A_F(cbp->stroke_rgba));
         cairo_set_line_width(buf->ct, 1);
+        if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) {
+            cairo_set_dash (buf->ct, cbp->dashes, 2, 0);
+        }
         cairo_stroke(buf->ct);
     }
 }
@@ -267,7 +270,7 @@ sp_canvas_bpath_set_fill (SPCanvasBPath *cbp, guint32 rgba, SPWindRule rule)
 }
 
 void
-sp_canvas_bpath_set_stroke (SPCanvasBPath *cbp, guint32 rgba, gdouble width, SPStrokeJoinType join, SPStrokeCapType cap)
+sp_canvas_bpath_set_stroke (SPCanvasBPath *cbp, guint32 rgba, gdouble width, SPStrokeJoinType join, SPStrokeCapType cap, double dash, double gap)
 {
     g_return_if_fail (cbp != NULL);
     g_return_if_fail (SP_IS_CANVAS_BPATH (cbp));
@@ -276,6 +279,8 @@ sp_canvas_bpath_set_stroke (SPCanvasBPath *cbp, guint32 rgba, gdouble width, SPS
     cbp->stroke_width = MAX (width, 0.1);
     cbp->stroke_linejoin = join;
     cbp->stroke_linecap = cap;
+    cbp->dashes[0] = dash;
+    cbp->dashes[1] = gap;
 
     sp_canvas_item_request_update (SP_CANVAS_ITEM (cbp));
 }
index bc3db883b85e85bbe3c074e9b99aa49bd4f5f3d5..d6382b65145655b117b7771158eb4a78cfd5c457 100644 (file)
@@ -73,6 +73,7 @@ struct SPCanvasBPath {
     /* Line attributes */
     guint32 stroke_rgba;
     gdouble stroke_width;
+    gdouble dashes[2];
     SPStrokeJoinType stroke_linejoin;
     SPStrokeCapType stroke_linecap;
     gdouble stroke_miterlimit;
@@ -92,7 +93,7 @@ SPCanvasItem *sp_canvas_bpath_new (SPCanvasGroup *parent, SPCurve *curve);
 
 void sp_canvas_bpath_set_bpath (SPCanvasBPath *cbp, SPCurve *curve);
 void sp_canvas_bpath_set_fill (SPCanvasBPath *cbp, guint32 rgba, SPWindRule rule);
-void sp_canvas_bpath_set_stroke (SPCanvasBPath *cbp, guint32 rgba, gdouble width, SPStrokeJoinType join, SPStrokeCapType cap);
+void sp_canvas_bpath_set_stroke (SPCanvasBPath *cbp, guint32 rgba, gdouble width, SPStrokeJoinType join, SPStrokeCapType cap, double dash=0, double gap=0);
 
 
 /*