I am developing an SVG converter for a specific purpose. SVG version is 1.1 which is a bit old, but I have to use this version.
I'm having a hard time trying to implement a clip list.
The clip structure is as follows.
struct
{
edgeList *path
clip *intersect
clip *union
} clip
Any clip object can have a intersecting clip or union clip or neither (but not both). So if there is an intersecting clip, I have to use intersect that clip path with the parent. If there is a union clip, I have to combine it with the parent.
According to SVG specification, I can use intersection of two clips by defining the two clipPath elements and using one of them in the clip-path attribute of the other clipPath. Union can be implemented such that you define both paths inside on clipPath element.
Now, what if I get a multiple clip paths? Say for example, 5 of them such that,
- The first two clips should intersect with each other
- The 3rd clip should combine with the previous result
- The 4th clip should intersect with the previous result
- The 5th clip should combine with the previous result
Note: The combined black area is the final clip area.

I can try to implement it like this.
<defs>
<clipPath id=cp1>
<path>red</path>
<clipPath>
<clipPath id=cp2 clip-path="#cp3">
<path clip-path="#cp1">green</path>
<path>purple</path>
<clipPath>
<clipPath id=cp3>
<path>yellow</path>
<clipPath>
</defs>
And I'm stuck at the 5th clip.
How would I union this? Besides, this method is harder to do programmatically. Is there a better way this? If there is no other way, I guess I will have to put it off as a limitation of SVG.