local mask = love.graphics.newImage("wwe.png") local mask_shader = love.graphics.newShader[[ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) { if (Texel(texture, texture_coords).rgb == vec3(0.0)) { // a discarded pixel wont be applied as the stencil. discard; } return vec4(1.0); } ]] function love.load() local canvas = love.graphics.newCanvas(20, 20) love.graphics.setCanvas(canvas) love.graphics.clear() love.graphics.setBlendMode("alpha") love.graphics.setColor(1, 1, 1, 0.8) love.graphics.circle('fill', 10, 10, 5) love.graphics.setCanvas() psystem = love.graphics.newParticleSystem(canvas, 1000) psystem:setParticleLifetime(2, 8) psystem:setEmissionRate(60) psystem:setSizeVariation(0.7) psystem:setSpeed(5) --psystem:setLinearAcceleration(-40, -40, 40, 0) psystem:setRadialAcceleration(4,8) psystem:setEmissionArea('borderrectangle', 150, 10, 0, false) psystem:setColors( 1,0.35,0,1, 0.85, 0.85, 0.85, 0 ) end local function myStencilFunction() love.graphics.setShader(mask_shader) love.graphics.draw(mask, 0, 0) love.graphics.setShader() end function love.draw() love.graphics.stencil(myStencilFunction, "increment") --love.graphics.setStencilTest("less", 1) love.graphics.draw(psystem, love.graphics.getWidth() * 0.5, love.graphics.getHeight() * 0.5) love.graphics.setStencilTest() end function love.update(dt) psystem:update(dt) end