From f09d855593cc5405937d20571526f81583f0cb8b Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 21 Mar 2024 21:35:15 +0000 Subject: the --- main.lua | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 main.lua (limited to 'main.lua') diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..b03306a --- /dev/null +++ b/main.lua @@ -0,0 +1,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 -- cgit v1.2.3