Utils

Tessif (random) utility collection.

tessif.frused.utils.greyscale2hex(greyscale, minn=0.0, maxn=1.0)[source]

Correlate a number within a certain range to a hex encoded gray value.

Parameters
  • greyscale (Number) – Number between minn and maxn representing the greyscale. Where minn = 'white' and maxn = 'black'.

  • minn (Number, default=0.0) – Lower boundary resulting in a white color hex value

  • maxn (Number, default=1.0) – Upper boundary resulting in a black color hex value

Returns

single hex color value representing the correlated grayscale color.

Return type

hex

Examples

>>> greyscale2hex(.3)
'#b2b2b2'
>>> greyscale2hex(.7)
'#4c4c4c'
>>> greyscale2hex(50, 0, 100)
'#7f7f7f'
>>> greyscale2hex(1e10, 0, 1e20)
'#fefefe'
>>> greyscale2hex(0)
'#ffffff'
>>> greyscale2hex(1)
'#000000'
>>> greyscale2hex(0.0)
'#ffffff'
>>> greyscale2hex(1.0)
'#000000'
class tessif.frused.utils.HideStdoutPrinting[source]

Bases: object

ContextManager for temporarily disabeling printing to stdout.

Originally written by Alexander Chzhen.

Examples

>>> import tessif.write.tools as write_tools
>>> with HideStdoutPrinting():
...     print("This will not be printed")
>>> print("This will be printed as before")
This will be printed as before