User Tools

Site Tools


gestures:touch:simple:spatial:scale:n-scale

N-Scale

(Touch → Spacial → Scale → Simple N Point Scale Gesture “N-Scale”)



The N-Scale gesture is designed to provide object scaling or zoom functionality using any number of touch points. It is considered to be one of the three fundamental object manipulation gestures.

This gesture can be activated by any number of touch points between 2 and 10. When two or more touch points are recognized on a touch object the relative separation of the touch points are tracked and grouped into a cluster. Changes in the separation of the cluster can be mapped directly to the scale of the touch interactive display object. The scale gesture is typically dispatched as a continuous event stream which is terminated when touch points are removed.

The scale gesture can be used to define a dynamic center for scaled media (affine transform) by using the returned cluster center to optionally redefine the center of transformation of associated media objects.

<Gesture id="n-scale" type="scale">
    <match>
        <action>
            <initial>
                <cluster point_number="0" point_number_min="2" point_number_max="10"/>
            </initial>
        </action>
    </match>
    <analysis>
        <algorithm class="kinemetric" type="continuous">
            <library module="scale"/>
                <returns>
                    <property id="scale_dsx" result="ds"/>
                    <property id="scale_dsy" result="ds"/>
                </returns>
        </algorithm>
    </analysis>    
    <mapping>
        <update dispatch_type="continuous">
            <gesture_event  type="scale">
                <property ref="scale_dsx" target="scaleX"/>
                <property ref="scale_dsy" target="scaleY"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>

Independent Axis Expansion

It is common to use a locked scale transform where the change in the separation of touch points in the cluster is axis independent. In some cases it may be required to analyze the vertical and horizontal components of the scale gesture (to stretch media along a defined axis). This can be done by returning each component from the kinemetric. For example:

Horizontal Scale Gesture

<Gesture id="n-scalex" type="scale">
    <match>
        <action>
            <initial>
                <cluster point_number="0" point_number_min="2" point_number_max="10"/>
            </initial>
        </action>
    </match>
    <analysis>
        <algorithm class="kinemetric" type="continuous">
            <library module="scale"/>
                <returns>
                    <property id="scale_dsx" result="dsx"/>
                </returns>
        </algorithm>
    </analysis>    
    <mapping>
        <update dispatch_type="continuous">
            <gesture_event  type="scale">
                <property ref="scale_dsx" target="scaleX"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>


The above GML defines a scale gesture that only considers the horizontal separation of the touch point cluster and applies it directly to the x component of scaled media associated with the interaction.

Vertical Scale gesture

<Gesture id="n-scaley" type="scale">
    <match>
        <action>
            <initial>
                <cluster point_number="0" point_number_min="2" point_number_max="10"/>
            </initial>
        </action>
    </match>
    <analysis>
        <algorithm class="kinemetric" type="continuous">
            <library module="scale"/>
                <returns>
                    <property id="scale_dsy" result="dsy"/>
                </returns>
        </algorithm>
    </analysis>    
    <mapping>
        <update dispatch_type="continuous">
            <gesture_event  type="scale">
                <property ref="scale_dsy" target="scaleY"/>
            </gesture_event>
        </update>
    </mapping>
</Gesture>


Conversely the above GML defines a scale gesture that only considers the vertical separation of the touch point cluster and applies it directly to the y component of scaled media associated with the interaction.
gestures/touch/simple/spatial/scale/n-scale.txt · Last modified: 2015/12/16 20:19 by paul