Creating an editor for low-resolution vector graphics drawings

128 views Asked by At

The goal is to create tiny 256x256 pixel vector drawings using line segments that require only one byte for each coordinate, so 32 bits total per line segment. The motivation is to create a game map and use the line segments for collision detection. By dividing the map up into 256x256 blocks, we make it easy to determine which line segments are close enough to be candidates for collision.

Since we don't intend to display these vector drawings at greater than 256x256 and we benefit from having fewer line segments rather than more, we want to eliminate line segments that are going to be invisible when rendered. If two line segments are so close together than their pixels overlap when rasterized, then we want to somehow detect that situation and merge together the overlapping parts of the line segments.

For example, if a polygon has a corner that is too sharp to properly represent in 256x256, then we should automatically cut off that corner.

It's easy enough to find algorithms for detecting the distance between two line segments, but that's not exactly what we're trying to do here. There's no particular minimum distance between segments; the issue is detecting when two segments are on the same pixel, and merging them together without seriously affecting how the rest of the drawing looks.

Is there some trick to turn this from a awkwardly complicated computational geometry problem into a simple problem?

0

There are 0 answers