From 391ee2161281b1d7cb569a74df08ad4c31aa027d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sat, 7 Sep 2019 17:38:28 +0200 Subject: [PATCH] assets/tools/MiRCART{Reduce,ToAnsi}.py: fixed. libcanvas/CanvasExportStore.py: fixed. assets/text/TODO: updated. --- assets/text/TODO | 19 ++++++++++--------- assets/tools/MiRCARTReduce.py | 11 +++++++---- assets/tools/MiRCARTToAnsi.py | 4 ++-- libcanvas/CanvasExportStore.py | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/assets/text/TODO b/assets/text/TODO index d539a72..efce91d 100644 --- a/assets/text/TODO +++ b/assets/text/TODO @@ -1,14 +1,15 @@ 1) General {cleanup,refactor} 2) Transparent {back,fore}ground colour -3) Implement ANSI CSI CU[BDPU] sequences -4) Incremental auto{load,save} & {backup,restore} -5) Open and toggle a reference image in the background -6) Client-Server or Peer-to-Peer realtime collaboration -7) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.) -8) Hotkey & graphical interfaces to {composed,parametrised} tools -9) GUI: a) scrollbar b) switch from wxPython to GTK c) revisit About dialogue -10) Layers, layout (e.g. for comics, zines, etc.) & asset management (e.g. kade, lion, etc.) & traits w/ {inserting,merging,linking} -11) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...) +3) Implement instrumentation & unit tests +4) Implement ANSI CSI CU[BDPU] sequences +5) Incremental auto{load,save} & {backup,restore} +6) Open and toggle a reference image in the background +7) Client-Server or Peer-to-Peer realtime collaboration +8) Arbitrary {format,palette}s ({4,8} bit ANSI/mIRC, etc.) +9) Hotkey & graphical interfaces to {composed,parametrised} tools +10) GUI: a) scrollbar b) switch from wxPython to GTK c) revisit About dialogue +11) Layers, layout (e.g. for comics, zines, etc.) & asset management (e.g. kade, lion, etc.) & traits w/ {inserting,merging,linking} +12) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...) 13) Composition and parametrisation of tools from higher-order operators (brushes, filters, outlines, patterns & shaders) and unit tools; unit tools: a) geometric primitives (arrow, circle, cloud/speech bubble, curve, heart, hexagon, line, pentagon, polygon, rhombus, triangle, square, star) b) regions (crop, duplicate, erase, fill, invert, measure, pick, rotate, scale, select, shift, slice, tile, translate) diff --git a/assets/tools/MiRCARTReduce.py b/assets/tools/MiRCARTReduce.py index e28aa99..8993bc5 100755 --- a/assets/tools/MiRCARTReduce.py +++ b/assets/tools/MiRCARTReduce.py @@ -9,6 +9,7 @@ import os, sys [sys.path.append(os.path.join(os.getcwd(), "..", "..", path)) for path in ["libcanvas", "librtl"]] from CanvasImportStore import CanvasImportStore +from CanvasExportStore import CanvasExportStore import sys def reduce(inPathName): @@ -25,15 +26,17 @@ def reduce(inPathName): print("\u001f", end="", file=outFile) lastAttribs = inCurCell[2] if lastColours == None \ - or (lastColours[0] != inCurCell[:2][0] \ - and lastColours[1] != inCurCell[:2][1]): + or ((lastColours[0] != inCurCell[:2][0]) \ + and (lastColours[1] != inCurCell[:2][1])) \ + or ((lastColours[0] == inCurCell[:2][0]) \ + and (lastColours[1] != inCurCell[:2][1])): if (inCurCell[3] in set("0123456789")) and (inCurCell[1] < 10): print("\u0003{:d},{:02d}{}".format(*inCurCell[:2], inCurCell[3]), end="", file=outFile) else: print("\u0003{:d},{:d}{}".format(*inCurCell[:2], inCurCell[3]), end="", file=outFile) lastColours = inCurCell[:2] - elif (lastColours[1] == inCurCell[:2][1]) \ - and (lastColours[0] != inCurCell[:2][0]): + elif (lastColours[0] != inCurCell[:2][0]) \ + and (lastColours[1] == inCurCell[:2][1]): if (inCurCell[3] in set("0123456789")) and (inCurCell[0] < 10): print("\u0003{:02d}{}".format(inCurCell[0], inCurCell[3]), end="", file=outFile) else: diff --git a/assets/tools/MiRCARTToAnsi.py b/assets/tools/MiRCARTToAnsi.py index 055ce39..fdf1c88 100755 --- a/assets/tools/MiRCARTToAnsi.py +++ b/assets/tools/MiRCARTToAnsi.py @@ -18,11 +18,11 @@ def main(*argv): print("usage: {} ".format(sys.argv[0]), file=sys.stderr) else: canvasImportStore = CanvasImportStore() - rc, error = canvasImportStore.importAnsiFile(argv[1]) + rc, error = canvasImportStore.importTextFile(argv[1]) if rc: canvasExportStore = CanvasExportStore() canvasExportStore.exportAnsiFile(canvasImportStore.outMap, canvasImportStore.inSize, sys.stdout) - else + else: print("error: {}".format(error), file=sys.stderr) if __name__ == "__main__": main(*sys.argv) diff --git a/libcanvas/CanvasExportStore.py b/libcanvas/CanvasExportStore.py index 510acd4..fbfd4a3 100644 --- a/libcanvas/CanvasExportStore.py +++ b/libcanvas/CanvasExportStore.py @@ -125,7 +125,7 @@ class CanvasExportStore(): outImgDraw = ImageDraw.Draw(outImg); outImgDraw.fontmode = "1"; for inCurRow in range(len(canvasMap)): for inCurCol in range(len(canvasMap[inCurRow])): - inCurCell = canvasMap[inCurRow][inCurCol]; outColours = (0, 0); + inCurCell = canvasMap[inCurRow][inCurCol]; outColours = [0, 0]; if inCurCell[2] & self._CellState.CS_BOLD: if inCurCell[3] != " ": if inCurCell[3] == "█":