6DE7RBZ6RHNEICJ7EUMCTROK43LW4LYINULIF2QEQOKCXWLUYUXAC EF6MFB46IJA3TMTGY6DNPFB46RETYX6L2JGX2P567T2XFY47MB3AC HYEAFRZ2UEKDYTAE2GDQLHEJBPQASP2NDLMXB7F6MTVK2BKOXKEAC JCSLDGAH2F6AIY4Z6XM6K4LOMW7EFY3E4NF5YXLMHLTYTX3A4Z3QC VHQCNMARPMNBSIUFLJG7HVK4QGDNPCGNVFLHS3I4IGNVSV5MRLYQC OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC MGOQ5XAVFTWZPBG2O5ZTGSEKU6BRJKQZLDV6CM4737VD2FAEB5JQC AVQ5MC5DWNLI6LUUIPGBLGP4LKRPGWBY4THNY25OBT2FAVHC6MCAC SNDZOK6QJUASKYLYBHIATA7WXPCPZTEYEWA63I4H7HH3JT3B4U6AC GCUARQ2GJT3Y5K6LOOA6S7SOBMSXU7VV7LT355TOMFFPBQ3ZVYKAC HWPK4SMPGZMXWXKCVX667676ZWN5Q2XZSTMVAADG7JNRF6XE45RQC NL5J7Z5H577GPKGNS5TDRVWC55VLA2UCZE34F5WR4AJ5N265UECAC FMQ74DP324YKGBSTNMHBJMT6FYP5NI26MM43VUPGKODI5DVDCUXQC ZOOY3ME4BUD6RLWCKZFA62JNN4BMPOXH24HGTFWPWEKDECOXMFUAC IFGAJAF7UWM236QV4NWP2C67TJPQGXNBC2RTZCOWPJUJYYC2MMXAC GP56QHRHE3TTUJEUYW32XDPMWODSC5QIYZWDDBTY6NNFQKAVINDQC BLWAYPKV3MLDZ4ALXLUJ25AIR6PCIL4RFYNRYLB26GFVC2KQBYBAC if Current_drawing_mode == 'move' thenCurrent_drawing_mode = Previous_drawing_modePrevious_drawing_mode = nilelseif Lines.current thenif Lines.current.pending thenif Lines.current.pending.mode == 'freehand' then-- the last point added during update is good enoughtable.insert(Lines.current.shapes, Lines.current.pending)elseif Lines.current.pending.mode == 'line' thenlocal 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 thenlocal j = Drawing.insert_point(Lines.current.points, mx,my)Lines.current.pending.p2 = jtable.insert(Lines.current.shapes, Lines.current.pending)endelseif Lines.current.pending.mode == 'manhattan' thenlocal 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 thenif math.abs(mx-p1.x) > math.abs(my-p1.y) thenlocal j = Drawing.insert_point(Lines.current.points, mx, p1.y)Lines.current.pending.p2 = jelselocal j = Drawing.insert_point(Lines.current.points, p1.x, my)Lines.current.pending.p2 = jendlocal 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)endelseif Lines.current.pending.mode == 'polygon' thenlocal 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 thenlocal j = Drawing.insert_point(Lines.current.points, mx,my)table.insert(Lines.current.shapes, Lines.current.pending)endtable.insert(Lines.current.shapes, Lines.current.pending)elseif Lines.current.pending.mode == 'circle' thenlocal 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 thenlocal 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)endelseif Lines.current.pending.mode == 'arc' thenlocal 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 thenlocal 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)endendLines.current.pending = {}Lines.current = nilendendsave_to_disk(Lines, Filename)
Drawing.mouse_released(x,y, button)
endfunction Drawing.mouse_released(x,y, button)if Current_drawing_mode == 'move' thenCurrent_drawing_mode = Previous_drawing_modePrevious_drawing_mode = nilelseif Lines.current thenif Lines.current.pending thenif Lines.current.pending.mode == 'freehand' then-- the last point added during update is good enoughtable.insert(Lines.current.shapes, Lines.current.pending)elseif Lines.current.pending.mode == 'line' thenlocal 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 thenlocal j = Drawing.insert_point(Lines.current.points, mx,my)Lines.current.pending.p2 = jtable.insert(Lines.current.shapes, Lines.current.pending)endelseif Lines.current.pending.mode == 'manhattan' thenlocal 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 thenif math.abs(mx-p1.x) > math.abs(my-p1.y) thenlocal j = Drawing.insert_point(Lines.current.points, mx, p1.y)Lines.current.pending.p2 = jelselocal j = Drawing.insert_point(Lines.current.points, p1.x, my)Lines.current.pending.p2 = jendlocal 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)endelseif Lines.current.pending.mode == 'polygon' thenlocal 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 thenlocal j = Drawing.insert_point(Lines.current.points, mx,my)table.insert(Lines.current.shapes, Lines.current.pending)endtable.insert(Lines.current.shapes, Lines.current.pending)elseif Lines.current.pending.mode == 'circle' thenlocal 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 thenlocal 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)endelseif Lines.current.pending.mode == 'arc' thenlocal 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 thenlocal 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)endendLines.current.pending = {}Lines.current = nilendendsave_to_disk(Lines, Filename)