Class Lighting

Defines the lighting of one light through a set of opaque objects.

Hierarchy

  • Lighting

Constructors

Properties

#castCache?: CanvasAndContext
light: Light

The source of the lighting.

Default

new Light()
objects: OpaqueObject[]

An array of OpaqueObject objects which stop the light and create shadows.

Default

[]

Methods

  • Draw the shadows that are cast by the objects. You usually don't have to use it if you use render().

    Parameters

    • ctxoutput: CanvasRenderingContext2D

      The canvas context onto which the shadows will be drawn.

    Returns void

  • Compute the shadows to cast.

    Parameters

    • w: number

      Width of the canvas context.

    • h: number

      Height of the canvas context.

    Returns void

  • Create caches for canvas contexts.

    Parameters

    • w: number

      Width of the contexts.

    • h: number

      Height of the contexts.

    Returns void

  • Returns the light and shadows onto the given context as canvas.

    Returns HTMLCanvasElement

    The picture of the light and shadow.

  • Draws the light and shadows onto the given context.

    Parameters

    • context: CanvasRenderingContext2D

      The canvas context on which to draw.

    Returns void