Skip to content

Instantly share code, notes, and snippets.

@emisjerry
Created April 20, 2024 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emisjerry/10939510183c145d4729dd1432f62c4d to your computer and use it in GitHub Desktop.
Save emisjerry/10939510183c145d4729dd1432f62c4d to your computer and use it in GitHub Desktop.
A Lua script for testing 'cfonts'
-- test for cfonts
--[[
--font, -f
Use to define the font face
$ cfonts --font block [ console, block, simpleBlock, simple, 3d, simple3d, chrome, huge, shade, slick, grid, pallet, tiny ]
--colors, -c
Use to define the font color
$ cfonts --colors red,blue [ system, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, candy, Any hex color starting with #, e.g.: #ff8800 or #f80 ]
--background, -b
Use to define background color
$ cfonts --background blue [ transparent, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, Any hex color starting with #, e.g.: #ff8800 or #f80 ]
]]--
nyagos.alias.test1=function(args)
local _sTime = os.date("%H:%M:%S")
local _sMsg = "Hi! " .. _sTime
local _aFonts = {"console", "block", "simpleBlock", "simple", "3d", "simple3d",
"chrome", "huge", "shade", "slick", "grid", "pallet", "tiny"}
local _aColors = { "system", "black", "red", "green", "yellow",
"blue", "magenta", "cyan", "white", "gray",
"redBright", "greenBright", "yellowBright", "blueBright", "magentaBright",
"cyanBright", "whiteBright", "candy" }
local _aGradColors = { "black", "red", "green", "yellow",
"blue", "magenta", "cyan", "white", "gray" }
local _sFmt = 'cfonts "%s" --font %s ' ..
' --align right --gradient %s,%s' --transition-gradient
math.randomseed(os.time()) -- 不要放在循環中,以避免生成相同的數字
for i = 1, #_aFonts do
local _sFont = _aFonts[i]
local _iColor = math.random(1, #_aGradColors)
local _sColor1 = _aGradColors[_iColor]
_iColor = math.random(1, #_aGradColors)
local _sColor2 = _aGradColors[_iColor]
--_iColor = math.random(1, #_aGradColors)
--local _sColor3 = _aGradColors[_iColor]
local _sCmd = string.format(_sFmt, _sTime, _sFont,
_sColor1, _sColor2)
print (_sCmd)
nyagos.exec(_sCmd)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment