mirror of
https://github.com/Kunsi/scheduled-plugin-pretalx-broadcast-tools.git
synced 2024-11-25 19:41:04 +00:00
room/day: add animation to text
This commit is contained in:
parent
17992f7283
commit
4e15583b4e
1 changed files with 42 additions and 21 deletions
61
tile.lua
61
tile.lua
|
@ -308,37 +308,58 @@ end
|
||||||
local function view_room(starts, ends, config, x1, y1, x2, y2)
|
local function view_room(starts, ends, config, x1, y1, x2, y2)
|
||||||
local font_size = config.font_size or 70
|
local font_size = config.font_size or 70
|
||||||
local align = config.room_align or "left"
|
local align = config.room_align or "left"
|
||||||
local r,g,b = helper.parse_rgb(config.color or "#ffffff")
|
local default_color = {helper.parse_rgb(config.color or "#ffffff")}
|
||||||
|
|
||||||
|
local a = anims.Area(x2 - x1, y2 - y1)
|
||||||
|
|
||||||
|
local S = starts
|
||||||
|
local E = ends
|
||||||
|
|
||||||
|
local function text(...)
|
||||||
|
return a.add(anims.moving_font(S, E, font, ...))
|
||||||
|
end
|
||||||
|
|
||||||
|
local x = 0
|
||||||
|
local w = font:width(current_room, font_size)
|
||||||
|
if align == "right" then
|
||||||
|
x = a.width - w
|
||||||
|
elseif align == "center" then
|
||||||
|
x = (a.width - w) / 2
|
||||||
|
end
|
||||||
|
text(x, 0, current_room, font_size, rgba(default_color,1))
|
||||||
|
|
||||||
for now in api.frame_between(starts, ends) do
|
for now in api.frame_between(starts, ends) do
|
||||||
local x = x1
|
a.draw(now, x1, y1, x2, y2)
|
||||||
local w = font:width(current_room, font_size)
|
|
||||||
if align == "right" then
|
|
||||||
x = x2 - w
|
|
||||||
elseif align == "center" then
|
|
||||||
x = (x1 + x2 - w) / 2
|
|
||||||
end
|
|
||||||
font:write(x, y1, current_room, font_size, r,g,b)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function view_day(starts, ends, config, x1, y1, x2, y2)
|
local function view_day(starts, ends, config, x1, y1, x2, y2)
|
||||||
local font_size = config.font_size or 70
|
local font_size = config.font_size or 70
|
||||||
local r,g,b = helper.parse_rgb(config.color or "#ffffff")
|
|
||||||
local align = config.day_align or "left"
|
local align = config.day_align or "left"
|
||||||
local template = config.day_template or "Day %d"
|
local template = config.day_template or "Day %d"
|
||||||
|
local default_color = {helper.parse_rgb(config.color or "#ffffff")}
|
||||||
|
|
||||||
|
local a = anims.Area(x2 - x1, y2 - y1)
|
||||||
|
|
||||||
|
local S = starts
|
||||||
|
local E = ends
|
||||||
|
|
||||||
|
local function text(...)
|
||||||
|
return a.add(anims.moving_font(S, E, font, ...))
|
||||||
|
end
|
||||||
|
|
||||||
|
local x = 0
|
||||||
|
local line = string.format(template, day)
|
||||||
|
local w = font:width(line, font_size)
|
||||||
|
if align == "right" then
|
||||||
|
x = a.width - w
|
||||||
|
elseif align == "center" then
|
||||||
|
x = (a.width - w) / 2
|
||||||
|
end
|
||||||
|
text(x, 0, line, font_size, rgba(default_color,1))
|
||||||
|
|
||||||
for now in api.frame_between(starts, ends) do
|
for now in api.frame_between(starts, ends) do
|
||||||
local x = x1
|
a.draw(now, x1, y1, x2, y2)
|
||||||
local line = string.format(template, day)
|
|
||||||
local w = font:width(line, font_size)
|
|
||||||
|
|
||||||
if align == "right" then
|
|
||||||
x = x2 - w
|
|
||||||
elseif align == "center" then
|
|
||||||
x = (x1 + x2 - w) / 2
|
|
||||||
end
|
|
||||||
font:write(x, y1, line, font_size, r,g,b)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue