Function fromAlphaTexture

  • Deposits material from an alpha-mask "stamp". The source is placed with its top-left at (dstX, dstY); for each source pixel whose alpha is at or above threshold, the corresponding bitmap cell is set to materialId. The deposit complement of Carve.fromAlphaTexture.

    The primary use is procedural terrain generation from a PNG mask: load the mask via Phaser, extract its ImageData, and call this with a single material id to produce the initial terrain shape.

    Parameters

    • bitmap: ChunkedBitmap
    • source: AlphaSource
    • dstX: number
    • dstY: number
    • materialId: number

      Bitmap value to write where the source is opaque.

    • threshold: number = DEFAULT_ALPHA_THRESHOLD

      Alpha cutoff in 0..255. Default 128.

    Returns void

    (via setPixel) If materialId is not an integer in 0..255.