Home

Awesome

Light & Shadow

A simple dynamic light shadow library for LOVE2D 11.2.

It's easy to use, don't need to create body for shadow, directly generate shadow from canvas/image according alpha. So it's not fast, and don't support 3D shadow. If you want a fast and 3D light shadow library, Light World and Shadow is better choice.

Example

Example Image

##Usage

local Lib = require 'light'
local light_world = Lib.World.new()
local light

local lg = love.grpahics

function love.load()
  light = light_world:add(200, 200, 200, 1, 0, 0)
end

function love.update(dt)
  light.x, light.y = love.mouse.getPosition()
end

function love.draw()
  -- reset light world
  light_world:begin()

  for i = 1, 10 do
    lg.circle('fill', 100 + i * 70, 300, 10)
  end

  -- track shadow objects
  light_world:track_obj()
  for i = 1, 10 do
    lg.circle('fill', 100 + i * 70, 300 + i * 50, 30)
  end
  -- draw background
  light_world:track_bg()

  for i = 1, 10 do
    lg.circle('fill', 100 + i * 70, 500 + i * 50, 30)
  end

  -- draw scene, light and shadow
  light_world:finish()

  lg.print('mouse: '..mx..','..my..' light: '..light.x..','..light.y, 50, 50)
end

Functions

World

Light

Tips

TODO