LeapSwipeGestureΒΆ
Properties:
Methods:
The LeapSwipeGesture class represents a swiping motion of fingers and tools.
SwipeGesture objects are generated for each swiping finger or tool. Swipe gestures are continuous; a gesture object with the same ID value will appear in each frame while the gesture continues. The LeapSwipeGesture objects for the gesture have three possible states:
LEAP_GESTURE_STATE_START The gesture has just started.
LEAP_GESTURE_STATE_UPDATE The swipe gesture is continuing.
LEAP_GESTURE_STATE_STOP The swipe gesture is finished.
Important: To use swipe gestures in your application, you must enable recognition of the swipe gesture. You can enable recognition with:
[controller enableGesture:LEAP_GESTURE_TYPE_SWIPE enable:YES];You can set the minimum length and velocity required for a movement to be recognized as a swipe using the config attribute of a connected LeapController object. Use the following keys to configure swipe recognition:
Key string Value type Default value Units Gesture.Swipe.MinLength float 150 mm Gesture.Swipe.MinVelocity float 1000 mm/s The following example demonstrates how to set the swipe configuration parameters:
[controller.config setFloat:@"Gesture.Swipe.MinLength" value:200.0]; [controller.config setFloat:@"Gesture.Swipe.MinVelocity" value:750]; [controller.config save];The LeapController object must be connected to the Leap Motion service/daemon before setting the configuration parameters.
Public Functions
- Since 1.0
Property- (BOOL) equals:(const LeapGesture *) otherCompare LeapGesture object equality.
Two LeapGestures are equal if they represent the same snapshot of the same recognized movement.
[thisGesture equals:thatGesture];
- Since 1.0
- Parameters
- other -
The LeapGesture object to compare.
- (LeapPointable *) pointableThe finger or tool performing the swipe gesture.
LeapPointable *gesturer = swipe.pointable;
- Return
- A LeapPointable object representing the swiping finger or tool.
- Since 1.0
Public Static Functionsdirection- (LeapVector *) directionThe unit direction vector parallel to the swipe motion.
LeapVector *direction = swipe.direction;You can compare the components of the vector to classify the swipe as appropriate for your application. For example, if you are using swipes for two dimensional scrolling, you can compare the x and y values to determine if the swipe is primarily horizontal or vertical.
- Return
- LeapVector The unit direction vector representing the swipe motion.
- Since 1.0
duration- (int64_t) durationThe elapsed duration of the recognized movement up to the frame containing this LeapGesture object, in microseconds.
int64_t microseconds = gesture.duration;The duration reported for the first LeapGesture in the sequence (with the LEAP_GESTURE_STATE_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.
- Return
- int64_t the elapsed duration in microseconds.
- Since 1.0
durationSeconds- (float) durationSecondsThe elapsed duration in seconds.
float seconds = gesture.duration;
- See
- duration
- Return
- float the elapsed duration in seconds.
- Since 1.0
frame- (LeapFrame *) frameThe LeapFrame containing this LeapGesture instance.
LeapFrame *owningFrame = gesture.frame;
- Return
- The parent LeapFrame object.
- Since 1.0
hands- (NSArray *) handsThe list of hands associated with this LeapGesture, if any.
NSArray *handList = gesture.hands; //Only one hand for current gestures LeapHand *gesturingHand = [handList objectAtIndex:0];If no hands are related to this gesture, the list is empty.
- Return
- NSArray the list of related LeapHand objects.
- Since 1.0
id- (int32_t) idThe gesture ID.
All LeapGesture objects belonging to the same recognized movement share the same ID value. Use the ID value with the [LeapFrame gesture:] method to find updates related to this LeapGesture object in subsequent frames.
int gestureID = gesture.id;
- Return
- int32_t the ID of this LeapGesture.
- Since 1.0
isValid- (BOOL) isValidReports whether this LeapGesture instance represents a valid gesture.
An invalid LeapGesture object does not represent a snapshot of a recognized movement. Invalid LeapGesture objects are returned when a valid object cannot be provided. For example, when you get an gesture by ID using [LeapFrame gesture:], and there is no gesture with that ID in the current frame, then gesture: returns an Invalid LeapGesture object (rather than a null value). Always check object validity in situations where an gesture might be invalid.
LeapFrame *frame = [controller frame:0]; LeapGesture *trackedGesture = [frame gesture:trackedGestureID]; if(trackedGesture.isValid) { //Use the data... }
- Return
- bool Yes, if this is a valid LeapGesture instance; NO, otherwise.
- Since 1.0
pointables- (NSArray *) pointablesThe list of fingers and tools associated with this LeapGesture, if any.
NSArray *pointableList = gesture.pointables; //Only one pointable for current gestures LeapHand *gesturingPointable = [pointableList objectAtIndex:0];If no LeapPointable objects are related to this gesture, the list is empty.
- Return
- NSArray the list of related LeapPointable objects.
- Since 1.0
position- (LeapVector *) positionThe current position of the swipe.
LeapVector *current = swipe.position;
- Return
- LeapVector The current swipe position within the Leap frame of reference, in mm.
- Since 1.0
speed- (float) speedThe swipe speed in mm/second.
float velocity = swipe.speed;
- Return
- float The speed of the finger performing the swipe gesture in millimeters per second.
- Since 1.0
startPosition- (LeapVector *) startPositionThe position where the swipe began.
LeapVector *start = swipe.startPosition;
- Return
- LeapVector The starting position within the Leap frame of reference, in mm.
- Since 1.0
state- (LeapGestureState) stateThe 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 LeapGesture object falls.
LeapGestureState state = gesture.state;The possible gesture states are defined by the LeapGestureState enumeration:
LEAP_GESTURE_STATE_INVALID An invalid state.
LEAP_GESTURE_STATE_START The gesture is starting. Just enough has happened to recognize it.
LEAP_GESTURE_STATE_UPDATE The gesture is in progress. (Note: not all gestures have updates).
LEAP_GESTURE_STATE_STOP The gesture has completed or stopped.
- Return
- LeapGestureState A value from the LeapGestureState enumeration.
- Since 1.0
type- (LeapGestureType) typeThe gesture type.
LeapGestureType type = gesture.type;The supported types of gestures are defined by the LeapGestureType enumeration:
LEAP_GESTURE_TYPE_INVALID An invalid type.
LEAP_GESTURE_TYPE_SWIPE A straight line movement by the hand with fingers extended.
LEAP_GESTURE_TYPE_CIRCLE A circular movement by a finger.
LEAP_GESTURE_TYPE_SCREEN_TAP A forward tapping movement by a finger.
LEAP_GESTURE_TYPE_KEY_TAP A downward tapping movement by a finger.
- Return
- LeapGestureType A value from the LeapGestureType enumeration.
- Since 1.0
+ (LeapGesture *) invalidReturns an invalid LeapGesture object.
LeapGesture *wrongGesture = LeapGesture.invalid;
- Return
- The invalid LeapGesture instance.
- Since 1.0
