Illuminated.js Docs (v0.1)

A 2D lights and shadows rendering engine for your HTML5 web applications and games.
Show:

illuminated.RectangleObject Class

A rectangular, opqaue object.

Constructor

illuminated.RectangleObject

(
  • [options]
)

Parameters:

  • [options] Object optional

    Options to be applied to this rectangle object.

    • [topleft] illuminated.Vec2 optional

      A vector that is the top-left of the rectangle.

    • [bottomright] illuminated.Vec2 optional

      A vector that is the bottom-right of the rectangle.

Methods

_forEachVisibleEdges

(
  • origin
  • bounds
  • f
)
private

Invoke a function for each of the visible edges in this polygon.

Parameters:

  • origin illuminated.Vec2

    A vector that represents the origin for the casted shadows.

  • bounds Object

    An anonymous object with the properties topleft and bottomright. The property values are illuminated.Vec2 objects representing the corners of the boundary of this polygon.

  • f Function

    The function to be invoked.

bounds

() Object

Inherited from illuminated.OpaqueObject but overwritten in src/illuminated.js:796

Calculate the boundaries of this polygon object.

Returns:

Object: An anonymous object with the properties topleft and bottomright. The property values are illuminated.Vec2 objects representing the corners of the boundary.

cast

(
  • ctx
  • origin
  • bounds
)

Inherited from illuminated.OpaqueObject but overwritten in src/illuminated.js:855

Fill ctx with the shadows projected by this polygon object from the origin point, constrained by the given bounds.

Parameters:

  • ctx CanvasRenderingContext2D

    The canvas context onto which the shadows will be cast.

  • origin illuminated.Vec2

    A vector that represents the origin for the casted shadows.

  • bounds Object

    An anonymous object with the properties topleft and bottomright. The property values are illuminated.Vec2 objects representing the corners of the boundary.

contains

(
  • point
)
Boolean

Inherited from illuminated.OpaqueObject but overwritten in src/illuminated.js:820

Determine if the given point is inside the polygon.

Parameters:

Returns:

Boolean: True if the polygon object contains the given point.

fill

(
  • ctx
)

Draws this rectangle onto the given context

Parameters:

  • ctx CanvasRenderingContext2D

    The canvas context onto which the rectangle should be drawn.

path

(
  • ctx
)

Inherited from illuminated.OpaqueObject but overwritten in src/illuminated.js:845

Draw the path of the polygon onto the ctx.

Parameters:

  • ctx CanvasRenderingContext2D

    The context onto which the path will be drawn.

syncFromTopleftBottomright

() private

Initializes the points defining this rectangle based on its specified bounds.

Properties

bottomright

Vec2

A vector that is the bottom-right of the rectangle.

Default: new illuminated.Vec2()

diffuse

Number

How diffuse this opaque object should be.

Default: 0.8

points

Array

An array of illuminated.Vec2 points that define the polygon.

Default: []

topleft

Vec2

A vector that is the top-left of the rectangle.

Default: new illuminated.Vec2()