starting to experiment with animated pane transitions
Dependencies
- [2]
VUF2SX7Bimplement carousel buttons for inserting/switching current pane - [3]
UEG224LHdebug animations - [*]
R5QXEHUIsomebody stop me - [*]
5RUFNRJOstart of the visual skeleton - [*]
ZM7NOBRMnew 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' thenfor i=1,40 doprint(Current_time, i)love.graphics.rectangle('fill', i*10,0, 30, App.screen.height)end_frame()endelseif dir == 'left' thenfor i=20,1,-1 doprint(i)love.graphics.line(i*50,0, i*50, App.screen.height)end_frame()endendendend - file addition: 0058-draw_next_frames_of_animations[5.2]
-- update any in-progress animations-- return whether any work remainsdraw_next_frames_of_animations = function()local a = Animations_in_progressfor i=#a,1,-1 doif coroutine.status(a[i].co) == 'dead' thentable.remove(a, i)elselocal status, err = coroutine.resume(a[i].co)if status == false then error(err) endendendreturn #a > 0end - 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 = nillocal co = coroutine.create(function()xpcall(function()f(unpack(args))end,save_callstack)end)coroutine.resume(co, ...)if Error_with_callstack thenerror(Error_with_callstack)endtable.insert(Debug_animations_in_progress, {co=co, next_run=Current_time+0.3})end - edit in 0021-draw_menu at line 28
animate(slide_canvas(Current_pane_index+1, 'right')) - edit in 0021-draw_menu at line 43
animate(slide_canvas(Current_pane_index-1, 'left')) - edit in 0021-draw_menu at line 55
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
-- Internal helper for animate()-- Internal helper for animations. - replacement in 0007-save_callstack at line 7
end[3.614]end - replacement in 0006-loiter at line 2
-- Can only be called from functions invoked using `animate()`.-- Can only be called from functions invoked using `enable_loiter()`. - replacement in 0006-loiter at line 5
end[3.827]end - replacement in 0005-animate at line 1
-- 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.-- 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
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