Pinch

Entityceramic.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: Visual

initializerName: String

destroy(): Void

new(): Void

Private Members

NO_INDEX: Int

pinchStatusDirty: Bool

pinchMoveDirty: Bool

status: PinchStatus

startDistance: Float

startRotation: Float

firstTouchIndex: Int

firstTouchStartX: Float

firstTouchStartY: Float

firstTouchLastX: Float

firstTouchLastY: Float

secondTouchIndex: Int

secondTouchStartX: Float

secondTouchStartY: Float

secondTouchLastX: Float

secondTouchLastY: Float

simulatingPinch: Bool

emitBeginPinch(originX: Float, originY: Float): Void

Triggered 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): Void

Triggered 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(): Void

Triggered when a pinch gesture ends. @event endPinch


bindAsComponent(): Void

Component interface implementation. Called when attached to a Visual as a component.


keyDown(key: Key): Void
Name Type
key Key

keyUp(key: Key): Void
Name Type
key Key

pointerDown(info: TouchInfo): Void
Name Type
info TouchInfo

pointerUp(info: TouchInfo): Void
Name Type
info TouchInfo

pointerMove(info: TouchInfo): Void
Name Type
info TouchInfo

update(delta: Float): Void
Name Type
delta Float

setEntity(entity: Entity): Void
Name Type
entity Entity

getEntity(): Entity
Returns
Entity

Metadata

Name Parameters
:hxGen -
: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()