Skip to content

1681-engine / index / Afterimages

Class: Afterimages ​

Defined in: src/fx/Afterimages.ts:34

Afterimages of a moving body — a dash, a blink, a quick step: copies of its current frame left behind as flat silhouettes in a tint, fading out. A copy is its frame's cached solid silhouette (solidSilhouette) tinted, not a fill filter, so a trail costs no render pass per copy; copies are pooled rather than made every few ms, and a live body's frames are snapshotted into a fixed ring of textures instead of a new canvas each time.

Constructors ​

Constructor ​

ts
new Afterimages(stage, options?): Afterimages;

Defined in: src/fx/Afterimages.ts:51

Parameters ​

ParameterType
stageStage
optionsAfterimagesOptions

Returns ​

Afterimages

Accessors ​

active ​

Get Signature ​

ts
get active(): number;

Defined in: src/fx/Afterimages.ts:98

Copies still fading.

Returns ​

number

Methods ​

destroy() ​

ts
destroy(): void;

Defined in: src/fx/Afterimages.ts:142

Takes every copy off the stage and frees the ring's textures.

Returns ​

void


trail() ​

ts
trail(
   body, 
   x, 
   y, 
   now, 
   depth?
): Image | null;

Defined in: src/fx/Afterimages.ts:70

Leaves a copy of body as drawn now, standing at world (x, y) with draw order depth (default just behind a body sorted by y), unless one was left less than spacingMs before now. Answers the copy, or null when none was laid (too soon, or the frame could not be read): a caller drawing its own speed streaks between copies follows that.

Parameters ​

ParameterType
bodyImage
xnumber
ynumber
nownumber
depthnumber

Returns ​

Image | null

Released under the MIT License.