UNPKG

agentjs-core

Version:

A comprehensive agent-based modeling framework with built-in p5.js visualization

136 lines 4.1 kB
/** * AnimationEngine - Smooth animation system for visualization * * Features: * - Tweening system for property changes * - Multiple easing functions * - Animation queue management * - Performance-optimized pipeline * - Agent position and property animations */ import type { AgentId } from '../types/core'; /** Easing function type */ export type EasingFunction = (t: number) => number; /** Animation target object */ export interface AnimationTarget { id: string; [key: string]: any; } /** Animation configuration */ export interface AnimationConfig { target: AnimationTarget; property: string; from: number; to: number; duration: number; easing: EasingFunction; onUpdate?: ((value: number) => void) | undefined; onComplete?: (() => void) | undefined; delay?: number; } /** * Easing functions for smooth animations */ export declare const Easing: { linear: (t: number) => number; easeInQuad: (t: number) => number; easeOutQuad: (t: number) => number; easeInOutQuad: (t: number) => number; easeInCubic: (t: number) => number; easeOutCubic: (t: number) => number; easeInOutCubic: (t: number) => number; easeInQuart: (t: number) => number; easeOutQuart: (t: number) => number; easeInOutQuart: (t: number) => number; easeInBack: (t: number) => number; easeOutBack: (t: number) => number; easeInOutBack: (t: number) => number; easeInBounce: (t: number) => number; easeOutBounce: (t: number) => number; easeInOutBounce: (t: number) => number; }; /** * AnimationEngine - Main animation system * * Educational Context: Provides smooth visual transitions * that help users understand agent state changes and * movement patterns over time. */ export declare class AnimationEngine { /** Active animations map */ private animations; /** Animation frame ID for cleanup */ private animationId; /** Current time for animations */ private currentTime; /** Performance monitoring */ private readonly stats; /** Whether animation loop is running */ private isRunning; constructor(); /** * Start the animation loop */ private startAnimationLoop; /** * Stop the animation loop */ private stopAnimationLoop; /** * Update all active animations */ update(timestamp: number): void; /** * Update a single animation */ private updateAnimation; /** * Animate a property of a target object */ animateProperty(target: AnimationTarget, property: string, to: number, duration: number, easing?: EasingFunction, delay?: number): string; /** * Animate agent position smoothly */ animateAgentPosition(agentId: AgentId, fromX: number, fromY: number, toX: number, toY: number, duration: number, easing?: EasingFunction, onUpdate?: (x: number, y: number) => void, onComplete?: () => void): string[]; /** * Animate agent property with visual feedback */ animateAgentProperty(agentId: AgentId, property: string, from: number, to: number, duration: number, easing?: EasingFunction, onUpdate?: (value: number) => void, onComplete?: () => void): string; /** * Create animation sequence */ sequence(animations: (() => string)[]): string; /** * Create parallel animations */ parallel(animations: (() => string)[]): string[]; /** * Stop animation by ID */ stopAnimation(animationId: string): boolean; /** * Stop all animations for a target */ stopAnimationsForTarget(targetId: string): number; /** * Check if animation is running */ isAnimationRunning(animationId: string): boolean; /** * Get animation progress (0-1) */ getAnimationProgress(animationId: string): number; /** * Get performance statistics */ getStats(): typeof this.stats; /** * Clear all animations */ clear(): void; /** * Destroy the animation engine */ destroy(): void; } //# sourceMappingURL=AnimationEngine.d.ts.map