try developing a 4k version

This commit is contained in:
Franzi 2023-06-26 10:16:42 +02:00
parent 920e6cbc75
commit d749cd1abb
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 41 additions and 14 deletions

View file

@ -5,37 +5,64 @@ local json = require "json"
local serial = sys.get_env "SERIAL"
local location = ""
local description = "<please wait>"
local upper_text = ""
local lower_text = ""
local size_multiplier = 1
local card = nil
util.data_mapper{
["device_info"] = function(info)
info = json.decode(info)
location = info.location
description = info.description
if location ~= nil and location ~= '' then
upper_text = description .. " (" .. serial .. ")"
lower_text = location
else
upper_text = description
lower_text = serial
end
end
}
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
card = resource.load_image("testcard.png")
if NATIVE_WIDTH > 2000 then
card = resource.load_image("testcard_3840.png")
size_multiplier = 2
else
card = resource.load_image("testcard_1920.png")
end
font = resource.load_font("vera.ttf")
function node.render()
local render_width = 1920
local render_height = 1080
local upper_text_pos = 631
local lower_text_pos = 679
local upper_text_size = 40
local lower_text_size = 20
gl.clear(0,0,0,1)
card:draw(0, 0, 1920, 1080)
card:draw(0, 0, 1920*size_multiplier, 1080*size_multiplier)
-- upper: 623
-- lower: 707
upper_width = font:width(upper_text, 40*size_multiplier)
lower_width = font:width(lower_text, 20*size_multiplier)
upper_text = description .. " (" .. serial .. ")"
upper_width = font:width(upper_text, 40)
font:write(
(render_width*size_multiplier/2)-(upper_width/2),
upper_text_pos*size_multiplier,
upper_text,
40*size_multiplier,
1,1,1,1)
if location ~= nil and location ~= '' then
font:write(960-(upper_width/2), 631, upper_text, 40, 1,1,1,1)
lower_width = font:width(location, 20)
font:write(960-(lower_width/2), 679, location, 20, 1,1,1,1)
else
font:write(960-(upper_width/2), 645, upper_text, 40, 1,1,1,1)
end
font:write(
(render_width*size_multiplier/2)-(lower_width/2),
lower_text_pos*size_multiplier,
lower_text,
20*size_multiplier,
1,1,1,1)
end

View file

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

BIN
testcard_3840.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB