Pinch
Entity → ceramic.Pinch (Class)
Implements: Component
A pinch gesture detector that recognizes two-finger pinch gestures.
Warning: this is just a draft, don't use it!
Pinch can be used standalone or as a component attached to any Visual. It detects and reports:
- Scale changes (zoom in/out)
- Translation (panning)
- Rotation (two-finger twist)
The component also supports simulated pinch gestures using Alt+mouse for development and testing on non-touch devices.
Example usage:
// Standalone
var pinch = new Pinch();
pinch.onPinch(this, (originX, originY, scale, translateX, translateY, rotation) -> {
visual.scale = scale;
visual.x = originX + translateX;
visual.y = originY + translateY;
visual.rotation = rotation * 180 / Math.PI;
});
// As component
visual.component(new Pinch());
Instance Members
visual: VisualinitializerName: Stringdestroy(): Voidnew(): VoidPrivate Members
NO_INDEX: IntpinchStatusDirty: BoolpinchMoveDirty: Boolstatus: PinchStatusstartDistance: FloatstartRotation: FloatfirstTouchIndex: IntfirstTouchStartX: FloatfirstTouchStartY: FloatfirstTouchLastX: FloatfirstTouchLastY: FloatsecondTouchIndex: IntsecondTouchStartX: FloatsecondTouchStartY: FloatsecondTouchLastX: FloatsecondTouchLastY: FloatsimulatingPinch: BoolTriggered when a pinch gesture begins. @event beginPinch
| Name | Type | Description |
|---|---|---|
originX |
Float | The X coordinate of the gesture's center point |
originY |
Float | The Y coordinate of the gesture's center point |
emitPinch(originX: Float, originY: Float, scale: Float, translateX: Float, translateY: Float, rotation: Float): VoidTriggered continuously during a pinch gesture. @event pinch
| Name | Type | Description |
|---|---|---|
originX |
Float | The X coordinate of the gesture's center point |
originY |
Float | The Y coordinate of the gesture's center point |
scale |
Float | The scale factor relative to the start (1.0 = no change) |
translateX |
Float | The horizontal translation from the origin |
translateY |
Float | The vertical translation from the origin |
rotation |
Float | The rotation angle in radians |
emitEndPinch(): VoidTriggered when a pinch gesture ends. @event endPinch
bindAsComponent(): VoidComponent interface implementation. Called when attached to a Visual as a component.
| Name | Type |
|---|---|
key |
Key |
| Name | Type |
|---|---|
key |
Key |
| Name | Type |
|---|---|
info |
TouchInfo |
| Name | Type |
|---|---|
info |
TouchInfo |
| Name | Type |
|---|---|
info |
TouchInfo |
| Name | Type |
|---|---|
delta |
Float |
| Name | Type |
|---|---|
entity |
Entity |
getEntity(): Entity| Returns |
|---|
| Entity |
Metadata
| Name | Parameters |
|---|---|
:build |
ceramic.macros.ComponentMacro.build() |
:autoBuild |
ceramic.macros.ComponentMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |