move mouse_released events to Drawing

[?]
May 18, 2022, 5:55 AM
6DE7RBZ6RHNEICJ7EUMCTROK43LW4LYINULIF2QEQOKCXWLUYUXAC

Dependencies

  • [2] EF6MFB46 assume we always have a filename
  • [3] HYEAFRZ2 split mouse_pressed events between Text and Drawing
  • [4] GCUARQ2G bugfix: clipping in line and manhattan mode
  • [5] AVQ5MC5D finish uppercasing all globals
  • [6] HWPK4SMP new mode: manhattan
  • [7] SNDZOK6Q slightly less strange now that we have the same two ways to move points as any other operation
  • [8] FMQ74DP3 new mode: circle
  • [9] NL5J7Z5H new mode: polygon
  • [10] JCSLDGAH beginnings of support for multiple shapes
  • [11] ZOOY3ME4 new mode: circle arc
  • [12] OTIBCAUJ love2d scaffold
  • [13] IFGAJAF7 add a level of indirection to vertices of shapes
  • [14] MGOQ5XAV start uppercasing globals
  • [15] VHQCNMAR several more modules
  • [16] YKRF5V3Z starting to load/save
  • [17] GP56QHRH bugfix
  • [18] ZD63LJ2T bugfix: keep the click to create a new drawing from creating a new shape in the drawing
  • [*] BLWAYPKV extract a module

Change contents

  • replacement in main.lua at line 173
    [4.1626][4.1723:1845](),[4.1845][4.570:687](),[4.2692][4.570:687](),[4.301][4.570:687](),[4.687][4.1739:1800](),[4.1739][4.1739:1800](),[4.1800][4.688:809](),[4.809][4.1846:1922](),[4.1922][4.869:943](),[4.869][4.869:943](),[4.943][4.1923:1993](),[4.1993][4.1005:1112](),[4.1005][4.1005:1112](),[4.1112][4.440:452](),[4.440][4.440:452](),[4.452][4.1113:1239](),[4.1239][4.1994:2070](),[4.2070][4.1299:1373](),[4.1299][4.1299:1373](),[4.1373][4.527:583](),[4.527][4.527:583](),[4.583][4.2071:2146](),[4.2146][4.1441:1482](),[4.1441][4.1441:1482](),[4.1482][4.691:706](),[4.691][4.691:706](),[4.706][4.2147:2222](),[4.2222][4.1550:1591](),[4.1550][4.1550:1591](),[4.1591][4.814:828](),[4.814][4.814:828](),[4.828][4.1592:1660](),[4.1660][4.2223:2319](),[4.2319][4.1740:1808](),[4.1740][4.1740:1808](),[4.1044][4.464:476](),[4.1808][4.464:476](),[4.464][4.464:476](),[4.476][4.1809:1867](),[4.1867][4.2320:2396](),[4.2396][4.1927:2001](),[4.1927][4.1927:2001](),[4.2001][4.2397:2467](),[4.2467][4.2063:2131](),[4.2063][4.2063:2131](),[4.2131][4.325:337](),[4.325][4.325:337](),[4.337][4.2132:2255](),[4.2255][4.2468:2544](),[4.2544][4.2315:2610](),[4.2315][4.2315:2610](),[4.2610][4.415:427](),[4.415][4.415:427](),[4.427][4.2611:2665](),[4.2665][4.2545:2621](),[4.2621][4.2725:2875](),[4.2725][4.2725:2875](),[4.2875][4.2622:2746](),[4.2746][4.2994:3062](),[4.2994][4.2994:3062](),[4.3062][4.454:466](),[4.454][4.454:466](),[4.403][4.1962:1972](),[4.427][4.1962:1972](),[4.466][4.1962:1972](),[4.620][4.1962:1972](),[4.630][4.1962:1972](),[4.1962][4.1962:1972](),[4.1972][4.3063:3122](),[4.3122][4.2095:2103](),[4.2095][4.2095:2103](),[4.107][4.3110:3116](),[4.1180][4.3110:3116](),[4.1205][4.3110:3116](),[4.1239][4.3110:3116](),[4.1441][4.3110:3116](),[4.1535][4.3110:3116](),[4.3110][4.3110:3116](),[4.3116][2.3:35]()
    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)
    [4.1626]
    [4.3116]
    Drawing.mouse_released(x,y, button)
  • edit in drawing.lua at line 70
    [3.1703]
    [4.19072]
    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)