Skip to content

Commit fd466bd

Browse files
committed
Switch to using negative positions as absolute coordinates.
1 parent c7f70d2 commit fd466bd

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ v2.0.0
88

99
Unreleased
1010
------------------
11+
Changed
12+
- Console print and drawing functions now always use absolute coordinates for negative numbers.
1113

1214
12.7.3 - 2021-08-13
1315
-------------------

tcod/console.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -926,20 +926,6 @@ def __str__(self) -> str:
926926
"""Return a simplified representation of this consoles contents."""
927927
return "<%s>" % "\n ".join("".join(chr(c) for c in line) for line in self._tiles["ch"])
928928

929-
def _pythonic_index(self, x: int, y: int) -> Tuple[int, int]:
930-
if __debug__ and (x < 0 or y < 0):
931-
warnings.warn(
932-
"Negative indexes will be treated as absolute coordinates instead of relative in the future."
933-
" The current behavior of indexing from the end is deprecated.",
934-
FutureWarning,
935-
stacklevel=3,
936-
)
937-
if x < 0:
938-
x += self.width
939-
if y < 0:
940-
y += self.height
941-
return x, y
942-
943929
def print(
944930
self,
945931
x: int,
@@ -972,8 +958,10 @@ def print(
972958
973959
.. versionchanged:: 9.0
974960
`fg` and `bg` now default to `None` instead of white-on-black.
961+
962+
.. versionchanged:: 13.0
963+
`x` and `y` are now always used as an absolute position for negative values.
975964
"""
976-
x, y = self._pythonic_index(x, y)
977965
string_ = string.encode("utf-8") # type: bytes
978966
lib.TCOD_console_printn(
979967
self.console_c,
@@ -1025,8 +1013,10 @@ def print_box(
10251013
10261014
.. versionchanged:: 9.0
10271015
`fg` and `bg` now default to `None` instead of white-on-black.
1016+
1017+
.. versionchanged:: 13.0
1018+
`x` and `y` are now always used as an absolute position for negative values.
10281019
"""
1029-
x, y = self._pythonic_index(x, y)
10301020
string_ = string.encode("utf-8") # type: bytes
10311021
return int(
10321022
lib.TCOD_console_printn_rect(
@@ -1095,6 +1085,9 @@ def draw_frame(
10951085
.. versionchanged:: 12.6
10961086
Added `decoration` parameter.
10971087
1088+
.. versionchanged:: 13.0
1089+
`x` and `y` are now always used as an absolute position for negative values.
1090+
10981091
Example::
10991092
11001093
>>> console = tcod.Console(12, 6)
@@ -1115,7 +1108,6 @@ def draw_frame(
11151108
│ │
11161109
└─┤Lower├──┘>
11171110
"""
1118-
x, y = self._pythonic_index(x, y)
11191111
if title and decoration != "┌─┐│ │└─┘":
11201112
raise TypeError(
11211113
"The title and decoration parameters are mutually exclusive. You should print the title manually."
@@ -1195,8 +1187,10 @@ def draw_rect(
11951187
11961188
.. versionchanged:: 9.0
11971189
`fg` and `bg` now default to `None` instead of white-on-black.
1190+
1191+
.. versionchanged:: 13.0
1192+
`x` and `y` are now always used as an absolute position for negative values.
11981193
"""
1199-
x, y = self._pythonic_index(x, y)
12001194
lib.TCOD_console_draw_rect_rgb(
12011195
self.console_c,
12021196
x,

0 commit comments

Comments
 (0)