delete points or shapes

[?]
May 15, 2022, 6:55 AM
FBDRL6LHPTBPMU3R356OLY4XE4ELQQEDXMCZGCBT2RFHLR7VQXQAC

Dependencies

  • [2] VQFBNHU4 make point near focus 'pop'
  • [3] T664AOUG make points easier to acquire
  • [4] GCUARQ2G bugfix: clipping in line and manhattan mode
  • [5] SNDZOK6Q slightly less strange now that we have the same two ways to move points as any other operation
  • [6] IFGAJAF7 add a level of indirection to vertices of shapes
  • [7] KCIM5UTV revert: back to freehand
  • [8] ZD63LJ2T bugfix: keep the click to create a new drawing from creating a new shape in the drawing
  • [9] JVRL5TWL store device-independent coordinates inside drawings
  • [10] OTIBCAUJ love2d scaffold
  • [11] WAZVXUV2 simplest possible way to straighten strokes
  • [12] 3XD6M3CF refactor
  • [13] WDWXNW7V slightly strange way to move points
  • [14] H7OEU6WP experimental approach to combining keyboard and mouse while drawing
  • [15] HWPK4SMP new mode: manhattan
  • [16] JCSLDGAH beginnings of support for multiple shapes
  • [17] D2GCFTTT clean up repl functionality
  • [18] 6LJZN727 handle chords
  • [19] O2UFJ6G3 switch from freehand to just straight lines
  • [*] ZOOY3ME4 new mode: circle arc

Change contents

  • replacement in main.lua at line 100
    [6.237][3.3:34](),[3.34][6.277:317](),[6.277][6.277:317](),[6.317][2.3:80](),[2.80][6.317:370](),[6.317][6.317:370](),[6.370][2.81:158]()
    if near(p, mx,my) then
    love.graphics.setColor(1,0,0)
    love.graphics.circle('line', pixels(p.x)+16,pixels(p.y)+line.y, 4)
    else
    love.graphics.setColor(0,0,0)
    love.graphics.circle('fill', pixels(p.x)+16,pixels(p.y)+line.y, 2)
    [6.237]
    [6.370]
    if p.deleted == nil then
    if near(p, mx,my) then
    love.graphics.setColor(1,0,0)
    love.graphics.circle('line', pixels(p.x)+16,pixels(p.y)+line.y, 4)
    else
    love.graphics.setColor(0,0,0)
    love.graphics.circle('fill', pixels(p.x)+16,pixels(p.y)+line.y, 2)
    end
  • edit in main.lua at line 289
    [21.694]
    [21.694]
    elseif shape.mode == 'deleted' then
  • edit in main.lua at line 368
    [21.1549]
    [6.3287]
    elseif shape.mode == 'deleted' then
  • replacement in main.lua at line 472
    [6.1063][6.1063:1092]()
    elseif chord == 'C-d' then
    [6.1063]
    [6.1092]
    elseif chord == 'C-x' then
  • replacement in main.lua at line 549
    [6.864][6.864:910]()
    local drawing,p = select_point_at_mouse()
    [6.864]
    [6.910]
    local drawing,_,p = select_point_at_mouse()
  • replacement in main.lua at line 557
    [5.471][5.471:517]()
    local drawing,p = select_point_at_mouse()
    [5.471]
    [5.517]
    local drawing,_,p = select_point_at_mouse()
  • edit in main.lua at line 563
    [6.1064]
    [6.1064]
    end
    elseif chord == 'C-d' and not love.mouse.isDown('1') then
    local drawing,i,p = select_point_at_mouse()
    if drawing then
    for _,shape in ipairs(drawing.shapes) do
    if contains_point(shape, i) then
    shape.mode = 'deleted'
    end
    end
    drawing.points[i].deleted = true
    end
    local drawing,i,shape = select_shape_at_mouse()
    if drawing then
    shape.mode = 'deleted'
  • replacement in main.lua at line 613
    [4.1408][6.3419:3460](),[6.433][6.3419:3460]()
    if on_shape(mx,my, shape) then
    [4.1408]
    [6.507]
    if on_shape(mx,my, drawing, shape) then
  • replacement in main.lua at line 628
    [6.1475][6.1475:1524]()
    for _,point in ipairs(drawing.points) do
    [6.1475]
    [6.1524]
    for i,point in ipairs(drawing.points) do
  • replacement in main.lua at line 631
    [6.1585][6.1585:1618]()
    return drawing,point
    [6.1585]
    [6.448]
    return drawing,i,point
  • edit in main.lua at line 650
    [6.1841]
    [6.2255]
    function contains_point(shape, p)
    if shape.mode == 'freehand' then
    -- not supported
    elseif shape.mode == 'line' then
    print(p, shape.p1, shape.p2)
    return shape.p1 == p or shape.p2 == p
    elseif shape.mode == 'polygon' then
    return table.find(shape.vertices, p)
    elseif shape.mode == 'circle' then
    return shape.center == p
    elseif shape.mode == 'arc' then
    return shape.center == p
    -- ugh, how to support angles
    elseif shape.mode == 'deleted' then
    -- already done
    else
    assert(false)
    end
    end