Merge pull request #41 from Janpot/fix-clip

.clip was not working, the path never made it to the clip area
This commit is contained in:
clintjd 2016-04-21 11:48:22 -07:00
commit 92464d63b6
2 changed files with 13 additions and 0 deletions

View File

@ -1029,6 +1029,7 @@
id = randomString(this.__ids),
newGroup = this.__createElement("g");
this.__applyCurrentDefaultPath();
group.removeChild(this.__currentElement);
clipPath.setAttribute("id", id);
clipPath.appendChild(this.__currentElement);

View File

@ -332,4 +332,16 @@ describe('canvas2svg', function() {
expect(svg.querySelector("path").getAttribute("stroke-opacity")).to.equal(''+0.8*0.5);
});
});
describe("supports clip", function() {
it("adds clippath", function() {
var ctx = new C2S();
ctx.rect(200, 200, 400, 400);
ctx.clip();
ctx.fillStyle = "#000000";
ctx.rect(100, 100, 300, 300);
var svg = ctx.getSvg();
expect(svg.querySelector("clipPath > path").getAttribute("d")).to.not.equal(null);
});
});
});