Skip to content

Commit 3b98810

Browse files
authored
Fix incorrect lrwh function name in arcade.draw_commands (#2075)
* Add renamed method and mark typo name for removal * Add new method using xywh naming scheme * Mark old one for removal * Add to __all_s * Swap textured rect lrwh to lbwh in examples * Replace arcade. usage in collect coins bg demo * Add import + replace arcade. usage in experimental light_demo * Replace arcade lrwh texture call in gui * Replace usage in tests * Add deprecation to release notes
1 parent 0df89b2 commit 3b98810

File tree

8 files changed

+45
-5
lines changed

8 files changed

+45
-5
lines changed

arcade/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def configure_logging(level: Optional[int] = None):
122122
from .draw_commands import draw_lrbt_rectangle_filled
123123
from .draw_commands import draw_lrtb_rectangle_outline
124124
from .draw_commands import draw_lrbt_rectangle_outline
125+
from .draw_commands import draw_lbwh_rectangle_textured
125126
from .draw_commands import draw_lrwh_rectangle_textured
126127
from .draw_commands import draw_parabola_filled
127128
from .draw_commands import draw_parabola_outline
@@ -294,6 +295,7 @@ def configure_logging(level: Optional[int] = None):
294295
'draw_line',
295296
'draw_line_strip',
296297
'draw_lines',
298+
'draw_lbwh_rectangle_textured',
297299
'draw_lrtb_rectangle_filled',
298300
'draw_lrbt_rectangle_filled',
299301
'draw_lrtb_rectangle_outline',

arcade/draw_commands.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"draw_rectangle_filled",
5757
"draw_scaled_texture_rectangle",
5858
"draw_texture_rectangle",
59+
"draw_lbwh_rectangle_textured",
5960
"draw_lrwh_rectangle_textured",
6061
"get_pixel",
6162
"get_image"
@@ -961,11 +962,39 @@ def draw_texture_rectangle(center_x: float, center_y: float,
961962
texture.draw_sized(center_x, center_y, width, height, angle, alpha)
962963

963964

965+
@warning(
966+
warning_type=ReplacementWarning,
967+
new_name="draw_lbwh_rectangle_textured"
968+
)
964969
def draw_lrwh_rectangle_textured(bottom_left_x: float, bottom_left_y: float,
965970
width: float,
966971
height: float,
967972
texture: Texture, angle: float = 0,
968973
alpha: int = 255):
974+
"""Draw a texture extending from bottom left to top right.
975+
976+
.. deprecated:: 3.0
977+
Use :py:func:`draw_lbwh_rectangle_textured` instead!
978+
979+
:param bottom_left_x: The x coordinate of the left edge of the rectangle.
980+
:param bottom_left_y: The y coordinate of the bottom of the rectangle.
981+
:param width: The width of the rectangle.
982+
:param height: The height of the rectangle.
983+
:param texture: identifier of texture returned from load_texture() call
984+
:param angle: rotation of the rectangle. Defaults to zero (clockwise).
985+
:param alpha: Transparency of image. 0 is fully transparent, 255 (default) is visible
986+
"""
987+
988+
center_x = bottom_left_x + (width / 2)
989+
center_y = bottom_left_y + (height / 2)
990+
texture.draw_sized(center_x, center_y, width, height, angle=angle, alpha=alpha)
991+
992+
993+
def draw_lbwh_rectangle_textured(bottom_left_x: float, bottom_left_y: float,
994+
width: float,
995+
height: float,
996+
texture: Texture, angle: float = 0,
997+
alpha: int = 255):
969998
"""
970999
Draw a texture extending from bottom left to top right.
9711000

arcade/examples/sprite_collect_coins_background.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def on_draw(self):
8989
self.clear()
9090

9191
# Draw the background texture
92-
arcade.draw_lrwh_rectangle_textured(0, 0,
92+
arcade.draw_lbwh_rectangle_textured(0, 0,
9393
SCREEN_WIDTH, SCREEN_HEIGHT,
9494
self.background)
9595

arcade/examples/sprite_rooms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def on_draw(self):
181181
self.clear()
182182

183183
# Draw the background texture
184-
arcade.draw_lrwh_rectangle_textured(0, 0,
184+
arcade.draw_lbwh_rectangle_textured(0, 0,
185185
SCREEN_WIDTH, SCREEN_HEIGHT,
186186
self.rooms[self.current_room].background)
187187

arcade/experimental/light_demo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import math
44
import arcade
5+
from arcade.draw_commands import draw_lbwh_rectangle_textured
56
from arcade.experimental.lights import Light, LightLayer
67

78
# Do the math to figure out our screen dimensions
@@ -57,7 +58,7 @@ def on_draw(self):
5758

5859
# Everything that should be affected by lights in here
5960
with self.light_layer:
60-
arcade.draw_lrwh_rectangle_textured(
61+
draw_lbwh_rectangle_textured(
6162
0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, self.background)
6263
self.torch_list.draw()
6364

arcade/gui/surface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import arcade
77
from arcade import Texture
88
from arcade.color import TRANSPARENT_BLACK
9+
from arcade.draw_commands import draw_lbwh_rectangle_textured
910
from arcade.camera import OrthographicProjector, OrthographicProjectionData, CameraData
1011
from arcade.gl import Framebuffer
1112
from arcade.gui.nine_patch import NinePatchTexture
@@ -119,7 +120,7 @@ def draw_texture(
119120

120121
tex.draw_sized(size=(width, height))
121122
else:
122-
arcade.draw_lrwh_rectangle_textured(
123+
draw_lbwh_rectangle_textured(
123124
bottom_left_x=x,
124125
bottom_left_y=y,
125126
width=width,

doc/programming_guide/release_notes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ Changes
182182
* :py:func:`~arcade.draw_text` and :py:class:`~arcade.Text` both now accept a ``start_z`` parameter. This will allow advanced usage to set the Z
183183
position of the underlying Label. This parameter defaults to 0 and does not change any existing usage.
184184

185+
* :py:mod:`arcade.draw_commands`:
186+
187+
* Added :py:func:`arcade.draw_commands.draw_lbwh_rectangle_textured`
188+
189+
* Replaces the now-deprecated :py:func:`arcade.draw_commands.draw_lrwh_rectangle_textured`
190+
* Usage is exactly the same
191+
185192
* OpenGL
186193

187194
* Support for OpenGL ES 3.1 and 3.2. 3.2 is fully supported, 3.1 is only supported if the ``EXT_geometry_shader`` extension

tests/unit/drawing_support/test_textured_rects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def on_draw():
1717
texture.image.height * scale,
1818
texture, angle=45,
1919
)
20-
arcade.draw_lrwh_rectangle_textured(10, 400, 64, 64, texture)
20+
arcade.draw_lbwh_rectangle_textured(10, 400, 64, 64, texture)
2121

2222
for i in range(15):
2323
arcade.draw_scaled_texture_rectangle(

0 commit comments

Comments
 (0)