2014-09-26 16:48:46 +00:00
|
|
|
local stencils = {}
|
|
|
|
|
|
|
|
function stencils.shadow(geometry, bodies)
|
|
|
|
return function()
|
2014-10-22 02:48:19 +00:00
|
|
|
--cast shadows
|
2014-09-26 16:48:46 +00:00
|
|
|
for i = 1,#geometry do
|
|
|
|
if geometry[i].alpha == 1.0 then
|
|
|
|
love.graphics.polygon("fill", unpack(geometry[i]))
|
2014-11-28 15:20:00 +00:00
|
|
|
if geometry[i].circle then
|
2014-11-28 21:56:05 +00:00
|
|
|
love.graphics.arc("fill", unpack(geometry[i].circle))
|
2014-11-28 15:20:00 +00:00
|
|
|
end
|
2014-09-26 16:48:46 +00:00
|
|
|
end
|
|
|
|
end
|
2014-10-22 02:48:19 +00:00
|
|
|
-- underneath shadows
|
2014-09-26 16:48:46 +00:00
|
|
|
for i = 1, #bodies do
|
|
|
|
if not bodies[i].castsNoShadow then
|
2014-10-24 02:41:52 +00:00
|
|
|
bodies[i]:stencil()
|
2014-09-26 16:48:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-10-24 02:41:52 +00:00
|
|
|
function stencils.shine(bodies)
|
2014-09-26 16:48:46 +00:00
|
|
|
return function()
|
|
|
|
for i = 1, #bodies do
|
2014-10-22 02:48:19 +00:00
|
|
|
if bodies[i].shine and
|
|
|
|
(bodies[i].glowStrength == 0.0 or
|
|
|
|
(bodies[i].type == "image" and not bodies[i].normal))
|
|
|
|
then
|
2014-10-24 02:41:52 +00:00
|
|
|
bodies[i]:stencil()
|
2014-09-26 16:48:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return stencils
|