A Cartesian coordinate system is used. Its origin (0,0) is the center of the graphics window.
To simplify things, use the Transformation Matrix Functions found in another project ("Demonstrate using a graphics transformation matrix (2D and/or 3D)").
a. Create an object using line segments and points
b. Define a fold line using two points outside of the object.
c. Determine where the fold line crosses any of the object's line segments.
Break these line segments into two line segments at the intersection
point.
d. locate the center of the fold line.
Note: For simplicity, the fold line should intersect with only two line segments. It should not weave in and out of the object.
Translate (move) the object so the fold line's center is at the center of the graphics window.
Rotate the object so the fold line is parallel to the Y axes and passes through the graphics window's center.
Fold the object.
This is made easy because the fold line is parallel to the Y axes and goes through the origin (0,0).
Any coordinate (X,Y) that has a negative X value can be
folded to the right of the center line (fold line) by changing its sign.
Translate/rotate the modified object to its original position.
Clear the graphics screen and redraw the object using the modified line segments and points.