aboutsummaryrefslogtreecommitdiff
path: root/main.lua
blob: b03306ac26d8782e8a7dadff8980beec3b014084 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
local L = love
local G = L.graphics

local R = 10

local canv
function L.load()
	canv = G.newCanvas()
	canv:renderTo(function()
		G.clear(1,1,1)
	end)
	G.setLineWidth(R)
end

local T = 0
function L.update(dt)
	T = T + dt
end


local function line_between(x0,y0,x1,y1)
	canv:renderTo(function()
		G.line(x0,y0,x1,y1)
	end)
end
local function circle(x,y)
	canv:renderTo(function()
		G.circle('fill',x,y,R/2)
	end)
end


local last = nil
function L.draw()
	G.setColor(0,0,0)
	local x,y = L.mouse.getPosition()
	if L.mouse.isDown(1) then
		if last == nil then
			circle(x,y)
			last = {x,y}
		else
			circle(x,y)
			line_between(last[1],last[2],x,y)
			last[1],last[2] = x,y
		end
	elseif last ~= nil then
		circle(x,y)
		line_between(last[1],last[2],x,y)
		last=nil
	end

	G.setColor(1,1,1)
	G.draw(canv)

end