6DE7RBZ6RHNEICJ7EUMCTROK43LW4LYINULIF2QEQOKCXWLUYUXAC
EF6MFB46IJA3TMTGY6DNPFB46RETYX6L2JGX2P567T2XFY47MB3AC
HYEAFRZ2UEKDYTAE2GDQLHEJBPQASP2NDLMXB7F6MTVK2BKOXKEAC
JCSLDGAH2F6AIY4Z6XM6K4LOMW7EFY3E4NF5YXLMHLTYTX3A4Z3QC
VHQCNMARPMNBSIUFLJG7HVK4QGDNPCGNVFLHS3I4IGNVSV5MRLYQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
MGOQ5XAVFTWZPBG2O5ZTGSEKU6BRJKQZLDV6CM4737VD2FAEB5JQC
AVQ5MC5DWNLI6LUUIPGBLGP4LKRPGWBY4THNY25OBT2FAVHC6MCAC
SNDZOK6QJUASKYLYBHIATA7WXPCPZTEYEWA63I4H7HH3JT3B4U6AC
GCUARQ2GJT3Y5K6LOOA6S7SOBMSXU7VV7LT355TOMFFPBQ3ZVYKAC
HWPK4SMPGZMXWXKCVX667676ZWN5Q2XZSTMVAADG7JNRF6XE45RQC
NL5J7Z5H577GPKGNS5TDRVWC55VLA2UCZE34F5WR4AJ5N265UECAC
FMQ74DP324YKGBSTNMHBJMT6FYP5NI26MM43VUPGKODI5DVDCUXQC
ZOOY3ME4BUD6RLWCKZFA62JNN4BMPOXH24HGTFWPWEKDECOXMFUAC
IFGAJAF7UWM236QV4NWP2C67TJPQGXNBC2RTZCOWPJUJYYC2MMXAC
GP56QHRHE3TTUJEUYW32XDPMWODSC5QIYZWDDBTY6NNFQKAVINDQC
BLWAYPKV3MLDZ4ALXLUJ25AIR6PCIL4RFYNRYLB26GFVC2KQBYBAC
if Current_drawing_mode == 'move' then
Current_drawing_mode = Previous_drawing_mode
Previous_drawing_mode = nil
elseif Lines.current then
if Lines.current.pending then
if Lines.current.pending.mode == 'freehand' then
-- the last point added during update is good enough
table.insert(Lines.current.shapes, Lines.current.pending)
elseif Lines.current.pending.mode == 'line' then
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
local j = Drawing.insert_point(Lines.current.points, mx,my)
Lines.current.pending.p2 = j
table.insert(Lines.current.shapes, Lines.current.pending)
end
elseif Lines.current.pending.mode == 'manhattan' then
local p1 = Lines.current.points[Lines.current.pending.p1]
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
if math.abs(mx-p1.x) > math.abs(my-p1.y) then
local j = Drawing.insert_point(Lines.current.points, mx, p1.y)
Lines.current.pending.p2 = j
else
local j = Drawing.insert_point(Lines.current.points, p1.x, my)
Lines.current.pending.p2 = j
end
local p2 = Lines.current.points[Lines.current.pending.p2]
love.mouse.setPosition(16+Drawing.pixels(p2.x), Lines.current.y+Drawing.pixels(p2.y))
table.insert(Lines.current.shapes, Lines.current.pending)
end
elseif Lines.current.pending.mode == 'polygon' then
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
local j = Drawing.insert_point(Lines.current.points, mx,my)
table.insert(Lines.current.shapes, Lines.current.pending)
end
table.insert(Lines.current.shapes, Lines.current.pending)
elseif Lines.current.pending.mode == 'circle' then
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
local center = Lines.current.points[Lines.current.pending.center]
Lines.current.pending.radius = math.dist(center.x,center.y, mx,my)
table.insert(Lines.current.shapes, Lines.current.pending)
end
elseif Lines.current.pending.mode == 'arc' then
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
local center = Lines.current.points[Lines.current.pending.center]
Lines.current.pending.end_angle = geom.angle_with_hint(center.x,center.y, mx,my, Lines.current.pending.end_angle)
table.insert(Lines.current.shapes, Lines.current.pending)
end
end
Lines.current.pending = {}
Lines.current = nil
end
end
save_to_disk(Lines, Filename)
Drawing.mouse_released(x,y, button)
end
function Drawing.mouse_released(x,y, button)
if Current_drawing_mode == 'move' then
Current_drawing_mode = Previous_drawing_mode
Previous_drawing_mode = nil
elseif Lines.current then
if Lines.current.pending then
if Lines.current.pending.mode == 'freehand' then
-- the last point added during update is good enough
table.insert(Lines.current.shapes, Lines.current.pending)
elseif Lines.current.pending.mode == 'line' then
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
local j = Drawing.insert_point(Lines.current.points, mx,my)
Lines.current.pending.p2 = j
table.insert(Lines.current.shapes, Lines.current.pending)
end
elseif Lines.current.pending.mode == 'manhattan' then
local p1 = Lines.current.points[Lines.current.pending.p1]
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
if math.abs(mx-p1.x) > math.abs(my-p1.y) then
local j = Drawing.insert_point(Lines.current.points, mx, p1.y)
Lines.current.pending.p2 = j
else
local j = Drawing.insert_point(Lines.current.points, p1.x, my)
Lines.current.pending.p2 = j
end
local p2 = Lines.current.points[Lines.current.pending.p2]
love.mouse.setPosition(16+Drawing.pixels(p2.x), Lines.current.y+Drawing.pixels(p2.y))
table.insert(Lines.current.shapes, Lines.current.pending)
end
elseif Lines.current.pending.mode == 'polygon' then
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
local j = Drawing.insert_point(Lines.current.points, mx,my)
table.insert(Lines.current.shapes, Lines.current.pending)
end
table.insert(Lines.current.shapes, Lines.current.pending)
elseif Lines.current.pending.mode == 'circle' then
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
local center = Lines.current.points[Lines.current.pending.center]
Lines.current.pending.radius = geom.dist(center.x,center.y, mx,my)
table.insert(Lines.current.shapes, Lines.current.pending)
end
elseif Lines.current.pending.mode == 'arc' then
local mx,my = Drawing.coord(x-16), Drawing.coord(y-Lines.current.y)
if mx >= 0 and mx < 256 and my >= 0 and my < Lines.current.h then
local center = Lines.current.points[Lines.current.pending.center]
Lines.current.pending.end_angle = geom.angle_with_hint(center.x,center.y, mx,my, Lines.current.pending.end_angle)
table.insert(Lines.current.shapes, Lines.current.pending)
end
end
Lines.current.pending = {}
Lines.current = nil
end
end
save_to_disk(Lines, Filename)