Love.graphics.captureScreenshot producing no file!
Posted: Wed Mar 01, 2023 3:40 pm
Hello! I've checked the wiki and I don't think anybody else had this problem, probably because I am doing something really stupid.
This is some WIP art/screensaver that connects dots to lines that just runs on a main.lua file that I am going to send.
If you press Q, it should take a screenshot, and LOVE will freeze for a little bit when you click it, so it has to be doing something! But when I check my folder for a the PNG file it is just not there!
Here's all of the code!
Any help would be really appreciated, and it's probably something really obvious , thanks.
This is some WIP art/screensaver that connects dots to lines that just runs on a main.lua file that I am going to send.
If you press Q, it should take a screenshot, and LOVE will freeze for a little bit when you click it, so it has to be doing something! But when I check my folder for a the PNG file it is just not there!
Here's all of the code!
Code: Select all
local POINTS = 500
local RESX, RESY = love.window.getDesktopDimensions()
local SINPOWERMULT = 20
local LINEWIDTH = 1
local CONNECTORS = 3
local allPoints = {}
local rt = 0
local qDown = false
function mag(x,y)
return (x ^ 2 + y ^ 2) ^ 0.5
end
function love.load()
for i = 1,POINTS do
table.insert(allPoints,
{
x = love.math.random() * RESX,
y = love.math.random() * RESY,
pwr = (love.math.random() + 0.5) * SINPOWERMULT,
xoffset = love.math.random() * 180,
yoffset = love.math.random() * 180,
sinmult = love.math.random() + 0.5,
connector = 1,
DX = 0,
DY = 0
})
end
love.graphics.setLineWidth(LINEWIDTH)
love.window.setFullscreen(true)
end
function love.draw()
for _,point in ipairs(allPoints) do
love.graphics.circle("fill",point.DX, point.DY ,LINEWIDTH / 2)
local connectedPoint = allPoints[point.connector]
love.graphics.line(point.DX, point.DY, connectedPoint.DX, connectedPoint.DY)
end
end
function love.update(dt)
rt = rt + dt
for i,point in ipairs(allPoints) do
local NFX, NFY = point.x + point.pwr * math.sin(rt * point.sinmult + point.xoffset), point.y + point.pwr * math.sin(rt * point.sinmult + point.yoffset)
local inverseForceX, inverseForceY = 0,0
local closestIndex, closestPoint = 0,9999999
for j, forcePoint in ipairs(allPoints) do
local newForceX, newForceY = NFX - forcePoint.DX, NFY - forcePoint.DY
local magnitude = mag(newForceX, newForceY)
newForceX, newForceY = newForceX / magnitude, newForceY / magnitude
inverseForceX, inverseForceY = inverseForceX + newForceX, inverseForceY + newForceY
if magnitude < closestPoint and i ~= j then
closestIndex, closestPoint = j, magnitude
end
end
point.connector = closestIndex
point.DX, point.DY = NFX + inverseForceX, NFY + inverseForceY
end
if love.keyboard.isDown("q") then
if qDown == false then
qDown = true
love.graphics.captureScreenshot("capture.png") --SCREENSHOTTING HAPPENS HERE HELLO !!
end
else[/b]
qDown = false
end
end