extract a module

[?]
May 18, 2022, 2:41 AM
BLWAYPKV3MLDZ4ALXLUJ25AIR6PCIL4RFYNRYLB26GFVC2KQBYBAC

Dependencies

  • [2] JS7DUFRA .
  • [3] AVQ5MC5D finish uppercasing all globals
  • [4] XX7G2FFJ intermingle freehand line drawings with text
  • [5] OTIBCAUJ love2d scaffold
  • [6] JVRL5TWL store device-independent coordinates inside drawings
  • [7] KCIM5UTV revert: back to freehand
  • [8] 2FMZNSD7 experiment: only show drawing borders when they can be edited
  • [9] VQFBNHU4 make point near focus 'pop'
  • [10] YHQC72JX slightly tweak boundary between concerns
  • [11] XLDKEAFZ make sure to show the border of a drawing immediately after creating it
  • [12] VVXVV2D2 change data model; text can now have metadata
  • [13] 6LJZN727 handle chords
  • [14] CXCAERTB icons for current_mode
  • [15] GCUARQ2G bugfix: clipping in line and manhattan mode
  • [16] G77XIN7M selecting a stroke
  • [17] 6PUNJS5B backspace
  • [18] Z2CJVAPV lighter border for figures
  • [19] D2GCFTTT clean up repl functionality
  • [20] TGICJQD3 bugfix: move mode
  • [21] VXORMHME delete experimental REPL
  • [22] JCSLDGAH beginnings of support for multiple shapes
  • [23] O2UFJ6G3 switch from freehand to just straight lines
  • [24] FBDRL6LH delete points or shapes
  • [25] MNWHXPBL more lightweight; select just the stroke at the mouse
  • [26] 3CS5KKCI up/down cursor movement
  • [27] K6HMLFLZ color close to drawing
  • [28] T664AOUG make points easier to acquire
  • [29] JS6JSYOT online contextual help
  • [30] 3SYFA5JQ show cursor even on empty lines
  • [31] IFGAJAF7 add a level of indirection to vertices of shapes
  • [32] ZD63LJ2T bugfix: keep the click to create a new drawing from creating a new shape in the drawing
  • [*] R5QXEHUI somebody stop me

Change contents

  • edit in main.lua at line 1
    [4.2]
    [4.2]
    local utf8 = require 'utf8'
  • replacement in main.lua at line 4
    [4.19][4.2:30](),[4.943][4.2:30](),[4.21][4.2:30]()
    local utf8 = require 'utf8'
    [4.19]
    [4.21]
    local Drawing = require 'drawing'
  • edit in main.lua at line 120
    [4.468][4.651:673](),[4.651][4.651:673]()
    -- line drawing
  • replacement in main.lua at line 121
    [4.426][4.2:62](),[4.62][3.1084:1170](),[4.82][4.156:203](),[3.1170][4.156:203](),[4.156][4.156:203](),[4.203][3.1171:1347](),[3.1347][4.92:105](),[4.92][4.92:105](),[4.105][3.1348:1409](),[3.1409][4.161:173](),[4.161][4.161:173](),[4.173][4.2:146](),[4.55][4.2:146](),[4.55][4.279:289](),[4.146][4.279:289](),[4.279][4.279:289](),[4.77][4.500:501](),[4.289][4.500:501](),[4.500][4.500:501](),[4.501][4.147:248](),[4.248][4.78:159](),[4.501][4.78:159](),[4.67][4.804:805](),[4.159][4.804:805](),[4.582][4.804:805](),[4.804][4.804:805](),[4.805][2.3:47](),[2.47][4.47:69](),[4.47][4.47:69](),[4.69][4.98:143](),[4.849][4.98:143](),[4.41][4.45:138](),[4.45][4.45:138](),[4.75][4.45:138](),[4.143][4.45:138](),[4.625][4.45:138](),[4.1307][4.45:138](),[4.45][4.45:138](),[4.280][4.280:292](),[4.292][4.144:237](),[4.237][4.3:340](),[4.158][4.370:382](),[4.340][4.370:382](),[4.370][4.370:382](),[4.159][4.1043:1053](),[4.197][4.1043:1053](),[4.292][4.1043:1053](),[4.457][4.1043:1053](),[4.1345][4.1043:1053](),[4.1043][4.1043:1053](),[4.189][4.458:500](),[4.1053][4.458:500]()
    local pmx,pmy = love.mouse.getX(), love.mouse.getY()
    if pmx < 16+Drawing_width and pmy > line.y and pmy < line.y+pixels(line.h) then
    love.graphics.setColor(0.75,0.75,0.75)
    love.graphics.rectangle('line', 16,line.y, Drawing_width,pixels(line.h))
    if icon[Current_mode] then
    icon[Current_mode](16+Drawing_width-20, line.y+4)
    else
    icon[Previous_mode](16+Drawing_width-20, line.y+4)
    end
    if love.mouse.isDown('1') and love.keyboard.isDown('h') then
    draw_help_with_mouse_pressed(line)
    return
    end
    end
    if line.show_help then
    draw_help_without_mouse_pressed(line)
    return
    end
    local mx,my = coord(love.mouse.getX()-16), coord(love.mouse.getY()-line.y)
    for _,shape in ipairs(line.shapes) do
    assert(shape)
    if on_shape(mx,my, line, shape) then
    love.graphics.setColor(1,0,0)
    else
    love.graphics.setColor(0,0,0)
    end
    draw_shape(16,line.y, line, shape)
    end
    for _,p in ipairs(line.points) do
    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
    end
    end
    draw_pending_shape(16,line.y, line)
    [4.426]
    [4.1240]
    Drawing.draw(line, y)
  • file addition: drawing.lua (----------)
    [34.2]
    -- primitives for editing drawings
    Drawing = {}
    function Drawing.draw(line, y)
    local pmx,pmy = love.mouse.getX(), love.mouse.getY()
    if pmx < 16+Drawing_width and pmy > line.y and pmy < line.y+pixels(line.h) then
    love.graphics.setColor(0.75,0.75,0.75)
    love.graphics.rectangle('line', 16,line.y, Drawing_width,pixels(line.h))
    if icon[Current_mode] then
    icon[Current_mode](16+Drawing_width-20, line.y+4)
    else
    icon[Previous_mode](16+Drawing_width-20, line.y+4)
    end
    if love.mouse.isDown('1') and love.keyboard.isDown('h') then
    draw_help_with_mouse_pressed(line)
    return
    end
    end
    if line.show_help then
    draw_help_without_mouse_pressed(line)
    return
    end
    local mx,my = coord(love.mouse.getX()-16), coord(love.mouse.getY()-line.y)
    for _,shape in ipairs(line.shapes) do
    assert(shape)
    if on_shape(mx,my, line, shape) then
    love.graphics.setColor(1,0,0)
    else
    love.graphics.setColor(0,0,0)
    end
    draw_shape(16,line.y, line, shape)
    end
    for _,p in ipairs(line.points) do
    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
    end
    end
    draw_pending_shape(16,line.y, line)
    end
    return Drawing