Skip to content

TextGauge: Examples

Damian Monogue edited this page Feb 18, 2021 · 4 revisions

Show me how it works already

You can create a new text gauge using

local TextGauge = require("MDK.textgauge")
tg = TextGauge:new()

That's the bare minimum, and will default to 24 chars wide, uses ':' for the fill character and '-' for the empty character. You can see it what it looks like with cecho(tg:setValue(50) .. "\n")

You can make it wider, using tg:setWidth(40), then the cecho again

If you run cecho(tg:setValue(100) .. "\n") it reduces the size of the gauge itself to fit the extra number

You can visually show values greater than 100% by setting the overflowColor. First without the color set. using tg:setValue(123) for the next several examples

And then we tg:setOverflowColor("light_blue")

You can use a different character for overflow as well. tg:setOverflowCharacter("#")

Let's be a bit playful.

tg:setFillCharacter("$")
tg:setFillColor("dark_green")
cecho(tg:setValue(60).."\n")

Continuing, how about

tg:setEmptyCharacter("=")
tg:setEmptyColor("yellow")
cecho(tg:setValue(60).."\n")

And now maybe

tg:setPercentColor("cornflower_blue")
tg:setPercentSymbolColor("purple")
cecho(tg:setValue(23).."\n")

You can turn off the numeric and % sign:

tg:disableShowPercent()
tg:disableShowPercentSymbol()
cecho(tg:setValue(12).."\n")

Or you can do it all in the beginning:

tg2 = TextGauge:new({
  width = 40,
  fillCharacter = "$",
  fillColor = "dark_green",
  emptyCharacter = "=",
  overflowCharacter = "#",
  emptyColor = "yellow",
  percentColor = "cornflower_blue",
  percentSymbolColor = "purple",
  overflowColor = "light_blue",
})
cecho(tg2:setValue(139).."\n")