Skip to content

Commit

Permalink
Fix ReflectMirror
Browse files Browse the repository at this point in the history
  • Loading branch information
somebody1234 committed Nov 11, 2018
1 parent 3a9f8b8 commit 37272da
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions charactertransformers.py
Expand Up @@ -195,7 +195,7 @@
}

NWSEFlip = {
"-": "|", "|": "-", "\\": "/", "/": "\\", "╲": "╱", "╱": "╲",
"-": "|", "|": "-",
"─": "│", "│": "─", "━": "┃", "┃": "━", "╌": "╎", "╎": "╌",
"╍": "╏", "╏": "╍", "┄": "┆", "┆": "┄", "┅": "┇", "┇": "┅",
"┈": "┊", "┊": "┈", "┉": "┋", "┋": "┉", "═": "║", "║": "═",
Expand Down Expand Up @@ -223,7 +223,7 @@
}

NESWFlip = {
"-": "|", "|": "-", "\\": "/", "/": "\\", "╲": "╱", "╱": "╲",
"-": "|", "|": "-",
"─": "│", "│": "─", "━": "┃", "┃": "━", "╌": "╎", "╎": "╌",
"╍": "╏", "╏": "╍", "┄": "┆", "┆": "┄", "┅": "┇", "┇": "┅",
"┈": "┊", "┊": "┈", "┉": "┋", "┋": "┉", "═": "║", "║": "═",
Expand Down
29 changes: 15 additions & 14 deletions charcoal.py
Expand Up @@ -1862,17 +1862,17 @@ def ReflectCopy(self, direction=Direction.right, transform=False):
)
self.x = x = -negative_x
if transform:
for line, length, index in zip(
self.lines[:], self.lengths[:], self.indices[:]
for line, length, right_index in zip(
self.lines[:], self.lengths[:], self.right_indices[:]
):
self.x -= 1
self.y = top_left - index
self.x += 1
self.y = right_index + top_right
self.PrintLine(
{Direction.up},
length,
"".join(
NWSEFlip.get(character, character)
for character in line
for character in line[::-1]
)
)
else:
Expand All @@ -1896,12 +1896,12 @@ def ReflectCopy(self, direction=Direction.right, transform=False):
self.x = x
if transform:
for line, length, index in zip(
self.lines[:], self.lengths[:], self.indices[:]
self.lines[::-1], self.lengths[::-1], self.indices[::-1]
):
self.x -= 1
self.y = top_left - index
self.y = index + bottom_left
self.PrintLine(
{Direction.up},
{Direction.down},
length,
"".join(
NWSEFlip.get(character, character)
Expand All @@ -1928,17 +1928,18 @@ def ReflectCopy(self, direction=Direction.right, transform=False):
)
self.x = x = -negative_x
if transform:
for line, length, index in zip(
self.lines[:], self.lengths[:], self.indices[:]
for line, length, right_index in zip(
self.lines[::-1], self.lengths[::-1],
self.right_indices[::-1]
):
self.x -= 1
self.y = top_left - index
self.x += 1
self.y = bottom_right - right_index
self.PrintLine(
{Direction.up},
{Direction.down},
length,
"".join(
NESWFlip.get(character, character)
for character in line
for character in line[::-1]
)
)
else:
Expand Down
4 changes: 4 additions & 0 deletions test.py
Expand Up @@ -506,6 +506,10 @@ def test_reflect_mirror(self):
self.assertEqual(Run("(({{¶ [[<<‖M→"), "(({{ }}))\n [[<<>>]] ")
self.assertEqual(Run("´⎛´⎞‖M↓"), "⎛⎞\n⎝⎠")
self.assertEqual(Run("---‖M↖"), "| \n| \n| \n ---")
for dir in "↖↗↘↙":
self.assertEqual(
Run("\\/↘²‖M%s" % dir), Run("\\/↘²‖C%s" % dir), dir
)

def test_rotate_copy(self):
self.assertEqual(Run("abc¶de⟲C²"), """\
Expand Down

0 comments on commit 37272da

Please sign in to comment.