Light2d

class Light2d extends Renderable

A 2D point light. Note: this is a very experimental and work in progress feature, that provides a simple spot light effect. The light effect is best rendered in WebGL, as they are few limitations when using the Canvas Renderer (multiple lights are not supported, alpha component of the ambient light is ignored)

See: stage.lights

Constructor


new Light2d(x: number, y: number, radiusX: number, radiusY: number, color: Color | string, intensity: number) → {}
Parameters:
Name Type Attributes Default Description
x number

The horizontal position of the light.

y number

The vertical position of the light.

radiusX number

The horizontal radius of the light.

radiusY number

<optional>

radiusX

The vertical radius of the light.

color Color | string

<optional>

"#FFF"

the color of the light

intensity number

<optional>

0.7

The intensity of the light.

Summary


Properties from Light2d

Properties inherited from Rect

number
bottom
number
centerX
number
centerY
number
height
number
left
number
right
number
top
string
type = "Rectangle"
number
width

Properties inherited from Polygon

Array<Vector2d>
points

Public Properties


blendMode light2d.js:91
blendMode: string = "lighter"

string

the default blend mode to be applied when rendering this light

See:
color light2d.js:65
color: Color = "#FFF"

Color

the color of the light

intensity light2d.js:84
intensity: number = 0.7

number

The intensity of the light

radiusX light2d.js:72
radiusX: number

number

The horizontal radius of the light

radiusY light2d.js:78
radiusY: number

number

The vertical radius of the light

Public Methods


getVisibleArea light2d.js:111
getVisibleArea() → {Ellipse}

returns a geometry representing the visible area of this light

Returns:
Type Description
Ellipse

the light visible mask

update light2d.js:121
update(dt: number) → {boolean}

update function

Parameters:
Name Type Description
dt number

time since the last update in milliseconds.

Returns:
Type Description
boolean

true if dirty

Protected Methods


draw light2d.js:130
protected draw(renderer: CanvasRenderer | WebGLRenderer, viewport: Camera2d) → {}

draw this Light2d (automatically called by melonJS)

Parameters:
Name Type Attributes Description
renderer CanvasRenderer | WebGLRenderer

a renderer instance

viewport Camera2d

<optional>

the viewport to (re)draw


Powered by webdoc!