How to use the pts.Polygon.convexHull function in pts

To help you get started, we’ve selected a few pts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github williamngan / pts-starter-kit / src / app.js View on Github external
animate: (time, ftime) => {

    landmarks[landmarks.length-1] = space.pointer;

    // convex hull the points
    let hull = Polygon.convexHull( landmarks );

    // eyes' positions
    let left = space.center.$subtract( 50 );
    let right = space.center.$add( 50, -50 );
    let leftB = left.clone().toAngle( space.pointer.$subtract( left ).angle(), 10, left );
    let rightB = right.clone().toAngle( space.pointer.$subtract( right ).angle(), 10, right );

    // draw face and eyes
    form.fillOnly("rgba(255, 255, 255, 0.5)").polygon( hull );
    form.fill("#fff").points( [left, right], 20, "circle" );
    form.fill("#123").points( [leftB, rightB], 5, "circle" );

    // draw the hull and pts
    form.fill("#fff").points( hull, 5, "circle" );
    form.fill("rgba(0,0,0,.5)").points( landmarks, 2, "circle" );
    form.fill("#f03").point( space.pointer, 10, "circle" );