Skip to content

Template class for clipping 2d polygons to bounding box. Clips also optional attributes such as texcoords and colors.

License

Notifications You must be signed in to change notification settings

BrakusSkullgear/Polygon_Bounding_Box_Clip_2d

Repository files navigation

Polygon_Bounding_Box_Clip_2d

Simple and easy to read template class for clipping 2d polygons to bounding box. Vertex positions are clipped to bounding box, and other optional attributes such as texcoord and color are interpolated based on the clipped position values.

Class accepts a single line, triangle or convex quad, and clips it into multiple polygons of the requested type.

See main.cpp for an example. Various types of vertexes are introduced in Vertex2d.h – file.

Example input:
alt text

Example output:
alt text


Feel free to use the codes as you like. Also if you are interested to see these codes in action, check out my game Dandy Boy Adventures: https://dandyboyoni.itch.io/dandyboyadventures WARNING, game contains adult content!

About

Template class for clipping 2d polygons to bounding box. Clips also optional attributes such as texcoords and colors.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages