-- Love2d Mesh -- init function love.load() -- get window width and height wdw_w, wdw_h = love.graphics.getDimensions() img = love.graphics.newImage("uvcheckermap01-512.png") bx, by = wdw_w / 2, wdw_h / 2 v = { { -- top left -- x, y, u, v, r, g, b bx - 50, by - 200, 0.0, 0.0, 1.0, 1.0, 1.0 }, { -- top right -- x, y, u, v, e, g, b bx + 50, by -200, 1.0, 0.0, 1.0, 1.0, 1.0 }, { -- bottom left -- x, y, u, v, e, g, b bx - 300, by + 200, 0.0, 1.0, 1.0, 1.0, 1.0 }, { -- bottom right -- x, y, u, v, e, g, b bx + 300, by + 200, 1.0, 1.0, 1.0, 1.0, 1.0 }, } mesh = love.graphics.newMesh(v, "strip") mesh:setTexture(img) ang = 0 end -- update function love.update(dt) ang = ang + 180 * dt local d = 150 + 100 * math.sin(math.rad(ang)) if true then local i = 1 -- mesh:setVertex(index, x, y, u, v, r, g, b, a) mesh:setVertex(i, (bx - d), v[i][2], v[i][3], v[i][4], v[i][5], v[i][6], v[i][7], v[i][8]) i = 2 mesh:setVertex(i, (bx + d), v[i][2], v[i][3], v[i][4], v[i][5], v[i][6], v[i][7], v[i][8]) else v[1][1] = bx - d v[2][1] = bx + d -- mesh:setVertex(index, table) mesh:setVertex(1, v[1]) mesh:setVertex(2, v[2]) end end -- draw function love.draw() -- fill BG color love.graphics.setColor(0.1, 0.2, 0.4) love.graphics.rectangle("fill", 0, 0, wdw_w, wdw_h) -- draw mesh love.graphics.setColor(1, 1, 1) love.graphics.draw(mesh, 0, 0) -- print FPS love.graphics.setColor(1, 1, 1) love.graphics.print("FPS: "..tostring(love.timer.getFPS()), 10, 10) end function love.keypressed(key, isrepeat) -- ESC to exit if key == "escape" then love.event.quit() end end