::
Library : nimcx.nim Module : cxfont.nim Status : stable License : MIT opensource Latest : 2021-07-14 Compiler : latest stable or devel branch OS : Linux Description : Experimental font building provides most font printing functions for the library experimental font, slim numbers , swampfont , dotmatrix slimfont and bracketmatrix font Usage : import nimcx/cxfont Test : nim c -d:release -r cxfont Notes : experimental! your results may depend on terminal in use. adjust terminal width and char size for desired effect
Procs
proc bracketMatrixTyper(s: string; xpos: int = 1; color: string = randcol()) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
-
prints the entered string in bracketmatrix font
no checking as to terminalwidth is done so adjust terminal width and char sizes accordingly
will be positioned at top right of last character
proc createCxFont(name: string): seq[seq[string]] {....raises: [], tags: [], forbids: [].}
proc cx10(npos: int = 0; col: string = rndCol(); coltop: string = rndCol()) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect], forbids: [].}
proc dotMatrixFontTest() {....raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
-
dotMatrixFontTest
The current way to use fonts swamp
is to run similar as below .
for dotmatrix use dotMatrixTyper
for bracketmatrix use bracketMatrixTyper
import nimcx showCxFont("dotmatrix") # or "bracketmatrix"
note the numbers next to the required characters
and then
let myfont = createCxFont("dotmatrix") # lets print <NIM>123 printCxFontText(@[12,30,25,29,14,1,2,3],xpos = 2,myfont)
Alternatively compile cxmatrixfontE1.nim which calls this function
proc dotMatrixTyper(s: string; xpos: int = 1; color: string = randcol()) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
-
prints the entered string in dotmatrix font
no checking as to terminalwidth is done so adjust terminal width and char sizes accordingly
will be positioned at top right of last character
# example for dotMatrixTyper and bracketMatrixTyper import nimcx decho(5) dotMatrixTyper("NIMCX - ") decho(8) bracketMatrixTyper("bracketmatrix") decho(12)
proc fprint[T](astring: T; fgr: string = getFg(fgDefault); xpos: int = 0; fitLine: bool = false; centered: bool = false; styled: set[Style] = {}; substr: string = "")
-
:: prev. print2
the old print routine with backgroundcolor set to fgDefault only ,
required by printfont ,fprintln , printBiCol2 and printLnBiCol2
basically similar to terminal.nim styledWriteLine with more functionality
fgr foreground colors can be set
xpos allows positioning on x-axis
fitLine = true will try to write the text into the current line irrespective of xpos
centered = true will try to center and disregard xpos
styled allows style parameters to be set
available styles :
styleBright = 1, # bright text
styleDim, # dim text
styleUnknown, # unknown
styleUnderscore = 4, # underscored text
styleBlink, # blinking/bold text
styleReverse = 7, # reverses currentforground and backgroundcolor
styleHidden # hidden text
styleItalic # italic
styleStrikethrough # strikethrough
for extended colorset background colors use styleReverse
or use 2 or more print statements for the desired effect
Example
# To achieve colored text with styleReverse try: setBackgroundColor(bgRed) print2("The end never comes on time ! ",pastelBlue,styled = {styleReverse})
proc fprintln[T](astring: T; fgr: string = termwhite; xpos: int = 0; fitLine: bool = false; centered: bool = false; styled: set[Style] = {}; substr: string = "")
-
:: fprintln
foregroundcolor best on black backgroundcolor position fitLine centered styled
Examples
fprintln("Yes , we made it.",green) # or use it as a replacement of echo fprintln(red & "What's up ? " & green & "Grub's up ! ") fprintln("No need to reset the original color") fprintln("Nim does it again",peru,centered = true ,styled = {styleDim,styleUnderscore},substr = "i") # To achieve colored text with styleReverse try: loopy2(0,30): fprintln("The end never comes on time ! ",randcol(),styled = {styleReverse}) print cleareol sleepy(0.1)
proc printCxFontLetter(n: int; xpos: int; cxfont: seq[seq[string]]; color: string; vertstepping: int) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
proc printCxFontText(textseq: seq[int]; xpos: int = 2; cxfont: seq[seq[string]]; color: string = randcol(); vertstepping: int = 9; kerning: int = 19) {....raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
-
printCxFontText
printtext in fonts dotmatrix,bracketmatrix,sideways,swamp
swamp needs vertstepping = 7 and kerning >= 15
proc printFont(s: string; col: string = rndCol(); coltop: string = rndCol(); xpos: int = -10) {....raises: [IOError, ValueError], tags: [WriteIOEffect], forbids: [].}
-
printFont
display experimental cxfont
search cxTest for example proc printFontTest
proc printFontFancy(s: string; coltop1 = rndcol(); xpos: int = -10) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect], forbids: [].}
-
printFontFancy
display experimental cxfont with every element in rand color changing of coltop color possible
proc printMadeWithNim(npos: int = terminalWidth() div 2 - 60) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect], forbids: [].}
-
printMadeWithNim
experiments in block font building , default is center in terminal
proc printNim(npos: int = terminalWidth() div 2 - 60) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect], forbids: [].}
proc printNimCx(npos: int = terminalWidth() div 2 - 30) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect], forbids: [].}
-
printNimcx
experiments in block font building , default is center in terminal
proc printSlim(ss: string = ""; frg: string = termwhite; xpos: int = 0; align: string = "left") {....raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
-
printSlim
prints available slim numbers and slim chars
right alignment : the string will be written left of xpos position left alignment : the string will be written right of xpos position
make sure enough space is available left or right of xpos
printSlim($"82233.32",salmon,xpos = 25,align = "right") decho(3) printSlim($"33.87",salmon,xpos = 25,align = "right") ruler(25,lime) decho(3) printSlim($"82233.32",peru,xpos = 25) decho(3) printSlim($"33.87",peru,xpos = 25)
proc printSlimNumber(anumber: string; fgr: string = yellowgreen; bgr: string = getBg(bgDefault); xpos: int = 1) {. ...raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
-
printSlimNumber
will shortly be deprecated use: printSlim
prints an string in big slim font
available chars 123456780,.:
usufull for big counter etc , a clock can also be build easily but running in a tight while loop just uses up cpu cycles needlessly.
for x in 990.. 1005: cleanScreen() printSlimNumber($x) sleep(750) echo() printSlimNumber($23456345,blue) decho(2) printSlimNumber("1234567:345,23.789",fgr=salmon,xpos=20) sleep(1500) import times cleanScreen() decho(2) printSlimNumber($getClockStr(),fgr=salmon,xpos=20) decho(5) for x in rxCol: printSlimNumber($x,colorNames[x][1]) curup(3) sleep(500) curdn(3)
proc showCxFont(name: string) {....raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
proc slimL(astring: string; col: string = truetomato; xpos: int = 5; adjuster: int = 0) {....raises: [IOError, ValueError], tags: [WriteIOEffect, ReadEnvEffect], forbids: [].}
-
slimL
prints slimfont strings
Templates
template cx1(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cx2(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cx3(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cx4(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cx5(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cx6(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cx7(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cx8(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cx9(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxa(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxb(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxc(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxd(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxe(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxf(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxg(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxgrid(npos: int = 0; col: string = rndCol; coltop: string = rndcol)
template cxh(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxhyphen(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxi(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxj(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxk(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxl(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxm(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxn(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxo(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxp(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxpoint(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxq(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxr(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxs(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxt(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxu(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxv(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxw(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxx(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxy(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxz(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())
template cxZero(npos: int = 0; col: string = rndCol(); coltop: string = rndCol())