Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path conversion for open paths #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions polymorph.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ polymorph = {
## transpose
Duplicate node positioning from one shape onto another
@param from {string} SVG shape containing the nodes to be copied
@param to {string} Resulting SVG shape which will contain a
@param to {string} Resulting SVG shape which will contain a
representation of the nodes from the first shape.
*/
polymorph.transpose = function(from, to){
Expand Down Expand Up @@ -88,5 +88,13 @@ polymorph.transpose = function(from, to){
measures = getMeasures(from);
newShape = transpose(measures, to);
svg.parentNode.removeChild(svg);
return "M" + newShape.join('L') + "Z";
};

var newPath = "M" + newShape.join('L');

// Close shape if input shape is closed
if (from.indexOf("Z") > -1) {
newPath += "Z";
}

return newPath;
};