some very basic animations for switching panes

In order to achieve this I'm forced to switch the default LÖVE blend
mode, which might not be a good trade-off. In particular, any use of the
alpha channel looks very different.

Even if I get rid of this commit, I'm learning how hard it's going to be
to support all possible blend modes in an app like this. So there are
some major limitations in the sorts of LÖVE programs that will be
possible.
This commit is contained in:
Kartik K. Agaram 2023-11-19 18:37:36 -08:00
parent 47d38eabf2
commit 5d49cd9507
4 changed files with 17 additions and 7 deletions

View File

@ -1,6 +1,7 @@
draw_canvas = function()
if Current_pane.canvas == nil then return end
love.graphics.setBlendMode('alpha', 'premultiplied')
love.graphics.setBlendMode('replace')
-- love.graphics.setBlendMode('alpha', 'premultiplied')
love.graphics.setColor(1,1,1,1)
love.graphics.draw(Current_pane.canvas, 0,0)
love.graphics.setBlendMode('alpha')

View File

@ -11,7 +11,10 @@ run_button = function()
Current_pane.canvas = love.graphics.newCanvas()
love.graphics.setCanvas(Current_pane.canvas)
love.graphics.push('all')
love.graphics.setBlendMode('replace')
love.graphics.setBackgroundColor(1,1,1)
love.graphics.setColor(1,1,1)
love.graphics.rectangle('fill', 0,0, App.screen.width, App.screen.height)
love.graphics.setColor(0,0,0)
Current_pane.output_editor_state.lines = {}
Text.redraw_all(Current_pane.output_editor_state)

View File

@ -1,16 +1,15 @@
slide_canvas = function(pane_index, dir)
local speed = 20 -- px/frame
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)
for x=0,App.screen.width,speed do
draw_previous_canvas(Panes[pane_index].canvas, x)
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)
for x=0,-App.screen.width,-speed do
draw_previous_canvas(Panes[pane_index].canvas, x)
end_frame()
end
end

View File

@ -0,0 +1,7 @@
draw_previous_canvas = function(canvas, x)
if canvas == nil then return end
love.graphics.setBlendMode('replace', 'premultiplied')
love.graphics.setColor(1,1,1,1)
love.graphics.draw(canvas, x,0)
love.graphics.setBlendMode('alpha')
end