source code of /small-scripts/stackexchange/nuospin

Last modified
Lines 76

Parent directory Download CGIread sitemap Main page

Quick links: printline

  1. #!/usr/bin/python
  2. import sys
  3. # Each item in `font` is a list of `font_height` strings.
  4. # The glyphs are not limited to asterisks and spaces.
  5. font_height = 7
  6. margin_left = 1
  7. margin_right = 1
  8. font = {
  9.     'N': [
  10.         "*   *",
  11.         "*   *",
  12.         "**  *",
  13.         "* * *",
  14.         "*  **",
  15.         "*   *",
  16.         "*   *",
  17.     ],
  18.     'U': [
  19.         "*   *",
  20.         "*   *",
  21.         "*   *",
  22.         "*   *",
  23.         "*   *",
  24.         "*   *",
  25.         " *** ",
  26.     ],
  27.     'O': [
  28.         " *** ",
  29.         "*   *",
  30.         "*   *",
  31.         "*   *",
  32.         "*   *",
  33.         "*   *",
  34.         " *** ",
  35.     ],
  36.     'S': [
  37.         " *** ",
  38.         "*   *",
  39.         "*    ",
  40.         " *** ",
  41.         "    *",
  42.         "*   *",
  43.         " *** ",
  44.     ],
  45.     'P': [
  46.         "**** ",
  47.         "*   *",
  48.         "*   *",
  49.         "**** ",
  50.         "*    ",
  51.         "*    ",
  52.         "*    ",
  53.     ],
  54.     'I': [
  55.         "  *  ",
  56.         "  *  ",
  57.         "  *  ",
  58.         "  *  ",
  59.         "  *  ",
  60.         "  *  ",
  61.         "  *  ",
  62.     ],
  63. }
  64. def printline(text):
  65.     for row in range(font_height):
  66.         for ch in text:
  67.             sys.stdout.write(' ' * margin_left)
  68.             sys.stdout.write(font[ch][row])
  69.             sys.stdout.write(' ' * margin_right)
  70.         sys.stdout.write('\n')
  71. printline('NUOSPIN')