1
0
mirror of https://github.com/kepler155c/opus synced 2025-01-05 21:30:28 +00:00

ntf transparency

This commit is contained in:
kepler155c@gmail.com 2019-07-10 19:02:46 -06:00
parent 8f17657263
commit 0e1b712adc
4 changed files with 15 additions and 9 deletions

View File

@ -50,9 +50,10 @@ function NFT.parse(imageText)
currFG = getColourOf(nextChar) currFG = getColourOf(nextChar)
fgNext = false fgNext = false
else else
if nextChar ~= " " and currFG == nil then --if nextChar ~= " " and currFG == nil then
currFG = _G.colors.white -- any color not in range is considered transparent
end -- currFG = _G.colors.white
--end
image.bg[num][writeIndex] = currBG image.bg[num][writeIndex] = currBG
image.fg[num][writeIndex] = currFG image.fg[num][writeIndex] = currFG
image.text[num][writeIndex] = nextChar image.text[num][writeIndex] = nextChar

View File

@ -912,10 +912,12 @@ function UI.Window:emit(event)
end end
end end
function UI.Window:find(uid) function UI.Window:getProperty(property)
if self.children then return self[property] or self.parent and self.parent:getProperty(property)
return Util.find(self.children, 'uid', uid)
end end
function UI.Window:find(uid)
return self.children and Util.find(self.children, 'uid', uid)
end end
function UI.Window:eventHandler() function UI.Window:eventHandler()

View File

@ -17,9 +17,12 @@ end
function UI.NftImage:draw() function UI.NftImage:draw()
if self.image then if self.image then
-- due to blittle, the background and foreground transparent
-- color is the same as the background color
local bg = self:getProperty('backgroundColor')
for y = 1, self.image.height do for y = 1, self.image.height do
for x = 1, #self.image.text[y] do for x = 1, #self.image.text[y] do
self:write(x, y, self.image.text[y][x], self.image.bg[y][x], self.image.fg[y][x]) self:write(x, y, self.image.text[y][x], self.image.bg[y][x], self.image.fg[y][x] or bg)
end end
end end
else else

View File

@ -412,8 +412,8 @@ function Util.first(t, order)
end end
--[[ File functions ]]-- --[[ File functions ]]--
function Util.readFile(fname) function Util.readFile(fname, flags)
local f = fs.open(fname, "r") local f = fs.open(fname, flags or "r")
if f then if f then
local t = f.readAll() local t = f.readAll()
f.close() f.close()