Isoraqathedh

EQ2.py

Oct 8th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.25 KB | None | 0 0
  1. import svgwrite
  2. import time
  3. """ ╔═══════╗                                                                             ╔═══════╗
  4.     ║   Q   ║                                                                             ║   R   ║
  5.     ╚═══════╝    ←   18 px   →                                                            ╚═══════╝
  6.              ╔═══════╗   ╔═══════╗   ╔═══════╗ ╔═══════╗ ╔═══════╗   ╔═══════╗   ╔═══════╗
  7.              ║  0,0  ╟───╢  0,3  ╟───╢  0,6  ╟-╢  0,7  ╟-╢  0,8  ╟───╢  0,11 ╟───╢  0,14 ║
  8.              ╚═══╤═══╝   ╚═══╤═══╝   ╚═══╤═══╝ ╚═══╤═══╝ ╚═══╤═══╝   ╚═══╤═══╝   ╚═══╤═══╝
  9.                  │           │           │         |         │           │           │
  10.              ╔═══╧═══╗   ╔═══╧═══╗   ╔═══╧═══╗     |     ╔═══╧═══╗   ╔═══╧═══╗   ╔═══╧═══╗  
  11.              ║  3,0  ╟───╢  3,3  ╟───╢  3,6  ║     |     ║  3,8  ╟───╢  3,11 ╟───╢  3,14 ║
  12.              ╚═══╤═══╝   ╚═══╤═══╝   ╚═══╤═══╝     |     ╚═══╤═══╝   ╚═══╤═══╝   ╚═══╤═══╝
  13.                  │           │           │         |         │           │           │
  14.              ╔═══╧═══╗   ╔═══╧═══╗   ╔═══╧═══╗     |     ╔═══╧═══╗   ╔═══╧═══╗   ╔═══╧═══╗  
  15.              ║  6,0  ╟───╢  6,3  ╟───╢  6,6  ║     |     ║  6,8  ╟───╢  6,11 ╟───╢  6,14 ║
  16.              ╚═══╤═══╝   ╚═══════╝   ╚═══════╝     |     ╚═══════╝   ╚═══════╝   ╚═══╤═══╝
  17.              ╔═══╧═══╗                         ╔═══╧═══╗                         ╔═══╧═══╗
  18.              ║  7,0  ╟-------------------------╢  7,7  ╟-------------------------╢  7,14 ║
  19.              ╚═══╤═══╝                         ╚═══╤═══╝                         ╚═══╤═══╝
  20.              ╔═══╧═══╗   ╔═══════╗   ╔═══════╗     |     ╔═══════╗   ╔═══════╗   ╔═══╧═══╗
  21.              ║  8,0  ╟───╢  8,3  ╟───╢  8,6  ║     |     ║  8,8  ╟───╢  8,11 ╟───╢  8,14 ║
  22.              ╚═══╤═══╝   ╚═══╤═══╝   ╚═══╤═══╝     |     ╚═══╤═══╝   ╚═══╤═══╝   ╚═══╤═══╝
  23.                  │           │           │         |         │           │           │
  24.              ╔═══╧═══╗   ╔═══╧═══╗   ╔═══╧═══╗     |     ╔═══╧═══╗   ╔═══╧═══╗   ╔═══╧═══╗  
  25.              ║ 11,0  ╟───╢ 11,3  ╟───╢ 11,6  ║     |     ║ 11,8  ╟───╢ 11,11 ╟───╢ 11,14 ║
  26.              ╚═══╤═══╝   ╚═══╤═══╝   ╚═══╤═══╝     |     ╚═══╤═══╝   ╚═══╤═══╝   ╚═══╤═══╝
  27.                  │           │           │         |         │           │           │
  28.              ╔═══╧═══╗   ╔═══╧═══╗   ╔═══╧═══╗ ╔═══╧═══╗ ╔═══╧═══╗   ╔═══╧═══╗   ╔═══╧═══╗  
  29.              ║ 14,0  ╟───╢ 14,3  ╟───╢ 14,6  ╟-╢ 14,7  ╟-╢ 14,8  ╟───╢ 14,11 ╟───╢ 14,14 ║
  30.              ╚═══════╝   ╚═══════╝   ╚═══════╝ ╚═══════╝ ╚═══════╝   ╚═══════╝   ╚═══════╝
  31.     ╔═══════╗                                                                             ╔═══════╗
  32.     ║   S   ║                                                                             ║   T   ║
  33.     ╚═══════╝                                                                             ╚═══════╝
  34.     """
  35. vertices = {
  36.     'upper': {
  37.         'a': (0, 0), 'b': (0, 3), 'h': (0, 6),
  38.         'c': (3, 0), 'o': (3, 3), 'g': (3, 6),
  39.         'd': (6, 0), 'e': (6, 3), 'f': (6, 6)},
  40.     'middle': {
  41.         'a': (0,  0), 'b': ( 0, 7), 'h': (0, 14),
  42.         'c': (7,  0), 'o': ( 7, 7), 'g': (7, 14),
  43.         'd': (14, 0), 'e': (14, 7), 'f': (6, 14)},
  44.     'lower': {
  45.         'a': ( 8, 0), 'b': ( 8, 3), 'h': ( 8, 6),
  46.         'c': (11, 0), 'o': (11, 3), 'g': (11, 6),
  47.         'd': (14, 0), 'e': (14, 3), 'f': (14, 6)}}
  48. lineAssocs = {
  49.     'A': ('a','b'), 'B': ('b','h'), 'C': ('a','c'), 'D': ('c','d'),
  50.     'E': ('d','e'), 'F': ('e','f'), 'G': ('f','g'), 'H': ('g','h'),
  51.     'I': ('b','o'), 'J': ('c','o'), 'K': ('o','g'), 'L': ('o','e'),
  52.     'M': ('a','o'), 'N': ('h','o'), 'O': ('o','d'), 'P': ('o','f')}
  53. def draw(lineName, letterSize):
  54.     for i in lineAssocs[lineName]:
  55.         pass
  56. def writeOneWord(upper, lower):
  57.     """
  58.         This function writes a single word, such as "utæk". Single words do not have pipes in them.
  59.     """
  60.     if upper != None and lower != None:
  61.         # In this case we have to align the two words together, as such:
  62.        
  63.         # L L L L L L   M M M M     N N N
  64.         #   L L L L       M M M   N N N N N N
  65.        
  66.         explodedUpper = letterize(upper)
  67.         explodedLower = letterize(lower)
  68.         while len(explodedUpper) > len(explodedLower):
  69.             # pad the lower list until it is the same length OR ONE SHORTER than the upper one
  70.             # left first, then right
  71.             explodedLower.insert(0, None)
  72.             if len(explodedUpper) > len(explodedLower):
  73.                 explodedLower.append(None)
  74.         while len(explodedUpper) < len(explodedLower):
  75.             # pad the upper list until it is the same length OR ONE SHORTER than the lower one
  76.             # right first, then
  77.             explodedUpper.append(None)
  78.             if len(explodedUpper) < len(explodedLower):
  79.                 explodedUpper.insert(0, None)
  80.         for i in range(max(len(explodedUpper), len(explodedLower))):
  81.             writeOneLetter(explodedUpper[i], explodedLower[i])
  82.     elif upper == None:
  83.         for i in letterize(lower):
  84.             writeOneLetter(i)
  85.     else:
  86.         for i in letterize(upper):
  87.             writeOneLetter(i)  
  88. def letterize(word):
  89.     pass
  90. def writeOneWordSet(word):
  91.     """
  92.         This function writes out exactly one word set. A word set is a string like "utæk|Qvaḻsa".
  93.         A word set must have """
  94.     if "|" in word:
  95.         wordPairs = word.split("|")
  96.         for i in wordPairs[:-2]:
  97.             writeOneWord(i, None)
  98.         writeOneWord(i[-2], i[-1])
Advertisement
Add Comment
Please, Sign In to add comment