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)
fgNext = false
else
if nextChar ~= " " and currFG == nil then
currFG = _G.colors.white
end
--if nextChar ~= " " and currFG == nil then
-- any color not in range is considered transparent
-- currFG = _G.colors.white
--end
image.bg[num][writeIndex] = currBG
image.fg[num][writeIndex] = currFG
image.text[num][writeIndex] = nextChar

View File

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

View File

@ -17,9 +17,12 @@ end
function UI.NftImage:draw()
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 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
else

View File

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