summaryrefslogtreecommitdiff
path: root/util.lua
blob: 6172d84c0ea09754fb603e4a7b5b991fa8c3caa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local hsluv = require 'hsluv'

local G = love.graphics
local function mouse_pos()
	-- in world space
	return G.inverseTransformPoint(love.mouse.getPosition())
end

local function write_at(text,x,y)
	local tx,ty = G.transformPoint(x,y)
	G.push()
	G.origin()
	G.print(text,tx,ty)
	G.pop()
end

local function phi_color(n)
	local phi = (1+math.sqrt(5))/2
	local h = (360*phi*n)%360
	return hsluv.hsluv_to_rgb({h, 80, 60})
end

return {
	mouse_pos = mouse_pos,
	write_at = write_at,
	phi_color = phi_color,
}