User Tools

Site Tools


using_the_multiply_filter_to_create_fast-drag_gesture

Using The "Multiply Filter" To Create Fast-Drag Gesture

The Multiply Filter

The multiply filter is a simple filter that is inserted into the processing block of a gesture object and enables the result each gesture dimension to be multiplied. In this example each dimension is multiplied by a factor of two. This has the effect of doubling the return value.

<Gesture id="2-point-power-drag" type="drag">
    <match>
        <action>
            <initial>
                <cluster point_number="2"/>
            </initial>
        </action>
    </match>       
    <analysis>
         <algorithm class="kinemetric" type="continuous">
            <library module="drag"/>
            <returns>
                <property id="dx" result="dx"/>
                <property id="dy" result="dy"/>
            </returns>
        </algorithm>
    </analysis>
    <processing>
        <multiply_filter>
            <property ref="dx" active="true" factor="2"/>
            <property ref="dy" active="true" factor="2"/>
        </multiply_filter>
    </processing>
    <mapping>
        <update dispatch_type="continuous">
            <gesture_event type="drag">
                <property ref="dx" target="x"/>
                <property ref="dy" target="y"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>

The “2-point-power-drag” moves touch objects twice as fast as the calculated velocity of the touch point cluster. This is a great gesture for power sliding across a long list of menu items.
The multiply filter can be dynamically activated on each dimension by setting active=“true”. This can be done independently. For example this gesture will drag objects normally in the x direction but twice as fast in the y direction:

<Gesture id="2-point-power-drag-y-only" type="drag">
    <match>
        <action>
            <initial>
                <cluster point_number="2"/>
            </initial>
        </action>
    </match>       
    <analysis>
        <algorithm class="kinemetric" type="continuous">
            <library module="drag"/>
            <returns>
                <property id="dx" result="dx"/>
                <property id="dy" result="dy"/>
            </returns>
        </algorithm>
    </analysis>
    <processing>
        <multiply_filter>
            <property ref="dx" active="false"/>
            <property ref="dy" active="true" factor="2"/>
        </multiply_filter>
    </processing>
     <mapping>
        <update dispatch_type="continuous">
            <gesture_event type="drag">
                <property ref="dx" target="x"/>
                <property ref="dy" target="y"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>

The multiplication factor can be any negative or positive value. Setting factor to “-1” will effectively reflect the value of the gesture dimension. For example in this example the motion of the drag gesture will be in the opposite direction to the gesture action:

<Gesture id="2-point-drag-reflected" type="drag">
    <match>
        <action>
            <initial>
                <cluster point_number="2"/>
            </initial>
        </action>
    </match>       
    <analysis>
        <algorithm class="kinemetric" type="continuous">
            <library module="drag"/>
            <returns>
                <property id="dx" result="dx"/>
                <property id="dy" result="dy"/>
             </returns>
        </algorithm>
    </analysis>
    <processing>
        <multiply_filter>
            <property ref="dx" active="true" factor="-1"/>
            <property ref="dy" active="true" factor="-1"/>
        </multiply_filter>
    </processing>
    <mapping>
        <update dispatch_type="continuous">
            <gesture_event type="drag">
                <property ref="dx" target="x"/>
                <property ref="dy" target="y"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>

The multiply filter can also multiply the result of a gesture dimension by a non-linear function of the factor. There are four different non linear methods available in the multiply filter:

using_the_multiply_filter_to_create_fast-drag_gesture.txt · Last modified: 2015/10/09 22:15 by paul