more precise shape selection

[?]
Jun 18, 2022, 6:15 AM
WPW3AVFS3WQVHNSCYVKX7ABWTQUUGVO4SXYCJZT2WOL6TOITX7EQC

Dependencies

  • [2] B4YZWV6S bugfix: checking if a point is on a manhattan line
  • [3] LAW2O3NW extract variable Margin_left
  • [4] K2X6G75Z start writing some tests for drawings
  • [5] VHQCNMAR several more modules
  • [6] LYN3L74W correct commit f3abc2cbf2
  • [7] XNFTJHC4 split keyboard handling between Text and Drawing
  • [8] WTDKUACN rectangle and square shapes
  • [*] BLWAYPKV extract a module
  • [*] DRFE3B3Z mouse buttons are integers, not strings

Change contents

  • edit in geom.lua at line 3
    [5.11597]
    [5.11597]
    function geom.on_any_shape(x,y, drawing)
    for _,shape in ipairs(drawing.shapes) do
    assert(shape)
    if geom.on_shape(x,y, drawing, shape) then
    return true
    end
    end
    return false
    end
  • replacement in geom.lua at line 27
    [2.240][2.240:283]()
    return y >= y1*0.95 and y <= y2*1.05
    [2.240]
    [2.283]
    return y >= y1-2 and y <= y2+2
  • replacement in geom.lua at line 34
    [2.438][2.438:481]()
    return x >= x1*0.95 and x <= x2*1.05
    [2.438]
    [2.510]
    return x >= x1-2 and x <= x2+2
  • replacement in geom.lua at line 40
    [5.12094][5.5061:5122]()
    return geom.dist(center.x,center.y, x,y) == shape.radius
    [5.12094]
    [5.12155]
    local dist = geom.dist(center.x,center.y, x,y)
    return dist > shape.radius*0.95 and dist < shape.radius*1.05
  • replacement in geom.lua at line 79
    [5.13048][5.13048:13081]()
    if math.abs(p1.x-x) > 5 then
    [5.13048]
    [5.13081]
    if math.abs(p1.x-x) > 2 then
  • replacement in geom.lua at line 86
    [5.13184][5.13184:13215]()
    return y >= y1 and y <= y2
    [5.13184]
    [5.13215]
    return y >= y1-2 and y <= y2+2
  • replacement in geom.lua at line 91
    [5.13333][5.13333:13370]()
    if yp < 0.95*y or yp > 1.05*y then
    [5.13333]
    [5.13370]
    if yp < y-2 or yp > y+2 then
  • replacement in geom.lua at line 96
    [5.13451][5.13451:13483]()
    return k > -0.05 and k < 1.05
    [5.13451]
    [5.13483]
    return k > -0.005 and k < 1.005
  • edit in drawing.lua at line 6
    [4.1602]
    [10.147]
    Show_nearby = false
  • edit in drawing.lua at line 33
    [10.817]
    [3.3000]
    if Show_nearby then
    love.graphics.setColor(1,0.75,0.75)
    for y=0,127 do
    for x=0,255 do
    if geom.on_any_shape(x,y, line) then
    love.graphics.circle('fill', Drawing.pixels(x)+Margin_left, Drawing.pixels(y)+line.y, 2)
    end
    end
    end
    end
  • edit in drawing.lua at line 386
    [5.5258]
    [11.1614]
    if chord == 'C-a' then
    Show_nearby = not Show_nearby
    return
    end