try developing a 4k version
This commit is contained in:
parent
920e6cbc75
commit
d749cd1abb
3 changed files with 41 additions and 14 deletions
55
node.lua
55
node.lua
|
@ -5,37 +5,64 @@ local json = require "json"
|
||||||
local serial = sys.get_env "SERIAL"
|
local serial = sys.get_env "SERIAL"
|
||||||
local location = ""
|
local location = ""
|
||||||
local description = "<please wait>"
|
local description = "<please wait>"
|
||||||
|
local upper_text = ""
|
||||||
|
local lower_text = ""
|
||||||
|
local size_multiplier = 1
|
||||||
|
local card = nil
|
||||||
|
|
||||||
util.data_mapper{
|
util.data_mapper{
|
||||||
["device_info"] = function(info)
|
["device_info"] = function(info)
|
||||||
info = json.decode(info)
|
info = json.decode(info)
|
||||||
location = info.location
|
location = info.location
|
||||||
description = info.description
|
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
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
|
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")
|
font = resource.load_font("vera.ttf")
|
||||||
|
|
||||||
function node.render()
|
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)
|
gl.clear(0,0,0,1)
|
||||||
|
|
||||||
card:draw(0, 0, 1920, 1080)
|
card:draw(0, 0, 1920*size_multiplier, 1080*size_multiplier)
|
||||||
|
|
||||||
-- upper: 623
|
upper_width = font:width(upper_text, 40*size_multiplier)
|
||||||
-- lower: 707
|
lower_width = font:width(lower_text, 20*size_multiplier)
|
||||||
|
|
||||||
upper_text = description .. " (" .. serial .. ")"
|
font:write(
|
||||||
upper_width = font:width(upper_text, 40)
|
(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(
|
||||||
font:write(960-(upper_width/2), 631, upper_text, 40, 1,1,1,1)
|
(render_width*size_multiplier/2)-(lower_width/2),
|
||||||
|
lower_text_pos*size_multiplier,
|
||||||
lower_width = font:width(location, 20)
|
lower_text,
|
||||||
font:write(960-(lower_width/2), 679, location, 20, 1,1,1,1)
|
20*size_multiplier,
|
||||||
else
|
1,1,1,1)
|
||||||
font:write(960-(upper_width/2), 645, upper_text, 40, 1,1,1,1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
BIN
testcard_3840.png
Normal file
BIN
testcard_3840.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 170 KiB |
Loading…
Reference in a new issue