SwipeGestureΒΆ
Methods:
The SwipeGesture class represents a swiping motion a finger or tool.
SwipeGesture objects are generated for each visible finger or tool. Swipe gestures are continuous; a gesture object with the same ID value will appear in each frame while the gesture continues.
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);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 Controller 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", 200.0); controller.config().setFloat("Gesture.Swipe.MinVelocity", 750); controller.config().save();The Controller object must be connected to the Leap Motion service/daemon before setting the configuration parameters.
Public Functions
- Since
- 1.0
Public Static FunctionsVector direction()The unit direction vector parallel to the swipe motion.
Leap::Vector swipeDirection = 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
- Vector The unit direction vector representing the swipe motion.
- Since
- 1.0
Pointable pointable()The finger performing the swipe gesture.
Leap::Pointable swiper = swipe.pointable();Vector position()The current position of the swipe.
Leap::Vector currentSwipePosition = swipe.position();
- Return
- Vector The current swipe position within the Leap Motion frame of reference, in mm.
- Since
- 1.0
float speed()The swipe speed in mm/second.
float currentSwipeSpeed = swipe.speed();
- Return
- float The speed of the finger performing the swipe gesture in millimeters per second.
- Since
- 1.0
Vector startPosition()The position where the swipe began.
Leap::Vector swipeStart = swipe.startPosition();
- Return
- Vector The starting position within the Leap Motion frame of reference, in mm.
- Since
- 1.0
SwipeGesture(const Gesture & rhs)Constructs a SwipeGesture object from an instance of the Gesture class.
Leap::SwipeGesture swipeGesture = Leap::Gesture::invalid(); if(gesture.type() == Leap::Gesture::TYPE_SWIPE) swipeGesture = Leap::SwipeGesture(gesture);
- Since
- 1.0
- Parameters
- rhs -
The Gesture instance to specialize. This Gesture instance must be a SwipeGesture object.
Type classType()The swipe gesture type.
Leap::SwipeGesture swipeGesture = Leap::Gesture::invalid(); if(gesture.type() == Leap::SwipeGesture::classType()) swipeGesture = Leap::SwipeGesture(gesture);
- Return
- Type The type value designating a swipe gesture.
- Since
- 1.0
