Create a new CanvasShakeEffect
Optionalduration?: numberTotal shake duration in MS.
OptionalinvalidateMasks?: booleanShould hidden canvas group masks be invalidated each frame?
OptionalmaxDisplacement?: numberMaximum displacement in pixels.
OptionalreturnSpeed?: number"Return to origin" lerp factor per tick in the range [0, 1].
Optionalseed?: number | nullOptional seed used to derive a deterministic time offset.
Optionalsmoothness?: numberSmoothness in the range [0, 1]. Higher is smoother.
Optionaltarget?: DisplayObjectThe target PIXI display object to shake. Defaults to canvas.stage
Optionalticker?: Ticker | nullOptional PIXI ticker. Defaults to foundry.canvas.animation.CanvasAnimation.ticker.
Total shake duration in MS. After this duration elapses, the effect transitions into a return-to-origin phase.
Maximum displacement in pixels during the shake. This value is used as the target maximum offset along each axis.
The deterministic time offset derived from CanvasShakeEffect#seed. Applied to the elapsed time before generating noise.
Return-to-origin interpolation factor per tick, in the range [0, 1]. Higher values restore the target to its reference point more quickly.
Smoothness parameter in the range [0, 1]. Higher values produce smoother, lower-frequency motion.
StaticTAKEOVER_Duration in ms of the smooth takeover transition when a new shake replaces an active shake.
Start the shake effect. Registers a ticker callback and returns a promise that resolves once the effect ends. If the effect is already playing, returns the existing promise (or a resolved one as a fallback).
A promise that resolves when the effect completes or is stopped.
Stop the shake effect immediately. Removes the ticker callback, optionally snaps the target back to its base position, and resolves the active promise.
Optionaloptions: { release?: boolean; snap?: boolean } = {}Optionalrelease?: booleanRelease the target shake state if no other shake is active.
Optionalsnap?: booleanSnap the target back to its base position.
A lightweight screen/object shake utility.
CanvasShakeEffect applies a smooth, time-based positional jitter to a target PIXI.DisplayObject by offsetting its
xandycoordinates relative to a captured reference point. The shake motion is produced using two independent foundry.canvas.animation.SmoothNoise generators (one per axis) to avoid harsh, frame-to-frame randomness and provide a more natural camera-like shake.The effect runs for CanvasShakeEffect#duration milliseconds, with a linearly decaying amplitude from CanvasShakeEffect#maxDisplacement down to zero. After the active shake window ends, the target smoothly returns to its reference point using CanvasShakeEffect#returnSpeed as a per-tick interpolation factor.
If multiple shake instances target the same object, the newest shake replaces the currently active one using a smooth transition, and the target returns to its original pre-shake position once shaking completes. Important: Changes of
xandyfrom external sources outside of CanvasShakeEffect are taken into account.Safety/termination conditions:
Example
Example