Canvas: add stroke-linejoin handling for path elements

This commit is contained in:
Torsten Dreyer 2014-08-26 00:05:01 +02:00
parent 088ce31f7c
commit 3ca7369fb2

View File

@ -70,7 +70,8 @@ namespace canvas
_mode(0), _mode(0),
_fill_rule(VG_EVEN_ODD), _fill_rule(VG_EVEN_ODD),
_stroke_width(1), _stroke_width(1),
_stroke_linecap(VG_CAP_BUTT) _stroke_linecap(VG_CAP_BUTT),
_stroke_linejoin(VG_JOIN_MITER)
{ {
setSupportsDisplayList(false); setSupportsDisplayList(false);
setDataVariance(Object::DYNAMIC); setDataVariance(Object::DYNAMIC);
@ -203,6 +204,21 @@ namespace canvas
_stroke_linecap = VG_CAP_BUTT; _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 * Draw callback
*/ */
@ -252,6 +268,7 @@ namespace canvas
vgSetf(VG_STROKE_LINE_WIDTH, _stroke_width); vgSetf(VG_STROKE_LINE_WIDTH, _stroke_width);
vgSeti(VG_STROKE_CAP_STYLE, _stroke_linecap); vgSeti(VG_STROKE_CAP_STYLE, _stroke_linecap);
vgSeti(VG_STROKE_JOIN_STYLE, _stroke_linejoin);
vgSetfv( VG_STROKE_DASH_PATTERN, vgSetfv( VG_STROKE_DASH_PATTERN,
_stroke_dash.size(), _stroke_dash.size(),
_stroke_dash.empty() ? 0 : &_stroke_dash[0] ); _stroke_dash.empty() ? 0 : &_stroke_dash[0] );
@ -426,6 +443,7 @@ namespace canvas
VGfloat _stroke_width; VGfloat _stroke_width;
std::vector<VGfloat> _stroke_dash; std::vector<VGfloat> _stroke_dash;
VGCapStyle _stroke_linecap; VGCapStyle _stroke_linecap;
VGJoinStyle _stroke_linejoin;
osg::Vec3f transformPoint( const osg::Matrix& m, osg::Vec3f transformPoint( const osg::Matrix& m,
osg::Vec2f pos ) const osg::Vec2f pos ) const
@ -506,6 +524,7 @@ namespace canvas
addStyle("stroke-width", "numeric", &PathDrawable::setStrokeWidth, path); addStyle("stroke-width", "numeric", &PathDrawable::setStrokeWidth, path);
addStyle("stroke-dasharray", "", &PathDrawable::setStrokeDashArray, path); addStyle("stroke-dasharray", "", &PathDrawable::setStrokeDashArray, path);
addStyle("stroke-linecap", "", &PathDrawable::setStrokeLinecap, path); addStyle("stroke-linecap", "", &PathDrawable::setStrokeLinecap, path);
addStyle("stroke-linejoin", "", &PathDrawable::setStrokeLinejoin, path);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------