two.js icon indicating copy to clipboard operation
two.js copied to clipboard

Clipping group with multiple paths

Open grrowl opened this issue 6 years ago • 1 comments

Currently two.js can only create an svg clipPath with a single path, as commented here: https://github.com/jonobr1/two.js/blob/06392d97b7e1753c97874c79845e43b232fb7c60/src/renderer/svg.js#L324-L328

It seems true that we can't add a <g> as a child of <clipPath>, but it does seem to work just adding multiple <path>s within the <clipPath>, without grouping. Is there any plans to implement rendering a group as a clipPath in the future to support this?

I forked a codepen to illustrate how this can be done

grrowl avatar Oct 30 '19 06:10 grrowl

Thanks for raising this issue! I didn't know that multiple children to the clipPath worked. In this case I could re-introduce setting a Two.Group as the mask property. In the background I can handle adding elements to the same clipPath. In the meantime this is a (hacky) workaround: https://jsfiddle.net/jonobr1/xfocL3ye/

jonobr1 avatar Oct 30 '19 08:10 jonobr1