Vector2 = require("Vector2") local showDebug = false local generator = require("gens.circle") local scaleSpeed = 0.1 love.graphics.setNewFont(25) local function resetCamera() scale = 1 offset = -Vector2(love.graphics.getDimensions())/2 end resetCamera() function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end function math.clamp(x, min, max) return (x < min and min) or (x > max and max) or x end function love.keypressed(keycode, scancode) if scancode == "space" and love.keyboard.isDown("lctrl") then love.window.setFullscreen(not love.window.getFullscreen()) elseif scancode == "f1" then showDebug = not showDebug elseif scancode == "f2" then resetCamera() end end function love.mousemoved(x, y, dx, dy) if love.mouse.isDown(1) then offset = offset - Vector2(dx, dy)*scale end end function love.wheelmoved(x, y) if y == 0 then return end local oldScale = scale if y < 0 then scale = scale*(1+scaleSpeed) else scale = scale*(1-scaleSpeed) end offset = offset + Vector2(love.mouse.getPosition()) * (oldScale-scale) end function love.draw() love.graphics.setColor(1, 1, 1, 1) generator(offset, scale) if showDebug then love.graphics.setColor(0.8, 0.2, 0.2) love.graphics.print("Offset: ("..round(offset.x, 2)..";"..round(offset.y, 2)..")", 0, 0) love.graphics.print("Zoom: "..(1/scale), 0, 30) end end