}

    function getSelectedPolygon(loc) {
        for (var i=0; i < polygons.length; ++i) {
            var polygon = polygons[i];

            polygon.createPath(context);
            if (context.isPointInPath(loc.x, loc.y)) {
                startDragging(loc);
                draggingOffsetX = loc.x - polygon.x;
                draggingOffsetY = loc.y - polygon.y;
                return polygon;
            }
        }
        return undefined;
    }

    function stopRotatingPolygon(loc) {
        angle