XX7G2FFJ4QCGQGD4REAW5QFHVYAKCFUPGZCK7L6DFGS5ISVBYBQQC
NZ7V4BVSRL4CYV3BGUSJQV7DDVFPSLYPAVOSJO5LAQEVEJIJBKBQC
6PUNJS5BSLTYMYMN4JFD7YDEGVQLM5PGAT7PQIG5NIAKLTM5T4PQC
IZZVOCLB7KB4ZNQ35OL466MHWOK3XZMOS7ZPFLHUFQ47LJLQQQ3QC
6LJZN727CRPYR34LV75CQF55YZI3E7MGESYZSFSYAE73SNEZE3FAC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
QU7NHFOVGFSKQ3CWG7EF2Q7GKP3Z6FHGTIDXFHHMSFL6XMUOHMEAC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
love.graphics.draw(text, 12, i*15)
if line == '' then
button('draw', {x=4,y=y+4, w=12,h=12, color={1,1,0},
icon = function(x, y)
love.graphics.setColor(0.7,0.7,0.7)
love.graphics.rectangle('line', x,y, 12,12)
love.graphics.line(4,y+6, 16,y+6)
love.graphics.line(10,y, 10,y+12)
love.graphics.setColor(0, 0, 0)
end,
onpress1 = function()
table.insert(lines, i, {y=y, w=400, h=200, pending={}, shapes={}})
end})
elseif type(line) == 'table' then
-- line drawing
love.graphics.setColor(0,0,0)
line.y = y
love.graphics.rectangle('line', 12,y, line.w,line.h)
y = y+line.h
for _,shape in ipairs(line.shapes) do
prev = nil
for _,point in ipairs(shape) do
if prev then
love.graphics.line(prev.x,prev.y, point.x,point.y)
end
prev = point
end
end
prev = nil
for _,point in ipairs(line.pending) do
if prev then
love.graphics.line(prev.x,prev.y, point.x,point.y)
end
prev = point
end
else
love.graphics.draw(text, 25,y, 0, 1.5)
end
if love.mouse.isDown('1') then
for i, line in ipairs(lines) do
if type(line) == 'table' then
local y = love.mouse.getY()
if y >= line.y and y < line.y + line.h then
lines.current = line
process_drag(line,love.mouse.getX(),love.mouse.getY())
end
end
end
end
end
function process_drag(drawing, x,y)
table.insert(drawing.pending, {x=x, y=y})
button_handlers = {}
-- draw button and queue up event handlers
function button(name, params)
love.graphics.setColor(params.color[1], params.color[2], params.color[3])
love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5)
if params.icon then params.icon(params.x, params.y) end
table.insert(button_handlers, params)
end
-- process button event handlers
function propagate_to_button_handers(x, y, button)
for _,ev in ipairs(button_handlers) do
if x>ev.x and x<ev.x+ev.w and y>ev.y and y<ev.y+ev.h then
if ev.onpress1 and button == 1 then ev.onpress1() end
end
end
end