starting to experiment with animated pane transitions

akkartik
Nov 20, 2023, 1:33 AM
2Q437U4FVEYO3Y22OC3NC5MAYVEDTTCWCRJHBKHKWA4WZSPWYUDQC

Dependencies

  • [2] VUF2SX7B implement carousel buttons for inserting/switching current pane
  • [3] UEG224LH debug animations
  • [*] R5QXEHUI somebody stop me
  • [*] 5RUFNRJO start of the visual skeleton
  • [*] ZM7NOBRM new fork: carousel shell

Change contents

  • file addition: 0059-slide_canvas (----------)
    [5.2]
    slide_canvas = function(pane_index, dir)
    return function()
    end_frame()
    if dir == 'right' then
    for i=1,40 do
    print(Current_time, i)
    love.graphics.rectangle('fill', i*10,0, 30, App.screen.height)
    end_frame()
    end
    elseif dir == 'left' then
    for i=20,1,-1 do
    print(i)
    love.graphics.line(i*50,0, i*50, App.screen.height)
    end_frame()
    end
    end
    end
    end
  • file addition: 0058-draw_next_frames_of_animations (----------)
    [5.2]
    -- update any in-progress animations
    -- return whether any work remains
    draw_next_frames_of_animations = function()
    local a = Animations_in_progress
    for i=#a,1,-1 do
    if coroutine.status(a[i].co) == 'dead' then
    table.remove(a, i)
    else
    local status, err = coroutine.resume(a[i].co)
    if status == false then error(err) end
    end
    end
    return #a > 0
    end
  • file addition: 0056-end_frame (----------)
    [5.2]
    -- Pause a drawing called by animate().
    end_frame = function()
    coroutine.yield()
    end
  • file addition: 0054-Animations_in_progress (----------)
    [5.2]
    -- Intermediate state during animations.
    Animations_in_progress = {}
  • file addition: 0052-enable_loiter (----------)
    [5.2]
    -- A debugging aid to help animate intermediate results within f.
    -- Pause animation in the current frame using loiter().
    -- Try to only have one such call in your program.
    -- You can have multiple, but things might get confusing if one of them indirectly calls the other,
    -- or more generally if a single function ever loiters sometimes under the call tree of one and sometimes under the other.
    enable_loiter = function(f, ...)
    local args = {...}
    Error_with_callstack = nil
    local co = coroutine.create(
    function()
    xpcall(function()
    f(unpack(args))
    end,
    save_callstack)
    end)
    coroutine.resume(co, ...)
    if Error_with_callstack then
    error(Error_with_callstack)
    end
    table.insert(Debug_animations_in_progress, {co=co, next_run=Current_time+0.3})
    end
  • edit in 0021-draw_menu at line 28
    [2.1336]
    [2.1336]
    animate(slide_canvas(Current_pane_index+1, 'right'))
  • edit in 0021-draw_menu at line 43
    [2.1784]
    [2.1784]
    animate(slide_canvas(Current_pane_index-1, 'left'))
  • edit in 0021-draw_menu at line 55
    [2.2220]
    [2.2220]
    animate(slide_canvas(Current_pane_index-1, 'left'))
  • edit in 0012-on.draw at line 13
    [6.1960]
    [7.3033]
    draw_next_frames_of_animations()
  • replacement in 0007-save_callstack at line 1
    [3.164][3.165:198]()
    -- Internal helper for animate()
    [3.164]
    [3.198]
    -- Internal helper for animations.
  • replacement in 0007-save_callstack at line 7
    [3.614][3.614:618]()
    end
    [3.614]
    end
  • replacement in 0006-loiter at line 2
    [3.724][3.724:788]()
    -- Can only be called from functions invoked using `animate()`.
    [3.724]
    [3.788]
    -- Can only be called from functions invoked using `enable_loiter()`.
  • replacement in 0006-loiter at line 5
    [3.827][3.827:831]()
    end
    [3.827]
    end
  • replacement in 0005-animate at line 1
    [3.869][3.870:1266]()
    -- A debugging aid to help animate intermediate results within f.
    -- Pause animation in the current frame using loiter().
    -- Try to only have one such call in your program.
    -- You can have multiple, but things might get confusing if one of them indirectly calls the other,
    -- or more generally if a single function ever loiters sometimes under the call tree of one and sometimes under the other.
    [3.869]
    [3.1266]
    -- Animate 'f' by smearing its work across multiple frames.
    -- Pause animation in the current frame using end_frame().
  • replacement in 0005-animate at line 17
    [3.1584][3.1584:1668]()
    table.insert(Debug_animations_in_progress, {co=co, next_run=Current_time+0.3})
    end
    [3.1584]
    table.insert(Animations_in_progress, {co=co})
    end