Add textured ribbon mode to Trail renderable
Author: obiotCreated Apr 14, 2026Updated Aug 30, 2026
Summary
The Trail renderable (#1368) currently draws solid-color quads with gradient interpolation. A textured ribbon mode would allow mapping a texture (or sprite sheet frame) along the trail, enabling effects like:
- Sword slash arcs with a blade texture
- Magic spell trails with animated glow textures
- Smoke/fire trails with particle-like textures
- Rope/chain rendering
Requirements
textureoption in Trail constructor — accepts an image or TextureAtlas region- UV mapping along the ribbon: U stretches along the trail length (0=head, 1=tail), V spans the width
- Compatible with the existing gradient/opacity/blendMode options (tint the texture with the gradient)
- Works on both WebGL (textured quads via drawImage or batcher) and Canvas (drawImage with transform per segment)
References
- Prior art elsewhere offers a
textureModeof stretch / tile / fit — worth matching, since "stretch one texture over the whole ribbon" and "repeat it per unit length" are both wanted and the choice cannot be inferred. - Current Trail implementation:
src/renderable/trail.js
Notes
This was identified during the Trail implementation (#1368) but deferred to keep the initial PR focused on the core ribbon rendering.
Source: melonjs/melonJS