I can't be trusted to do anything without a test.
This should fix #5. Please reopen if it doesn't.
LYN3L74WRXZI4KNNIMNLPRFQ36RAGPWNE2O5AMB42H3CSTI6QM6QC B4YZWV6SQI6HK4PZAUKB5L6TISNECL72GFZZET34Q673OVN7IBRAC KAUD3YIKPOXHIUZVR3VCIQHQGBPWTBHXEXC3VQIPAN2BAV6SEMIQC AVFRVNFRGQ3KY6CPC2QFPYVO6OAGZVYV7IVX5PSKGCNWO24Q2MTAC VHQCNMARPMNBSIUFLJG7HVK4QGDNPCGNVFLHS3I4IGNVSV5MRLYQC L6XA5EY2FVDQFRGCBFSCOM6O4GYN74K3YTZKGFUOPXIUYA3YT5JQC K2X6G75Z6XBC4DVIRWC5HC7XA3A2SKOM3MWSQTCFEYWIJL7LME2QC RT6EV6OPUYCXYZOX2PHFXJ7KT77KHNEVINEGQXIQLHQVKPGTN6VQC BLWAYPKV3MLDZ4ALXLUJ25AIR6PCIL4RFYNRYLB26GFVC2KQBYBAC LAW2O3NWVFTPBSKIMIXPAGYBDOCHYJNKCAVWKNKH62G42DIKZCYQC 6DE7RBZ6RHNEICJ7EUMCTROK43LW4LYINULIF2QEQOKCXWLUYUXAC DRFE3B3ZKRG4RY2R5Q3SDFD3LH4EXUX3CZCDFBNAXVI2SLDS57PAC JAXPXLEBWHBLNLMZ5VCSO63X6Z5WT4KZKWBOVACCAVX4QJAWWNYQC JFFUF5ALUWPDM7IEDEZVAYG2SVXO334STONRGKVB3QKY2TT5QGBQC 6UZ2JNZECLGR4VFEPQKEJWORNOMNKZFS5DV4TVXDKG3IX3ZPLDSAC XNFTJHC4QSHNSIWNN7K6QZEZ37GTQYKHS4EPNSVPQCUSWREROGIQC function test_move_point_on_manhattan_line()io.write('\ntest_move_point_on_manhattan_line')-- create a drawing with a manhattan lineFilename = 'foo'App.screen.init{width=Margin_left+300, height=300}Lines = load_array{'```lines', '```', ''}Line_width = 256 -- drawing coordinates 1:1 with pixelsCurrent_drawing_mode = 'manhattan'App.draw()App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+46, 1)local drawing = Lines[1]check_eq(#drawing.shapes, 1, 'F - test_move_point_on_manhattan_line/baseline/#shapes')check_eq(#drawing.points, 2, 'F - test_move_point_on_manhattan_line/baseline/#points')check_eq(drawing.shapes[1].mode, 'manhattan', 'F - test_move_point_on_manhattan_line/baseline/shape:1')App.draw()-- enter 'move' modeApp.run_after_keychord('C-u')check_eq(Current_drawing_mode, 'move', 'F - test_move_point_on_manhattan_line/mode:1')-- move pointApp.mouse_move(Margin_left+26, Margin_top+Drawing_padding_top+44)App.update(0.05)-- line is no longer manhattancheck_eq(drawing.shapes[1].mode, 'line', 'F - test_move_point_on_manhattan_line/baseline/shape:1')end
function Drawing.relax_constraints(drawing, p)for _,shape in ipairs(drawing.shapes) doif shape.mode == 'manhattan' thenif shape.p1 == p thenshape.mode = 'line'elseif shape.p2 == p thenshape.mode = 'line'endelseif shape.mode == 'rectangle' or shape.mode == 'square' thenfor _,v in ipairs(shape.vertices) doif v == p thenshape.mode = 'polygon'endendendendend