local Text = require("gfx.text") local TextProgress = Text:new() function TextProgress:getProgress() return math.max(0, math.min(self.progress or 0, 1)) end function TextProgress:setProgress(progress) self.progress = progress end function TextProgress:draw() getmetatable(getmetatable(getmetatable(self))).draw(self) local text = self:getText() if #text == 0 then return end local activePart = math.ceil(#text * self:getProgress()) local fg = { } local bg = { } for i=1,#text do table.insert(fg, colors.toBlit(i > activePart and self:getFgColor() or self:getBgColor())) table.insert(bg, colors.toBlit(i > activePart and self:getBgColor() or self:getFgColor())) end self:_getWindow().blit(text, table.concat(fg), table.concat(bg)) end return TextProgress