illuminated.Light Class
Abstract class for light objects.
Constructor
illuminated.Light
-
[options]
Parameters:
-
[options]
Object optionalOptions to be applied to this light.
-
[position]
illuminated.Vec2 optionalPosition of this light. (0,0) by default.
-
[distance=100]
Number optionalIntensity of this light.
-
[diffuse=0.8]
Number optionalHow diffuse this light is.
-
Item Index
Methods
_getVisibleMaskCache
()
CanvasRenderingContext2D
private
Creates a canvas context with the visible mask rendered onto it.
Returns:
bounds
()
Object
Calculate the boundaries of this light using the light's distance.
Returns:
center
()
illuminated.Vec2
Return the center of this light. i.e. The position where the light intensity is the highest
Returns:
forEachSample
-
f
Invoke a function for every sample generated by this light.
Parameters:
-
f
FunctionFunction to be called for every sample. The function will be passed a vector representing the position of the sample.
mask
-
ctx
Render a mask representing the visibility. (Used by DarkMask.)
Parameters:
-
ctx
CanvasRenderingContext2DThe canvas context onto which the mask will be rendered.
render
-
ctx
Render the light onto the given context.
Parameters:
-
ctx
CanvasRenderingContext2DThe canvas context onto which the light will be rendered.
Properties
diffuse
Number
How diffuse this light is.
Default: 0.8
distance
Number
Intensity of this light.
Default: 100
position
Vec2
Position of this light. (0,0) by default.
Default: new Vec2(0, 0)