CircleGesture

Attributes:

class CircleGesture()

The CircleGesture classes represents a circular finger movement.

A circle movement is recognized when the tip of a finger draws a circle within the Leap field of view.

CircleGestureImage

Circle gestures are continuous. The CircleGesture objects for the gesture have three possible states:

  • start – The circle gesture has just started. The movement has progressed far enough for the recognizer to classify it as a circle.
  • update – The circle gesture is continuing.
  • stop – The circle gesture is finished.

An uninitialized CircleGesture object is considered invalid. Get valid instances of the CircleGesture class from a Frame object or a gesture event listener.

The following example illustrates how to get gesture objects from a frame of tracking data:

var controller = Leap.loop({enableGestures: true}, function(frame){
  if(frame.valid && frame.gestures.length > 0){
    frame.gestures.forEach(function(gesture){
        switch (gesture.type){
          case "circle":
              console.log("Circle Gesture");
              break;
          case "keyTap":
              console.log("Key Tap Gesture");
              break;
          case "screenTap":
              console.log("Screen Tap Gesture");
              break;
          case "swipe":
              console.log("Swipe Gesture");
              break;
        }
    });
  }
});

You can also add a listener callback to a Controller object. Your callback is called for each gesture object in each device frame:

var controller = Leap.loop({enableGestures: true}, function(frame){
  //... handle frame data
});

controller.on("gesture", function(gesture){
  //... handle gesture object
});

Extends Gesture()

CircleGesture.center
Type:number[] – a 3-element array representing a point in space.

The center point of the circle within the Leap frame of reference.

if(gesture.type == "circle"){
  var circleCenter = gesture.center;
}

Leap Motion 1.0 and LeapJS 0.2.0

CircleGesture.duration
Type:number

The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds.

var duration = gesture.duration;

The duration reported for the first Gesture in the sequence (with the start state) will typically be a small positive number since the movement must progress far enough for the Leap to recognize it as an intentional gesture.

Leap Motion 1.0 and LeapJS 0.2.0

CircleGesture.handIds
Type:array

The list of hands associated with this Gesture, if any.

var controller = Leap.loop({enableGestures: true}, function(frame){
  if(frame.valid && frame.gestures.length > 0){
    frame.gestures.forEach(function(gesture){
        var handIds = gesture.handIds;
        handIds.forEach(function(handId){
          var hand = frame.hand(handId);
        });
    });
  }
});

If no hands are related to this gesture, the list is empty.

Leap Motion 1.0 and LeapJS 0.3.0

CircleGesture.id
Type:number

The gesture ID.

All Gesture objects belonging to the same recognized movement share the same ID value.

var gestureIdOfInterest = gesture.id;

Leap Motion 1.0 and LeapJS 0.3.0

CircleGesture.normal
Type:number[] – a 3-element array representing a unit direction vector.

The normal vector for the circle being traced.

If you draw the circle clockwise, the normal vector points in the same general direction as the pointable object drawing the circle. If you draw the circle counterclockwise, the normal points back toward the pointable. If the angle between the normal and the pointable object drawing the circle is less than 90 degrees, then the circle is clockwise. You can use the sign of the dot product of the two vectors to determine whether the direction and normal are pointing in the same general direction, or not:

var clockwise = false;
var pointableID = gesture.pointableIds[0];
var direction = frame.pointable(pointableID).direction;
var dotProduct = Leap.vec3.dot(direction, gesture.normal);

if (dotProduct  >  0) clockwise = true;

Leap Motion 1.0 and LeapJS 0.3.0

CircleGesture.pointableIds

The list of fingers and tools associated with this Gesture, if any.

var controller = Leap.loop({enableGestures: true}, function(frame){
  if(frame.valid && frame.pointables.length > 0){
    frame.gestures.forEach(function(gesture){
        var pointableIds = gesture.pointableIds;
        pointableIds.forEach(function(pointableId){
          var pointable = frame.pointable(pointableId);
        });
    });
  }
});

If no Pointable objects are related to this gesture, the list is empty.

Type: Array

Leap Motion 1.0 and LeapJS 0.3.0

CircleGesture.progress
Type:number

The number of times the finger tip has traversed the circle.

Progress is reported as a positive number of the number. For example, a progress value of .5 indicates that the finger has gone halfway around, while a value of 3 indicates that the finger has gone around the the circle three times.

if(gesture.type == "circle"){
  var circleProgress = gesture.progress;
  var completeCircles = Math.floor(circleProgress);
}

Progress starts where the circle gesture began. Since the circle must be partially formed before the Leap can recognize it, progress will be greater than zero when a circle gesture first appears in the frame.

Leap Motion 1.0 and LeapJS 0.3.0

CircleGesture.radius
Type:number

The radius of the circle in mm.

if(gesture.type == "circle"){
  var circleRadius = gesture.radius;
}

Leap Motion 1.0 and LeapJS 0.3.0

CircleGesture.state
Type:string – one of: “start”, “update”, or “stop”

The gesture state.

Recognized movements occur over time and have a beginning, a middle, and an end. The ‘state’ attribute reports where in that sequence this Gesture object falls.

Possible values for the state field are:

  • “start”
  • “update”
  • “stop”
var state = gesture.state;

Leap Motion 1.0 and LeapJS 0.3.0

CircleGesture.type
Type:string

The gesture type; in this case, “circle”.

var controller = Leap.loop({enableGestures: true}, function(frame){
  if(frame.valid && frame.gestures.length > 0){
    frame.gestures.forEach(function(gesture){
        switch (gesture.type){
          case "circle":
              console.log("Circle Gesture");
              break;
          case "keyTap":
              console.log("Key Tap Gesture");
              break;
          case "screenTap":
              console.log("Screen Tap Gesture");
              break;
          case "swipe":
              console.log("Swipe Gesture");
              break;
        }
    });
  }
});

Leap Motion 1.0 and LeapJS 0.3.0