From: Torsten Dreyer Date: Mon, 25 Aug 2014 22:05:01 +0000 (+0200) Subject: Canvas: add stroke-linejoin handling for path elements X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3ca7369fb2837e70bdc31dbd13b90060856df53f;p=simgear.git Canvas: add stroke-linejoin handling for path elements --- diff --git a/simgear/canvas/elements/CanvasPath.cxx b/simgear/canvas/elements/CanvasPath.cxx index 9eddcb31..a2d0c1a5 100644 --- a/simgear/canvas/elements/CanvasPath.cxx +++ b/simgear/canvas/elements/CanvasPath.cxx @@ -70,7 +70,8 @@ namespace canvas _mode(0), _fill_rule(VG_EVEN_ODD), _stroke_width(1), - _stroke_linecap(VG_CAP_BUTT) + _stroke_linecap(VG_CAP_BUTT), + _stroke_linejoin(VG_JOIN_MITER) { setSupportsDisplayList(false); setDataVariance(Object::DYNAMIC); @@ -203,6 +204,21 @@ namespace canvas _stroke_linecap = VG_CAP_BUTT; } + /** + * Set stroke-linejoin + * + * @see http://www.w3.org/TR/SVG/painting.html#StrokeLinejoinProperty + */ + void setStrokeLinejoin(const std::string& linejoin) + { + if( linejoin == "round" ) + _stroke_linejoin = VG_JOIN_ROUND; + else if( linejoin == "bevel" ) + _stroke_linejoin = VG_JOIN_BEVEL; + else + _stroke_linejoin = VG_JOIN_MITER; + } + /** * Draw callback */ @@ -252,6 +268,7 @@ namespace canvas vgSetf(VG_STROKE_LINE_WIDTH, _stroke_width); vgSeti(VG_STROKE_CAP_STYLE, _stroke_linecap); + vgSeti(VG_STROKE_JOIN_STYLE, _stroke_linejoin); vgSetfv( VG_STROKE_DASH_PATTERN, _stroke_dash.size(), _stroke_dash.empty() ? 0 : &_stroke_dash[0] ); @@ -426,6 +443,7 @@ namespace canvas VGfloat _stroke_width; std::vector _stroke_dash; VGCapStyle _stroke_linecap; + VGJoinStyle _stroke_linejoin; osg::Vec3f transformPoint( const osg::Matrix& m, osg::Vec2f pos ) const @@ -506,6 +524,7 @@ namespace canvas addStyle("stroke-width", "numeric", &PathDrawable::setStrokeWidth, path); addStyle("stroke-dasharray", "", &PathDrawable::setStrokeDashArray, path); addStyle("stroke-linecap", "", &PathDrawable::setStrokeLinecap, path); + addStyle("stroke-linejoin", "", &PathDrawable::setStrokeLinejoin, path); } //----------------------------------------------------------------------------