SVG: Output 'h' and 'v' commands in #getPathData()

This commit is contained in:
Jürg Lehni 2016-07-18 21:07:30 +02:00
parent 32d8c969fb
commit ad48e93ee9
2 changed files with 9 additions and 5 deletions

View file

@ -284,7 +284,7 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
paths.push(child.getPathData(_matrix && !mx.isIdentity()
? _matrix.appended(mx) : _matrix, _precision));
}
return paths.join(' ');
return paths.join('');
}
}, /** @lends CompoundPath# */{
_hitTestChildren: function _hitTestChildren(point, options, viewMatrix) {

View file

@ -318,13 +318,17 @@ var Path = PathItem.extend(/** @lends Path# */{
} else {
inX = coords[2];
inY = coords[3];
// TODO: Add support for H/V and/or relative commands, where
// appropriate and resulting in shorter strings.
if (inX === curX && inY === curY
&& outX === prevX && outY === prevY) {
// l = relative lineto:
if (!skipLine)
parts.push('l' + f.pair(curX - prevX, curY - prevY));
if (!skipLine) {
var dx = curX - prevX,
dy = curY - prevY;
parts.push(
dx === 0 ? 'v' + f.number(dy)
: dy === 0 ? 'h' + f.number(dx)
: 'l' + f.pair(dx, dy));
}
} else {
// c = relative curveto:
parts.push('c' + f.pair(outX - prevX, outY - prevY)