Skip to content

Commit cf35aba

Browse files
committed
🛠 SvgRenderer getPointString
1 parent b6ec5bb commit cf35aba

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

js/svg-renderer.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,23 @@ var round = SvgRenderer.round = function( num ) {
2424
return Math.round( num * 1000 ) / 1000;
2525
};
2626

27+
function getPointString( point ) {
28+
return round( point.x ) + ',' + round( point.y ) + ' ';
29+
}
30+
2731
SvgRenderer.begin = function() {};
2832

2933
SvgRenderer.move = function( svg, elem, point ) {
30-
return 'M' + round( point.x ) + ',' + round( point.y );
34+
return 'M' + getPointString( point );
3135
};
3236

3337
SvgRenderer.line = function( svg, elem, point ) {
34-
return 'L' + round( point.x ) + ',' + round( point.y );
38+
return 'L' + getPointString( point );
3539
};
3640

3741
SvgRenderer.bezier = function( svg, elem, cp0, cp1, end ) {
38-
return 'C' + round( cp0.x ) + ',' + round( cp0.y ) +
39-
' ' + round( cp1.x ) + ',' + round( cp1.y ) +
40-
' ' + round( end.x ) + ',' + round( end.y );
42+
return 'C' + getPointString( cp0 ) + getPointString( cp1 ) +
43+
getPointString( end );
4144
};
4245

4346
SvgRenderer.closePath = function(/* elem */) {

0 commit comments

Comments
 (0)