asc2svg

asc2svg was intended to be an ASCII diagrams to SVG, like `ditaa` and Svgbob
Log | Files | Refs

commit 73c7be92aa96eef70ed13c83d0ed10cdf99e1420
parent 50938d91a2b9d720b7422ede6dbf83d97647a14f
Author: bkopf <vetlehaf@stud.ntnu.no>
Date:   Tue, 20 Nov 2018 20:36:33 +0100

Fixed unprocessed rect right sides

Diffstat:
Ma2svg.py | 15+++++++++++----
Mascii.txt | 31++++++++++++++-----------------
2 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/a2svg.py b/a2svg.py @@ -130,14 +130,15 @@ class Figure: return line_list elif direction == "LEFT": - x_test = x + 1 + x_test = x - 1 while self.__has_char(y, x_test, '-'): self._processed[y][x_test] = True x_test -= 1 if self.__line_end_in(y, x_test): line_list.append(Line((y, x_test), (y, x))) else: - line_list.append(Line((y, x_test+1), (y, x))) + print("NOT LINE END: [{}, {}]".format(y, x_test)) + line_list.append(Line((y, x_test + 1), (y, x))) x = x_test elif direction == "RIGHT": x_test = x + 1 @@ -147,7 +148,8 @@ class Figure: if self.__line_end_in(y, x_test): line_list.append(Line((y, x), (y, x_test))) else: - line_list.append(Line((y, x), (y, x_test + 1))) + print("NOT LINE END: [{}, {}]".format(y, x_test)) + line_list.append(Line((y, x), (y, x_test - 1))) x = x_test elif direction == "UP": y_test = y + 1 @@ -157,6 +159,7 @@ class Figure: if self.__line_end_in(y_test, x): line_list.append(Line((y_test, x), (y, x))) else: + print("NOT LINE END: [{}, {}]".format(y_test, x)) line_list.append(Line((y_test+1, x), (y, x))) y = y_test elif direction == "DOWN": @@ -167,6 +170,7 @@ class Figure: if self.__line_end_in(y_test, x): line_list.append(Line((y, x), (y_test, x))) else: + print("NOT LINE END: [{}, {}]".format(y_test, x)) line_list.append(Line((y, x), (y_test-1, x))) y = y_test else: @@ -227,8 +231,11 @@ class Figure: # Check that there's a line from upper cell to lower for y_test in range(y_start+1, y_stop): cell = self._figarray[y_test][x] - if cell != '|' and cell != '+': + if cell == '+': + self._process_queue.append([y_test, x]) + elif cell != '|': x_stop = None + break if x_stop: break # If x_stop is *not* defined, we probably found an x where both 'y's are connected to lines, diff --git a/ascii.txt b/ascii.txt @@ -2,21 +2,21 @@ +----------------+ - | |<----+ + | +-----+ | | | +----------------+ | - | - | - +---------------------+ - +----->| A BLOCK |<-+ - | +---------------------+ | - | v -+-------+--------+ +----------------------+ -| Block 1 | | Additional block |<---+ + ^ | + | | + | +-----------+---------+ + | +------+ A BLOCK +--+ + | | +---------------------+ | + | | | ++-----+-+--------+ +--------------------+-+ +| Block 1 +-+ Additional block +----+ +-------+--------+ +----------+-----------+ | - | v | - | +----------------------+ | - +--------->| Second block +----+ + | | | + | +----------+-----------+ | + +----------+ Second block +----+ | +----------------------+ | | | | | - List of stuff here | @@ -30,14 +30,11 @@ | +----------------------+ | | - v -+-----------------------+ + | ++-------+---------------+ | SEC 1 | +-----------------------+ | SEC 2 | +-----------------------+ | SEC 3 | +-----------------------+ - - -