dead code

[?]
Jun 15, 2022, 6:11 PM
VTYCPKNHTRN42MQ6IRGZDU6YLYXCPTUSUWVMMBOE7YC2H3UGK7EQC

Dependencies

  • [2] DRFE3B3Z mouse buttons are integers, not strings
  • [3] XNFTJHC4 split keyboard handling between Text and Drawing
  • [4] NVSWVPW5 move
  • [5] H4K2GFIL experiment: give up on changing shape mode
  • [6] 2WGRQI5E missing shape modes in a couple more places
  • [7] VFJEVPPO bugfix: function names
  • [8] VHQCNMAR several more modules
  • [9] 6UZ2JNZE yet another key conflict
  • [10] JAXPXLEB set current_drawing_index with current_drawing
  • [11] JFFUF5AL override mouse state lookups in tests
  • [12] LAW2O3NW extract variable Margin_left
  • [*] BLWAYPKV extract a module

Change contents

  • edit in drawing.lua at line 471
    [3.9740][2.2554:2609](),[2.2609][3.9926:10036](),[3.3781][3.9926:10036](),[3.9926][3.9926:10036]()
    elseif chord == 'C-s' and not App.mouse_down(1) then
    local drawing,_,shape = Drawing.select_shape_at_mouse()
    if drawing then
    smoothen(shape)
    end
  • edit in drawing.lua at line 651
    [3.21510][3.21510:22172](),[3.22172][3.102:134](),[3.134][3.22196:22708](),[3.22196][3.22196:22708]()
    function Drawing.convert_line(drawing, shape)
    -- Perhaps we should do a more sophisticated "simple linear regression"
    -- here:
    -- https://en.wikipedia.org/wiki/Linear_regression#Simple_and_multiple_linear_regression
    -- But this works well enough for close-to-linear strokes.
    assert(shape.mode == 'freehand')
    shape.mode = 'line'
    shape.p1 = insert_point(drawing.points, shape.points[1].x, shape.points[1].y)
    local n = #shape.points
    shape.p2 = insert_point(drawing.points, shape.points[n].x, shape.points[n].y)
    end
    -- turn a line either horizontal or vertical
    function Drawing.convert_horvert(drawing, shape)
    if shape.mode == 'freehand' then
    Drawing.convert_line(shape)
    end
    assert(shape.mode == 'line')
    local p1 = drawing.points[shape.p1]
    local p2 = drawing.points[shape.p2]
    if math.abs(p1.x-p2.x) > math.abs(p1.y-p2.y) then
    p2.y = p1.y
    else
    p2.x = p1.x
    end
    end
    function Drawing.smoothen(shape)
    assert(shape.mode == 'freehand')
    for _=1,7 do
    for i=2,#shape.points-1 do
    local a = shape.points[i-1]
    local b = shape.points[i]
    local c = shape.points[i+1]
    b.x = (a.x + b.x + c.x)/3
    b.y = (a.y + b.y + c.y)/3
    end
    end
    end