Skip to content

Emotion Presets

@hapticjs includes 12 emotion-based haptic patterns that convey feelings through vibration rhythms. Each pattern is carefully tuned to evoke a specific emotional response.

Usage

typescript
import { haptic, emotions } from '@hapticjs/core';

haptic.play(emotions.excited);
haptic.play(emotions.calm);
haptic.play(emotions.romantic);

Or access via the presets object:

typescript
import { presets } from '@hapticjs/core';

haptic.play(presets.emotions.happy);

All Emotions

EmotionPattern Description
excitedFast, energetic pulses building to a crescendo
calmSlow, gentle wave with soft sustained vibrations
tenseTight, irregular short heavy bursts
happyBouncy, playful ascending rhythm
sadSlow, heavy, descending vibrations that fade
angryAggressive, chaotic rapid heavy hits
surprisedSharp sudden hit, silence, then lighter hit
anxiousFast irregular heartbeat with inconsistent spacing
confidentStrong, steady, measured even pulses
playfulAlternating light-heavy in bouncy rhythm
romanticGentle heartbeat rhythm, two soft pulses with long pauses
peacefulVery subtle, barely-there ultra-light slow pulses

Example: Dynamic Emotion Feedback

typescript
import { haptic, emotions } from '@hapticjs/core';

type Mood = keyof typeof emotions;

function reactToMood(mood: Mood) {
  haptic.play(emotions[mood]);
}

// In a mood-tracking app
reactToMood('happy');
reactToMood('calm');

Combining with SensoryEngine

Pair emotion haptics with themed sound and visuals:

typescript
import { SensoryEngine, emotions } from '@hapticjs/core';

const engine = SensoryEngine.create({ theme: 'nature' });

// Play emotion with multi-sensory feedback
await engine.play(emotions.peaceful);

INFO

Emotion presets are HPL-based pattern strings. You can pass them to haptic.play(), engine.play(), or any function that accepts pattern input.

Released under the MIT License.