mirror of
https://github.com/kepler155c/opus
synced 2025-10-15 15:57:40 +00:00
canvas use in UI overhaul
This commit is contained in:
@@ -7,24 +7,14 @@ function Transition.slideLeft(args)
|
||||
local easing = args.easing or 'outQuint'
|
||||
local pos = { x = args.ex }
|
||||
local tween = Tween.new(ticks, pos, { x = args.x }, easing)
|
||||
local lastScreen = args.canvas:copy()
|
||||
|
||||
args.canvas:move(pos.x, args.canvas.y)
|
||||
|
||||
return function(device)
|
||||
local finished = tween:update(1)
|
||||
local x = math.floor(pos.x)
|
||||
lastScreen:dirty()
|
||||
lastScreen:blit(device, {
|
||||
x = args.ex - x + args.x,
|
||||
y = args.y,
|
||||
ex = args.ex,
|
||||
ey = args.ey },
|
||||
{ x = args.x, y = args.y })
|
||||
args.canvas:blit(device, {
|
||||
x = args.x,
|
||||
y = args.y,
|
||||
ex = args.ex - x + args.x,
|
||||
ey = args.ey },
|
||||
{ x = x, y = args.y })
|
||||
args.canvas:move(math.floor(pos.x), args.canvas.y)
|
||||
args.canvas:dirty()
|
||||
args.canvas:render(device)
|
||||
return not finished
|
||||
end
|
||||
end
|
||||
@@ -32,26 +22,16 @@ end
|
||||
function Transition.slideRight(args)
|
||||
local ticks = args.ticks or 6
|
||||
local easing = args.easing or'outQuint'
|
||||
local pos = { x = args.x }
|
||||
local tween = Tween.new(ticks, pos, { x = args.ex }, easing)
|
||||
local lastScreen = args.canvas:copy()
|
||||
local pos = { x = -args.canvas.width }
|
||||
local tween = Tween.new(ticks, pos, { x = 1 }, easing)
|
||||
|
||||
args.canvas:move(pos.x, args.canvas.y)
|
||||
|
||||
return function(device)
|
||||
local finished = tween:update(1)
|
||||
local x = math.floor(pos.x)
|
||||
lastScreen:dirty()
|
||||
lastScreen:blit(device, {
|
||||
x = args.x,
|
||||
y = args.y,
|
||||
ex = args.ex - x + args.x,
|
||||
ey = args.ey },
|
||||
{ x = x, y = args.y })
|
||||
args.canvas:blit(device, {
|
||||
x = args.ex - x + args.x,
|
||||
y = args.y,
|
||||
ex = args.ex,
|
||||
ey = args.ey },
|
||||
{ x = args.x, y = args.y })
|
||||
args.canvas:move(math.floor(pos.x), args.canvas.y)
|
||||
args.canvas:dirty()
|
||||
args.canvas:render(device)
|
||||
return not finished
|
||||
end
|
||||
end
|
||||
@@ -62,27 +42,13 @@ function Transition.expandUp(args)
|
||||
local pos = { y = args.ey + 1 }
|
||||
local tween = Tween.new(ticks, pos, { y = args.y }, easing)
|
||||
|
||||
return function(device)
|
||||
local finished = tween:update(1)
|
||||
args.canvas:blit(device, nil, { x = args.x, y = math.floor(pos.y) })
|
||||
return not finished
|
||||
end
|
||||
end
|
||||
|
||||
function Transition.grow(args)
|
||||
local ticks = args.ticks or 3
|
||||
local easing = args.easing or 'linear'
|
||||
local tween = Tween.new(ticks,
|
||||
{ x = args.width / 2 - 1, y = args.height / 2 - 1, w = 1, h = 1 },
|
||||
{ x = 1, y = 1, w = args.width, h = args.height }, easing)
|
||||
args.canvas:move(args.x, pos.y)
|
||||
|
||||
return function(device)
|
||||
local finished = tween:update(1)
|
||||
local subj = tween.subject
|
||||
local rect = { x = math.floor(subj.x), y = math.floor(subj.y) }
|
||||
rect.ex = math.floor(rect.x + subj.w - 1)
|
||||
rect.ey = math.floor(rect.y + subj.h - 1)
|
||||
args.canvas:blit(device, rect, { x = args.x + rect.x - 1, y = args.y + rect.y - 1})
|
||||
args.canvas:move(args.x, math.floor(pos.y))
|
||||
args.canvas:dirty()
|
||||
args.canvas:render(device)
|
||||
return not finished
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user