Skip to content
/Fox --develop edited this page May 30, 2017 · 1 revision

LightWorld(options)

local LightWorld = require 'lib' --the directory you've placed the files in (in this repo it's "lib")
local lightWorld = LightWorld({
 -- options here
})

Available Options

  • ambient - required the color of the darkness
  • refractionStrength - how strong the world refraction is
  • reflectionStrength - how strong reflection is
  • reflectionVisibility - how visible the reflections are
  • shadowblur - the amount the shadows are blurred (this makes them seem a bit more natural)
  • glowBlur - the amount that glowing object lights are blurred

:refreshScreenSize(width, height)

defaults: (love.graphics.getWidth(), love.graphics.getHeight())

used for refreshing canvas sizes, this will cascade over the lights and bodies and is very costly so only call this when the screen has been resized.

:draw(x_offset, y_offset, scale)

defaults: (0,0,1)

The main draw method to be called in love.draw()

:newLight(x, y, red, green, blue, range)

returns Light

Creates a new light at position (x, y) with color (red, green, blue) with a shine radius of (range)

:clearLights()

Clears all lights from the world

:clearBodies()

Clears all shadow bodies from the world

:clear()

Clears all shadows and bodies from the world

Sets the callback for drawing the foreground

:setAmbientColor(red, green, blue)

:setShadowBlur(blur)

:setGlowStrength(strength)

:setRefractionStrength(strength)

:setReflectionStrength(strength)

:setReflectionVisibility(visibility)

:newRectangle(x, y, w, h)

returns Body

new rectangle shadowbody with centre at x,y with dimensions w,h

:newCircle(x, y, r)

returns Body

new circle shadowbody with the centre at x,y and a radius of r

:newPolygon(x1, y1, x2, y2, x3, y3, ...)

returns Body

new shadowbody polygon with the points provided (3 < n < 9)

:newImage(image, x, y, width, height, ox, oy)

defaults: width=image_width, height=image_height, ox=0, oy=0

returns Body

new shadowbody from an image at point x,y with size of width,height and an offset point of ox,oy

:newAnimationGrid(image, x, y)

returns Body

new shadowbody from an image at point x,y this will not yet draw though if you dont add an animation to it.

:newRefraction(normal_map, x, y, width, height)

returns Body

new refraction shadow body at point x,y with the size of width,height

:newRefractionHeightMap(height_map, x, y, strength)

returns Body

new refraction made from a height map that has been converted into a normal map

:newReflection(normal_map, x, y, width, height)

returns Body

new reflection shadow body at point x,y with the size of width,height

:newReflectionHeightMap(height_map, x, y, strength)

returns Body

new reflection made from a height map that has been converted into a normal map

:getBodyCount()

returns number

get number of bodies

:getBody(n)

returns Body

get body number n

:getLightCount()

returns number get number of lights

:getLight(n)

returns Light

Get light number n

:remove(Body|Light)

returns bool true if succeeded false if not

remove the item from the light world, you can pass in either a light or a shadow body.