FlubberMorpher

Flubber-based shape interpolator with reference-counted caching.

Uses the static 'for_paths' factory method to manage a global instance cache. Multiple calls to for_paths() with the same shapes return the same instance, and the instance is only cleaned up when all references call close().

Constructor

FlubberMorpher(
    path1: SVGPath,
    path2: SVGPath,
    cache_key: tuple[str, str, str],
    max_cache_size: int | None = None,
    kwargs: Any
)

Constructor. Executes the expensive Node.js bridge initialization.

Parameters

path1
Start shape.
path2
End shape.
cache_key
Tuple used for cache lookup.
max_cache_size
Maximum number of interpolated paths to cache.
**kwargs
Options for FlubberNodeBridge.

Methods

cache_stats

cache_stats()

Get statistics about the global morpher cache.

Returns

Dict with cache size, active instances, total references

cleanup

cleanup()

Force cleanup of all cached morphers regardless of reference counts.

clear_cache

clear_cache()

Clear the t-value interpolation cache.

clear_morpher_cache

clear_morpher_cache()

Alias for cleanup(). Clear all cached morphers.

close

close()

Decrement reference count and cleanup if this is the last reference.

for_paths

for_paths(
    path1: SVGPath,
    path2: SVGPath,
    kwargs: Any
) -> FlubberMorpher

Factory method that returns a cached morpher instance.

Parameters

path1
Start shape
path2
End shape
**kwargs
Options passed to FlubberNodeBridge (e.g., flubber_path).

get_cache_stats

get_cache_stats()

Get statistics about the t-value cache performance.

Returns

Dictionary with cache statistics