mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
SVG: Output 'h' and 'v' commands in #getPathData()
This commit is contained in:
parent
32d8c969fb
commit
ad48e93ee9
2 changed files with 9 additions and 5 deletions
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue