melonJS
    Preparing search index...

    Class OutlineEffect

    A shader effect that draws a colored outline around the sprite. Works by sampling neighboring pixels — if any neighbor is opaque but the current pixel is transparent, it draws the outline color. Commonly used for selection highlights, hover states, or collectible glow.

    Renderable.shader for usage

    // yellow outline for selection
    mySprite.shader = new OutlineEffect(renderer, {
    color: [1.0, 1.0, 0.0],
    width: 2.0,
    });
    // remove the effect
    mySprite.shader = undefined;

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    enabled: boolean = false

    whether this effect is active (false in Canvas mode)

    Methods

    • set the texture size for accurate outline width calculation

      Parameters

      • width: number

        texture width in pixels

      • height: number

        texture height in pixels

      Returns void