tonelib
v1.0.9
Published
Emotional tone utilities for interactive narrative - HSL-based emotion mapping, blending, and analysis
Maintainers
Readme
tonelib
Emotional tone utilities for interactive narrative. Uses an HSL-based emotion wheel for mapping, blending, and analyzing narrative moods.
Installation
npm install tonelibUsage
import {
createTone,
getEmotionDescription,
HUE_TO_EMOTION,
getNearestEmotionalHue,
blendTones,
} from 'tonelib';
// Create a tone from HSL values
const tone = createTone(30, 80, 50); // Anger range
// Get human-readable description
const desc = getEmotionDescription(30); // "Anger"
// Find the nearest emotional anchor
const nearest = getNearestEmotionalHue(35); // 30 (Anger)
// Blend two tones
const blended = blendTones(tone1, tone2, 0.5);Core Exports
- Tone creation:
createTone,fromHSL,fromCode,fromCompact - Parsing/conversion:
parseHSL,toCompact,hslToRgb,rgbToHsl,toHex - Emotion mappings:
HUE_TO_EMOTION,HUE_TO_CODE,CODE_TO_HUE,EMOTION_DESCRIPTIONS,getEmotionDescription - Utilities:
getNearestEmotionalHue,blendTones,shiftToward,intensify,mute,brighten,darken - Validation:
isValidHSL,validateTone,validateDescription
Emotion Wheel
The library maps 12 emotional anchors around a 360° hue wheel:
| Hue | Emotion | Code | |-----|--------------|------| | 0 | Rage | RA | | 30 | Anger | AN | | 60 | Joy | JO | | 90 | Serenity | SE | | 120 | Trust | TR | | 150 | Admiration | AD | | 180 | Apprehension | AP | | 210 | Fear | FE | | 240 | Sadness | SA | | 270 | Pensiveness | PE | | 300 | Disgust | DI | | 330 | Contempt | CO |
License
MIT
