[toxiclibs] offsetShape

I'm developing a sketch that draws the silhouette from kinect users. My workflow is SimpleOpeniNI(get body) -> OpenCV(generates first contour) -> toxiclibs(offset contours). So far so good, it's working fine.

The problem lies at the offsetShape() that is glitching at concave curves.

offsetPath() is a method of the built in Polygon2D object that offsets the Polygon2D a given distance, i.e. calculates the normal and 'moves' the vertex a given distance. offsetShape() calls offsetCorner(). it works ok for convex curves but it's not good for concave curves. it also has problems with video images(camera refresh).

is there ay way to get fix this?! there is a boolean function toOutline but i believe i'm not using it right.

my offset function:

void offsetPoly(int num) {
  for (int i=0; i<num; i++) {
    Polygon2D poly = polygons.get(polygons.size()-1).copy();

    poly=poly.reduceVertices(2);
    poly = poly.offsetShape(-10);
    poly.toOutline();

    polygons.add(poly);
  }
}

Polygon2D code is here: https://github.com/postspectacular/toxiclibs/blob/master/src.core/toxi/geom/Polygon2D.java

Sign In or Register to comment.