-- File dropped on love2d function love.load() font = love.graphics.newFont(12) filepath = "" loadreq = false img = nil scalev = 0 angle = 0 end function love.update(dt) if loadreq then -- load png image loadreq = false local f = io.open(filepath, "rb") local contents = f:read("*all") local data = love.filesystem.newFileData(contents, "temp.png") local imgdata = love.image.newImageData(data) f:close() img = love.graphics.newImage(imgdata) end scalev = 0.1 * math.sin(math.rad(angle)) angle = (angle + 540 * dt) % 360.0 end function love.draw() -- clear canvas love.graphics.clear(0.2, 0.2, 0.2, 1.0) -- draw image love.graphics.setColor(1.0, 1.0, 1.0, 1.0) if img ~= nil then local scrw, scrh = love.graphics.getDimensions() local w = img:getWidth() local h = img:getHeight() local x = scrw / 2 local y = scrh - 16 local ox = w / 2 local oy = h local yscale = 1.0 + scalev local xscale = (w * h) / (h * yscale) / w love.graphics.draw(img, x, y, 0, xscale, yscale, ox, oy) end -- draw text love.graphics.setFont(font) love.graphics.setColor(1, 1, 1, 1) love.graphics.print("Please drop the png image file", 220, 2) love.graphics.print(filepath, 2, 40) love.graphics.print("FPS: " .. tostring(love.timer.getFPS()), 2, 2) end function love.keypressed(key, isrepeat) if key == "escape" then -- ESC key to exit love.event.quit() end end function love.filedropped(file) filepath = file:getFilename() loadreq = true end