new mode: manhattan

[?]
May 14, 2022, 11:52 PM
HWPK4SMPGZMXWXKCVX667676ZWN5Q2XZSTMVAADG7JNRF6XE45RQC

Dependencies

  • [2] S5JIPJPI .
  • [3] IFGAJAF7 add a level of indirection to vertices of shapes
  • [4] EFMLTMZG bugfix: restrict strokes to the drawing they started in
  • [5] JCSLDGAH beginnings of support for multiple shapes
  • [6] ZD63LJ2T bugfix: keep the click to create a new drawing from creating a new shape in the drawing
  • [*] OTIBCAUJ love2d scaffold
  • [*] KCIM5UTV revert: back to freehand
  • [*] T76KKDWZ turn strokes into horizontal and vertical lines

Change contents

  • edit in main.lua at line 150
    [3.630]
    [3.1962]
    elseif lines.current.pending.mode == 'manhattan' then
    local p1 = lines.current.points[lines.current.pending.p1]
    local mx,my = coord(x-16), coord(y-lines.current.y)
    if math.abs(mx-p1.x) > math.abs(my-p1.y) then
    local j = insert_point(lines.current.points, mx, p1.y)
    lines.current.pending.p2 = j
    else
    local j = 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+pixels(p2.x), lines.current.y+pixels(p2.y))
  • replacement in main.lua at line 177
    [2.97][3.2250:2293](),[3.712][3.2250:2293](),[3.2250][3.2250:2293]()
    elseif current_mode == 'line' then
    [2.97]
    [3.631]
    elseif current_mode == 'line' or current_mode == 'manhattan' then
  • replacement in main.lua at line 212
    [3.2688][3.2688:2723]()
    elseif shape.mode == 'line' then
    [3.2688]
    [3.1007]
    elseif shape.mode == 'line' or shape.mode == 'manhattan' then
  • edit in main.lua at line 226
    [3.1441]
    [3.3110]
    elseif shape.mode == 'manhattan' then
    local p1 = drawing.points[shape.p1]
    local mx,my = coord(love.mouse.getX()-16), coord(love.mouse.getY()-drawing.y)
    if math.abs(mx-p1.x) > math.abs(my-p1.y) then
    love.graphics.line(pixels(p1.x)+left,pixels(p1.y)+top, pixels(mx)+left,pixels(p1.y)+top)
    else
    love.graphics.line(pixels(p1.x)+left,pixels(p1.y)+top, pixels(p1.x)+left,pixels(my)+top)
    end
  • edit in main.lua at line 242
    [3.1567]
    [3.3287]
    elseif shape.mode == 'manhattan' then
    return x == drawing.points[shape.p1].x or y == drawing.points[shape.p1].y
  • edit in main.lua at line 245
    [3.3294]
    [3.3294]
    print(shape.mode)
  • edit in main.lua at line 331
    [9.1022]
    [10.11]
    elseif love.mouse.isDown('1') and chord == 'm' then
    current_mode = 'manhattan'
    local drawing = select_drawing_at_mouse()
    drawing.pending.mode = 'manhattan'
  • edit in main.lua at line 336
    [10.40]
    [10.40]
    current_mode = 'manhattan'
  • edit in main.lua at line 389
    [9.1073]
    [3.2255]
    function select_drawing_at_mouse()
    for _,drawing in ipairs(lines) do
    if type(drawing) == 'table' then
    local x, y = love.mouse.getX(), love.mouse.getY()
    if y >= drawing.y and y < drawing.y + pixels(drawing.h) and x >= 16 and x < 16+drawingw then
    return drawing
    end
    end
    end
    end