Today I have a (simple) rendering problem for you. My current project gets data from a file to create an SVG file. Drawing things as a polygon is quite simple thanks to the SVG format, but I have one problem: some of my polygons are in AND from the page (this means that some parts of them are displayed, and the rest are not displayed due to the fact that they are outside the limits display). To optimize the final SVG file, I need to reduce my polygon to a simpler shape.
Consider the gray rectangle as my page. Consider the green polygon as the thing that I actually draw.
The first photo shows you what I actually have, and the second photo shows the final result that I want to have.

At first I decided to reduce my polygon in simple triangles so that I could draw points only within the boundaries of the display. But I think there is a simpler solution ... if you have this, feel free to share it with me :)
EDIT:
I have this difficult case:


Thank.
source
share