You see, the problem is that Horizontal Line
command takes only one parameter (docs). As your helper function always provides two parameters, after function evaluation you end up with something like this:
paper.path('M70,30H110,30');
Which obviously does not correspond to expected input.
You could change your helper functions to generate something like this:
paper.path('M70,30H110');
But in this case simplest solution is to use Line To
command instead of Horizontal Line
command (change H
to L
). Line To
takes two arguments. So you would end up with something like this:
paper.path('M70,30L110,30');
In your code sample just change H
to L
.
...
paper.path(p1.toPath('M') + p2.toPath('L'));
...
See the fiddle here