-- constants
local SIZE = settings.size
local HSIZE = SIZE / 2
local OFFSET = Vector2.new(HSIZE, HSIZE)

-- create screen capture session
local zoomer = ZoomView.new({
    width = SIZE,
    height = SIZE,
    zoom = settings.zoom,
    invert = settings.invert
})


-- !!!!! HACK: create hidden object. 
local mesh = Mesh2D.circle(10)
local halo = Node2D.new()
halo:addMesh( mesh )
halo.color.rgba = 0
halo:spawn()


-- step: called each frame
function step(deltaTime)
	-- get cursor position
    local position = ym.getCursorPosition()

	-- update zoom view position
	zoomer:update(position, OFFSET)
end

-- hotkey: called when hotkeys are triggered
function hotkey(id, down)
	-- if matching settings hotkey, toggle zoom view visibility
	if id == settings.hotkey then
		zoomer.visible = not zoomer.visible
	end
end
