diff --git a/arcade/__init__.py b/arcade/__init__.py index f13a1ff3d..1d21e29cb 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -19,7 +19,7 @@ def configure_logging(level: Optional[int] = None): """Set up basic logging. - :param int level: The log level. Defaults to DEBUG. + :param level: The log level. Defaults to DEBUG. """ import logging level = level or logging.DEBUG diff --git a/arcade/application.py b/arcade/application.py index 46f97f3e8..08e72b402 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -7,7 +7,7 @@ import logging import os import time -from typing import Tuple, Optional +from typing import List, Tuple, Optional import pyglet @@ -45,14 +45,13 @@ ] -def get_screens(): +def get_screens() -> List: """ Return a list of screens. So for a two-monitor setup, this should return a list of two screens. Can be used with arcade.Window to select which window we full-screen on. :returns: List of screens, one for each monitor. - :rtype: List """ display = pyglet.canvas.get_display() return display.get_screens() @@ -70,24 +69,24 @@ class Window(pyglet.window.Window): The Window class forms the basis of most advanced games that use Arcade. It represents a window on the screen, and manages events. - :param int width: Window width - :param int height: Window height - :param str title: Title (appears in title bar) - :param bool fullscreen: Should this be full screen? - :param bool resizable: Can the user resize the window? - :param float update_rate: How frequently to run the on_update event. - :param float draw_rate: How frequently to run the on_draw event. (this is the FPS limit) - :param bool antialiasing: Should OpenGL's anti-aliasing be enabled? - :param Tuple[int,int] gl_version: What OpenGL version to request. This is ``(3, 3)`` by default \ + :param width: Window width + :param height: Window height + :param title: Title (appears in title bar) + :param fullscreen: Should this be full screen? + :param resizable: Can the user resize the window? + :param update_rate: How frequently to run the on_update event. + :param draw_rate: How frequently to run the on_draw event. (this is the FPS limit) + :param antialiasing: Should OpenGL's anti-aliasing be enabled? + :param gl_version: What OpenGL version to request. This is ``(3, 3)`` by default \ and can be overridden when using more advanced OpenGL features. - :param bool visible: Should the window be visible immediately - :param bool vsync: Wait for vertical screen refresh before swapping buffer \ + :param visible: Should the window be visible immediately + :param vsync: Wait for vertical screen refresh before swapping buffer \ This can make animations and movement look smoother. - :param bool gc_mode: Decides how OpenGL objects should be garbage collected ("context_gc" (default) or "auto") - :param bool center_window: If true, will center the window. - :param bool samples: Number of samples used in antialiasing (default 4). \ + :param gc_mode: Decides how OpenGL objects should be garbage collected ("context_gc" (default) or "auto") + :param center_window: If true, will center the window. + :param samples: Number of samples used in antialiasing (default 4). \ Usually this is 2, 4, 8 or 16. - :param bool enable_polling: Enabled input polling capability. This makes the ``keyboard`` and ``mouse`` \ + :param enable_polling: Enabled input polling capability. This makes the ``keyboard`` and ``mouse`` \ attributes available for use. """ @@ -239,7 +238,6 @@ def current_view(self) -> Optional["View"]: To set a different view, call the :py:meth:`arcade.Window.show_view` method. - :rtype: arcade.View """ return self._current_view @@ -268,7 +266,7 @@ def clear( 2. A 4-length RGBA :py:class:`tuple` of byte values (0 to 255) 3. A 4-length RGBA :py:class:`tuple` of normalized floats (0.0 to 1.0) - :param bool normalized: If the color format is normalized (0.0 -> 1.0) or byte values + :param normalized: If the color format is normalized (0.0 -> 1.0) or byte values :param Tuple[int, int, int, int] viewport: The viewport range to clear """ color = color if color is not None else self.background_color @@ -331,15 +329,15 @@ def set_fullscreen(self, """ Set if we are full screen or not. - :param bool fullscreen: + :param fullscreen: :param screen: Which screen should we display on? See :func:`get_screens` - :param pyglet.canvas.ScreenMode mode: + :param mode: The screen will be switched to the given mode. The mode must have been obtained by enumerating `Screen.get_modes`. If None, an appropriate mode will be selected from the given `width` and `height`. - :param int width: - :param int height: + :param width: + :param height: """ super().set_fullscreen(fullscreen, screen, mode, width, height) @@ -358,7 +356,7 @@ def on_update(self, delta_time: float): """ Move everything. Perform collision checks. Do all the game logic here. - :param float delta_time: Time interval since the last time the function was called. + :param delta_time: Time interval since the last time the function was called. """ pass @@ -375,7 +373,7 @@ def set_update_rate(self, rate: float): Set how often the on_update function should be dispatched. For example, self.set_update_rate(1 / 60) will set the update rate to 60 times per second. - :param float rate: Update frequency in seconds + :param rate: Update frequency in seconds """ self._update_rate = rate pyglet.clock.unschedule(self._dispatch_updates) @@ -396,10 +394,10 @@ def on_mouse_motion(self, x: int, y: int, dx: int, dy: int): Override this function to respond to changes in mouse position. - :param int x: x position of mouse within the window in pixels - :param int y: y position of mouse within the window in pixels - :param int dx: Change in x since the last time this method was called - :param int dy: Change in y since the last time this method was called + :param x: x position of mouse within the window in pixels + :param y: y position of mouse within the window in pixels + :param dx: Change in x since the last time this method was called + :param dy: Change in y since the last time this method was called """ pass @@ -413,16 +411,16 @@ def on_mouse_press(self, x: int, y: int, button: int, modifiers: int): .. seealso:: :meth:`~.Window.on_mouse_release` - :param int x: x position of the mouse - :param int y: y position of the mouse - :param int button: What button was pressed. This will always be + :param x: x position of the mouse + :param y: y position of the mouse + :param button: What button was pressed. This will always be one of the following: * ``arcade.MOUSE_BUTTON_LEFT`` * ``arcade.MOUSE_BUTTON_RIGHT`` * ``arcade.MOUSE_BUTTON_MIDDLE`` - :param int modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) + :param modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ pass @@ -433,12 +431,12 @@ def on_mouse_drag(self, x: int, y: int, dx: int, dy: int, buttons: int, modifier Override this function to handle dragging. - :param int x: x position of mouse - :param int y: y position of mouse - :param int dx: Change in x since the last time this method was called - :param int dy: Change in y since the last time this method was called - :param int buttons: Which button is pressed - :param int modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) + :param x: x position of mouse + :param y: y position of mouse + :param dx: Change in x since the last time this method was called + :param dy: Change in y since the last time this method was called + :param buttons: Which button is pressed + :param modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ self.on_mouse_motion(x, y, dx, dy) @@ -451,12 +449,12 @@ def on_mouse_release(self, x: int, y: int, button: int, modifiers: int): may be useful when you want to use the duration of a mouse click to affect gameplay. - :param int x: x position of mouse - :param int y: y position of mouse - :param int button: What button was hit. One of: + :param x: x position of mouse + :param y: y position of mouse + :param button: What button was hit. One of: arcade.MOUSE_BUTTON_LEFT, arcade.MOUSE_BUTTON_RIGHT, arcade.MOUSE_BUTTON_MIDDLE - :param int modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) + :param modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ pass @@ -483,11 +481,11 @@ def on_mouse_scroll(self, x: int, y: int, scroll_x: int, scroll_y: int): to maximize the number of people who can play your game! - :param int x: x position of mouse - :param int y: y position of mouse - :param int scroll_x: number of steps scrolled horizontally + :param x: x position of mouse + :param y: y position of mouse + :param scroll_x: number of steps scrolled horizontally since the last call of this function - :param int scroll_y: number of steps scrolled vertically since + :param scroll_y: number of steps scrolled vertically since the last call of this function """ pass @@ -520,7 +518,7 @@ def set_mouse_visible(self, visible: bool = True): `_ for more information. - :param bool visible: Whether to hide the system mouse cursor + :param visible: Whether to hide the system mouse cursor """ super().set_mouse_visible(visible) @@ -534,8 +532,8 @@ def on_key_press(self, symbol: int, modifiers: int): gameplay, you also need to override :meth:`~.Window.on_key_release`. - :param int symbol: Key that was just pushed down - :param int modifiers: Bitwise 'and' of all modifiers (shift, + :param symbol: Key that was just pushed down + :param modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ @@ -558,8 +556,8 @@ def on_key_release(self, symbol: int, modifiers: int): how long a key was pressed * Showing which keys are currently pressed down - :param int symbol: Key that was just released - :param int modifiers: Bitwise 'and' of all modifiers (shift, + :param symbol: Key that was just released + :param modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ @@ -587,8 +585,8 @@ def on_resize(self, width: int, height: int): super().on_resize(width, height) # Add extra resize logic here - :param int width: New width - :param int height: New height + :param width: New width + :param height: New height """ # NOTE: When a second window is opened pyglet will # dispatch on_resize during the window constructor. @@ -606,8 +604,8 @@ def on_resize(self, width: int, height: int): def set_min_size(self, width: int, height: int): """ Wrap the Pyglet window call to set minimum size - :param float width: width in pixels. - :param float height: height in pixels. + :param width: width in pixels. + :param height: height in pixels. """ if self._resizable: @@ -618,8 +616,8 @@ def set_min_size(self, width: int, height: int): def set_max_size(self, width: int, height: int): """ Wrap the Pyglet window call to set maximum size - :param int width: width in pixels. - :param int height: height in pixels. + :param width: width in pixels. + :param height: height in pixels. :Raises ValueError: """ @@ -633,8 +631,8 @@ def set_size(self, width: int, height: int): """ Ignore the resizable flag and set the size - :param int width: - :param int height: + :param width: + :param height: """ super().set_size(width, height) @@ -661,7 +659,7 @@ def set_visible(self, visible: bool = True): """ Set if the window is visible or not. Normally, a program's window is visible. - :param bool visible: + :param visible: """ super().set_visible(visible) @@ -673,10 +671,10 @@ def set_viewport(self, left: float, right: float, bottom: float, top: float): See :py:func:`arcade.set_viewport` for more detailed information. - :param Number left: - :param Number right: - :param Number bottom: - :param Number top: + :param left: + :param right: + :param bottom: + :param top: """ set_viewport(left, right, bottom, top) @@ -693,7 +691,7 @@ def test(self, frames: int = 10): """ Used by unit test cases. Runs the event loop a few times and stops. - :param int frames: + :param frames: """ start_time = time.time() for _ in range(frames): @@ -720,7 +718,7 @@ def show_view(self, new_view: 'View'): Calling this function is the same as setting the :py:attr:`arcade.Window.current_view` attribute. - :param View new_view: View to show + :param new_view: View to show """ if not isinstance(new_view, View): raise TypeError( @@ -897,8 +895,8 @@ def on_mouse_enter(self, x: int, y: int): This event will not be triggered if the mouse is currently being dragged. - :param int x: - :param int y: + :param x: + :param y: """ pass @@ -910,8 +908,8 @@ def on_mouse_leave(self, x: int, y: int): dragged. Note that the coordinates of the mouse pointer will be outside of the window rectangle. - :param int x: - :param int y: + :param x: + :param y: """ pass @@ -929,14 +927,13 @@ def open_window( the window handle is stored in a global, but it makes things easier for programmers if they don't have to track a window pointer. - :param Number width: Width of the window. - :param Number height: Height of the window. - :param str window_title: Title of the window. - :param bool resizable: Whether the user can resize the window. - :param bool antialiasing: Smooth the graphics? + :param width: Width of the window. + :param height: Height of the window. + :param window_title: Title of the window. + :param resizable: Whether the user can resize the window. + :param antialiasing: Smooth the graphics? :returns: Handle to window - :rtype: Window """ global _window @@ -998,7 +995,7 @@ def clear( 2. A 4-length RGBA :py:class:`tuple` of byte values (0 to 255) 3. A 4-length RGBA :py:class:`tuple` of normalized floats (0.0 to 1.0) - :param bool normalized: If the color format is normalized (0.0 -> 1.0) or byte values + :param normalized: If the color format is normalized (0.0 -> 1.0) or byte values :param Tuple[int, int, int, int] viewport: The viewport range to clear """ self.window.clear(color, normalized, viewport) @@ -1031,10 +1028,10 @@ def on_mouse_motion(self, x: int, y: int, dx: int, dy: int): """ Override this function to add mouse functionality. - :param int x: x position of mouse - :param int y: y position of mouse - :param int dx: Change in x since the last time this method was called - :param int dy: Change in y since the last time this method was called + :param x: x position of mouse + :param y: y position of mouse + :param dx: Change in x since the last time this method was called + :param dy: Change in y since the last time this method was called """ pass @@ -1042,12 +1039,12 @@ def on_mouse_press(self, x: int, y: int, button: int, modifiers: int): """ Override this function to add mouse button functionality. - :param int x: x position of the mouse - :param int y: y position of the mouse - :param int button: What button was hit. One of: + :param x: x position of the mouse + :param y: y position of the mouse + :param button: What button was hit. One of: arcade.MOUSE_BUTTON_LEFT, arcade.MOUSE_BUTTON_RIGHT, arcade.MOUSE_BUTTON_MIDDLE - :param int modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) + :param modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ pass @@ -1056,12 +1053,12 @@ def on_mouse_drag(self, x: int, y: int, dx: int, dy: int, _buttons: int, _modifi """ Override this function to add mouse button functionality. - :param int x: x position of mouse - :param int y: y position of mouse - :param int dx: Change in x since the last time this method was called - :param int dy: Change in y since the last time this method was called - :param int _buttons: Which button is pressed - :param int _modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) + :param x: x position of mouse + :param y: y position of mouse + :param dx: Change in x since the last time this method was called + :param dy: Change in y since the last time this method was called + :param _buttons: Which button is pressed + :param _modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ self.on_mouse_motion(x, y, dx, dy) @@ -1070,12 +1067,12 @@ def on_mouse_release(self, x: int, y: int, button: int, modifiers: int): """ Override this function to add mouse button functionality. - :param int x: x position of mouse - :param int y: y position of mouse - :param int button: What button was hit. One of: + :param x: x position of mouse + :param y: y position of mouse + :param button: What button was hit. One of: arcade.MOUSE_BUTTON_LEFT, arcade.MOUSE_BUTTON_RIGHT, arcade.MOUSE_BUTTON_MIDDLE - :param int modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) + :param modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ pass @@ -1084,10 +1081,10 @@ def on_mouse_scroll(self, x: int, y: int, scroll_x: int, scroll_y: int): """ User moves the scroll wheel. - :param int x: x position of mouse - :param int y: y position of mouse - :param int scroll_x: ammout of x pixels scrolled since last call - :param int scroll_y: ammout of y pixels scrolled since last call + :param x: x position of mouse + :param y: y position of mouse + :param scroll_x: ammout of x pixels scrolled since last call + :param scroll_y: ammout of y pixels scrolled since last call """ pass @@ -1095,8 +1092,8 @@ def on_key_press(self, symbol: int, modifiers: int): """ Override this function to add key press functionality. - :param int symbol: Key that was hit - :param int modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) + :param symbol: Key that was hit + :param modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ try: @@ -1108,8 +1105,8 @@ def on_key_release(self, _symbol: int, _modifiers: int): """ Override this function to add key release functionality. - :param int _symbol: Key that was hit - :param int _modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) + :param _symbol: Key that was hit + :param _modifiers: Bitwise 'and' of all modifiers (shift, ctrl, num lock) active during this event. See :ref:`keyboard_modifiers`. """ try: @@ -1132,8 +1129,8 @@ def on_mouse_enter(self, x: int, y: int): This event will not be triggered if the mouse is currently being dragged. - :param int x: x position of mouse - :param int y: y position of mouse + :param x: x position of mouse + :param y: y position of mouse """ pass @@ -1144,7 +1141,7 @@ def on_mouse_leave(self, x: int, y: int): dragged. Note that the coordinates of the mouse pointer will be outside of the window rectangle. - :param int x: x position of mouse - :param int y: y position of mouse + :param x: x position of mouse + :param y: y position of mouse """ pass diff --git a/arcade/background/background_texture.py b/arcade/background/background_texture.py index ebdcdea77..429e33e1e 100644 --- a/arcade/background/background_texture.py +++ b/arcade/background/background_texture.py @@ -118,7 +118,7 @@ def wrap_y(self, value: int): def use(self, unit: int = 0) -> None: """Bind the texture to a channel, - :param int unit: The texture unit to bind the texture. + :param unit: The texture unit to bind the texture. """ self.texture.use(unit) diff --git a/arcade/cache/hit_box.py b/arcade/cache/hit_box.py index 3688c2dac..01b21af2c 100644 --- a/arcade/cache/hit_box.py +++ b/arcade/cache/hit_box.py @@ -57,7 +57,7 @@ def get(self, name_or_texture: Union[str, "Texture"]) -> Optional[PointList]: points = cache.get("hash|(0, 1, 2, 3)|simple|") :param keys: List of keys to use for the cache entry - :param str hit_box_algorithm: The hit box algorithm used + :param hit_box_algorithm: The hit box algorithm used """ from arcade import Texture @@ -79,8 +79,8 @@ def put(self, name_or_texture: Union[str, "Texture"], points: PointList) -> None # Cache with custom string cache.put("my_custom_points", points) - :param List[Any] keys: List of keys to use for the cache entry - :param PointList points: The hit box points + :param keys: List of keys to use for the cache entry + :param points: The hit box points """ from arcade import Texture @@ -124,8 +124,8 @@ def save(self, path: Path, indent: int = 0) -> None: if the file extension is ".gz" the file will be compressed. - :param Path path: The path to save the cache to - :param int indent: The indentation level for the json file + :param path: The path to save the cache to + :param indent: The indentation level for the json file """ if indent == 0: data_str = json.dumps(self._entries) diff --git a/arcade/camera.py b/arcade/camera.py index f3fb89343..8d28ab76e 100644 --- a/arcade/camera.py +++ b/arcade/camera.py @@ -147,7 +147,7 @@ def _set_projection_matrix(self, *, update_combined_matrix: bool = True) -> None """ Helper method. This will just pre-compute the projection and combined matrix - :param bool update_combined_matrix: if True will also update the combined matrix (projection @ view) + :param update_combined_matrix: if True will also update the combined matrix (projection @ view) """ self._projection_matrix = Mat4.orthogonal_projection(*self._projection, -100, 100) if update_combined_matrix: @@ -157,7 +157,7 @@ def _set_view_matrix(self, *, update_combined_matrix: bool = True) -> None: """ Helper method. This will just pre-compute the view and combined matrix - :param bool update_combined_matrix: if True will also update the combined matrix (projection @ view) + :param update_combined_matrix: if True will also update the combined matrix (projection @ view) """ # Figure out our 'real' position @@ -181,8 +181,8 @@ def move_to(self, vector: Union[Vec2, tuple], speed: float = 1.0) -> None: The camera will lerp towards this position based on the provided speed, updating its position every time the use() function is called. - :param Vec2 vector: Vector to move the camera towards. - :param Vec2 speed: How fast to move the camera, 1.0 is instant, 0.1 moves slowly + :param vector: Vector to move the camera towards. + :param speed: How fast to move the camera, 1.0 is instant, 0.1 moves slowly """ self.goal_position = Vec2(*vector) self.move_speed = speed @@ -221,7 +221,7 @@ def get_map_coordinates(self, camera_vector: Union[Vec2, tuple]) -> Vec2: """ Returns map coordinates in pixels from screen coordinates based on the camera position - :param Vec2 camera_vector: Vector captured from the camera viewport + :param camera_vector: Vector captured from the camera viewport """ return Vec2(*self.position) + Vec2(*camera_vector) @@ -230,9 +230,9 @@ def resize(self, viewport_width: int, viewport_height: int, *, """ Resize the camera's viewport. Call this when the window resizes. - :param int viewport_width: Width of the viewport - :param int viewport_height: Height of the viewport - :param bool resize_projection: if True the projection will also be resized + :param viewport_width: Width of the viewport + :param viewport_height: Height of the viewport + :param resize_projection: if True the projection will also be resized """ new_viewport = (self._viewport[0], self._viewport[1], viewport_width, viewport_height) self.set_viewport(new_viewport) @@ -272,12 +272,12 @@ class Camera(SimpleCamera): It is very useful for separating a scrolling screen of sprites, and a GUI overlay. For an example of this in action, see :ref:`sprite_move_scrolling`. - :param tuple viewport: (left, bottom, width, height) size of the viewport. If None the window size will be used. - :param tuple projection: (left, right, bottom, top) size of the projection. If None the window size will be used. - :param float zoom: the zoom to apply to the projection - :param float rotation: the angle in degrees to rotate the projection - :param tuple anchor: the x, y point where the camera rotation will anchor. Default is the center of the viewport. - :param Window window: Window to associate with this camera, if working with a multi-window program. + :param viewport: (left, bottom, width, height) size of the viewport. If None the window size will be used. + :param projection: (left, right, bottom, top) size of the projection. If None the window size will be used. + :param zoom: the zoom to apply to the projection + :param rotation: the angle in degrees to rotate the projection + :param anchor: the x, y point where the camera rotation will anchor. Default is the center of the viewport. + :param window: Window to associate with this camera, if working with a multi-window program. """ def __init__( self, *, @@ -331,7 +331,7 @@ def _set_projection_matrix(self, *, update_combined_matrix: bool = True) -> None """ Helper method. This will just pre-compute the projection and combined matrix - :param bool update_combined_matrix: if True will also update the combined matrix (projection @ view) + :param update_combined_matrix: if True will also update the combined matrix (projection @ view) """ # apply zoom left, right, bottom, top = self._projection @@ -347,7 +347,7 @@ def _set_projection_matrix(self, *, update_combined_matrix: bool = True) -> None def _set_view_matrix(self, *, update_combined_matrix: bool = True) -> None: """ Helper method. This will just pre-compute the view and combined matrix - :param bool update_combined_matrix: if True will also update the combined matrix (projection @ view) + :param update_combined_matrix: if True will also update the combined matrix (projection @ view) """ # Figure out our 'real' position plus the shake @@ -540,9 +540,9 @@ def shake(self, velocity: Union[Vec2, tuple], speed: float = 1.5, damping: float """ Add a camera shake. - :param Vec2 velocity: Vector to start moving the camera - :param float speed: How fast to shake - :param float damping: How fast to stop shaking + :param velocity: Vector to start moving the camera + :param speed: How fast to shake + :param damping: How fast to stop shaking """ if not isinstance(velocity, Vec2): velocity = Vec2(*velocity) @@ -568,10 +568,9 @@ def get_sprites_at_point(self, point: "Point", sprite_list: "SpriteList") -> Lis the specified point. If a sprite has a different center_x/center_y but touches the point, this will return that sprite. - :param Point point: Point to check - :param SpriteList sprite_list: SpriteList to check against + :param point: Point to check + :param sprite_list: SpriteList to check against :returns: List of sprites colliding, or an empty list. - :rtype: list """ raise NotImplementedError() diff --git a/arcade/context.py b/arcade/context.py index 4d3f9b23b..25f9663d3 100644 --- a/arcade/context.py +++ b/arcade/context.py @@ -35,8 +35,8 @@ class ArcadeContext(Context): **This is part of the low level rendering API in arcade and is mainly for more advanced usage** - :param pyglet.window.Window window: The pyglet window - :param str gc_mode: The garbage collection mode for opengl objects. + :param window: The pyglet window + :param gc_mode: The garbage collection mode for opengl objects. ``auto`` is just what we would expect in python while ``context_gc`` (default) requires you to call ``Context.gc()``. The latter can be useful when using multiple threads when @@ -367,17 +367,17 @@ def load_program( fragment_shader="frag.glsl", ) - :param Union[str,pathlib.Path] vertex_shader: path to vertex shader - :param Union[str,pathlib.Path] fragment_shader: path to fragment shader (optional) - :param Union[str,pathlib.Path] geometry_shader: path to geometry shader (optional) - :param Union[str,pathlib.Path] tess_control_shader: Tessellation Control Shader - :param Union[str,pathlib.Path] tess_evaluation_shader: Tessellation Evaluation Shader - :param List[Union[str,pathlib.Path]] common: Common files to be included in all shaders - :param dict defines: Substitute ``#define`` values in the source - :param Optional[Sequence[str]] varyings: The name of the out attributes in a transform shader. + :param vertex_shader: path to vertex shader + :param fragment_shader: path to fragment shader (optional) + :param geometry_shader: path to geometry shader (optional) + :param tess_control_shader: Tessellation Control Shader + :param tess_evaluation_shader: Tessellation Evaluation Shader + :param common: Common files to be included in all shaders + :param defines: Substitute ``#define`` values in the source + :param varyings: The name of the out attributes in a transform shader. This is normally not necessary since we auto detect them, but some more complex out structures we can't detect. - :param str varyings_capture_mode: The capture mode for transforms. + :param varyings_capture_mode: The capture mode for transforms. ``"interleaved"`` means all out attribute will be written to a single buffer. ``"separate"`` means each out attribute will be written separate buffers. Based on these settings the `transform()` method will accept a single @@ -430,8 +430,8 @@ def load_compute_shader(self, path: Union[str, Path], common: Iterable[Union[str ctx.load_compute_shader(":shader:compute/do_work.glsl") - :param Union[str,pathlib.Path] path: Path to texture - :param Iterable[Union[str,pathlib.Path]] common: Common source injected into compute shader + :param path: Path to texture + :param common: Common source injected into compute shader """ from arcade.resources import resolve path = resolve(path) @@ -459,9 +459,9 @@ def load_texture( # Load a texture using Arcade resource handle texture = window.ctx.load_texture(":textures:background.png") - :param Union[str,pathlib.Path] path: Path to texture - :param bool flip: Flips the image upside down - :param bool build_mipmaps: Build mipmaps for the texture + :param path: Path to texture + :param flip: Flips the image upside down + :param build_mipmaps: Build mipmaps for the texture """ from arcade.resources import resolve @@ -494,7 +494,7 @@ def shader_inc(self, source: str) -> str: #include :my_shader:lib/common.glsl - :param str source: Shader + :param source: Shader """ from arcade.resources import resolve lines = source.splitlines() @@ -514,9 +514,9 @@ def get_framebuffer_image( """ Shortcut method for reading data from a framebuffer and converting it to a PIL image. - :param Framebuffer fbo: Framebuffer to get image from - :param int components: Number of components to read - :param bool flip: Flip the image upside down + :param fbo: Framebuffer to get image from + :param components: Number of components to read + :param flip: Flip the image upside down """ mode = "RGBA"[:components] image = Image.frombuffer( diff --git a/arcade/draw_commands.py b/arcade/draw_commands.py index bad76c26a..9658b233c 100644 --- a/arcade/draw_commands.py +++ b/arcade/draw_commands.py @@ -73,16 +73,16 @@ def draw_arc_filled(center_x: float, center_y: float, """ Draw a filled in arc. Useful for drawing pie-wedges, or Pac-Man. - :param float center_x: x position that is the center of the arc. - :param float center_y: y position that is the center of the arc. - :param float width: width of the arc. - :param float height: height of the arc. - :param RGBA255 color: A 3 or 4 length tuple of 0-255 channel values + :param center_x: x position that is the center of the arc. + :param center_y: y position that is the center of the arc. + :param width: width of the arc. + :param height: height of the arc. + :param color: A 3 or 4 length tuple of 0-255 channel values or a :py:class:`~arcade.types.Color` instance. - :param float start_angle: start angle of the arc in degrees. - :param float end_angle: end angle of the arc in degrees. - :param float tilt_angle: angle the arc is tilted (clockwise). - :param float num_segments: Number of line segments used to draw arc. + :param start_angle: start angle of the arc in degrees. + :param end_angle: end angle of the arc in degrees. + :param tilt_angle: angle the arc is tilted (clockwise). + :param num_segments: Number of line segments used to draw arc. """ unrotated_point_list = [(0.0, 0.0)] @@ -115,17 +115,17 @@ def draw_arc_outline(center_x: float, center_y: float, width: float, """ Draw the outside edge of an arc. Useful for drawing curved lines. - :param float center_x: x position that is the center of the arc. - :param float center_y: y position that is the center of the arc. - :param float width: width of the arc. - :param float height: height of the arc. - :param RGBA255 color: A 3 or 4 length tuple of 0-255 channel values + :param center_x: x position that is the center of the arc. + :param center_y: y position that is the center of the arc. + :param width: width of the arc. + :param height: height of the arc. + :param color: A 3 or 4 length tuple of 0-255 channel values or a :py:class:`~arcade.types.Color` instance. - :param float start_angle: start angle of the arc in degrees. - :param float end_angle: end angle of the arc in degrees. - :param float border_width: width of line in pixels. - :param float tilt_angle: angle the arc is tilted (clockwise). - :param int num_segments: float of triangle segments that make up this + :param start_angle: start angle of the arc in degrees. + :param end_angle: end angle of the arc in degrees. + :param border_width: width of line in pixels. + :param tilt_angle: angle the arc is tilted (clockwise). + :param num_segments: float of triangle segments that make up this circle. Higher is better quality, but slower render time. """ unrotated_point_list = [] @@ -171,13 +171,13 @@ def draw_parabola_filled(start_x: float, start_y: float, end_x: float, """ Draws a filled in parabola. - :param float start_x: The starting x position of the parabola - :param float start_y: The starting y position of the parabola - :param float end_x: The ending x position of the parabola - :param float height: The height of the parabola - :param RGBA255 color: A 3 or 4 length tuple of 0-255 channel values + :param start_x: The starting x position of the parabola + :param start_y: The starting y position of the parabola + :param end_x: The ending x position of the parabola + :param height: The height of the parabola + :param color: A 3 or 4 length tuple of 0-255 channel values or a :py:class:`~arcade.types.Color` instance. - :param float tilt_angle: The angle of the tilt of the parabola (clockwise) + :param tilt_angle: The angle of the tilt of the parabola (clockwise) """ center_x = (start_x + end_x) / 2 center_y = start_y + height @@ -194,14 +194,14 @@ def draw_parabola_outline(start_x: float, start_y: float, end_x: float, """ Draws the outline of a parabola. - :param float start_x: The starting x position of the parabola - :param float start_y: The starting y position of the parabola - :param float end_x: The ending x position of the parabola - :param float height: The height of the parabola - :param RGBA255 color: A 3 or 4 length tuple of 0-255 channel values + :param start_x: The starting x position of the parabola + :param start_y: The starting y position of the parabola + :param end_x: The ending x position of the parabola + :param height: The height of the parabola + :param color: A 3 or 4 length tuple of 0-255 channel values or a :py:class:`~arcade.types.Color` instance. - :param float border_width: The width of the parabola - :param float tilt_angle: The angle of the tilt of the parabola (clockwise) + :param border_width: The width of the parabola + :param tilt_angle: The angle of the tilt of the parabola (clockwise) """ center_x = (start_x + end_x) / 2 center_y = start_y + height @@ -224,13 +224,13 @@ def draw_circle_filled(center_x: float, center_y: float, radius: float, """ Draw a filled-in circle. - :param float center_x: x position that is the center of the circle. - :param float center_y: y position that is the center of the circle. - :param float radius: width of the circle. - :param RGBA255 color: A 3 or 4 length tuple of 0-255 channel values + :param center_x: x position that is the center of the circle. + :param center_y: y position that is the center of the circle. + :param radius: width of the circle. + :param color: A 3 or 4 length tuple of 0-255 channel values or a :py:class:`~arcade.types.Color` instance. - :param float tilt_angle: Angle in degrees to tilt the circle. Useful for low segment count circles - :param int num_segments: Number of triangle segments that make up this + :param tilt_angle: Angle in degrees to tilt the circle. Useful for low segment count circles + :param num_segments: Number of triangle segments that make up this circle. Higher is better quality, but slower render time. The default value of -1 means arcade will try to calculate a reasonable amount of segments based on the size of the circle. @@ -247,15 +247,15 @@ def draw_circle_outline(center_x: float, center_y: float, radius: float, """ Draw the outline of a circle. - :param float center_x: x position that is the center of the circle. - :param float center_y: y position that is the center of the circle. - :param float radius: width of the circle. - :param RGBA255 color: A 3 or 4 length tuple of 0-255 channel values + :param center_x: x position that is the center of the circle. + :param center_y: y position that is the center of the circle. + :param radius: width of the circle. + :param color: A 3 or 4 length tuple of 0-255 channel values or a :py:class:`~arcade.types.Color` instance. - :param float border_width: Width of the circle outline in pixels. - :param float tilt_angle: Angle in degrees to tilt the circle (clockwise). + :param border_width: Width of the circle outline in pixels. + :param tilt_angle: Angle in degrees to tilt the circle (clockwise). Useful for low segment count circles - :param int num_segments: Number of triangle segments that make up this + :param num_segments: Number of triangle segments that make up this circle. Higher is better quality, but slower render time. The default value of -1 means arcade will try to calculate a reasonable amount of segments based on the size of the circle. @@ -278,17 +278,17 @@ def draw_ellipse_filled(center_x: float, center_y: float, """ Draw a filled in ellipse. - :param float center_x: x position that is the center of the circle. - :param float center_y: y position that is the center of the circle. - :param float width: width of the ellipse. - :param float height: height of the ellipse. - :param RGBA255 color: A 3 or 4 length tuple of 0-255 channel values + :param center_x: x position that is the center of the circle. + :param center_y: y position that is the center of the circle. + :param width: width of the ellipse. + :param height: height of the ellipse. + :param color: A 3 or 4 length tuple of 0-255 channel values or a :py:class:`~arcade.types.Color` instance. - :param RGBA255 color: Either a :py:class:`~arcade.types.Color` instance + :param color: Either a :py:class:`~arcade.types.Color` instance or an RGBA :py:class:`tuple` of 4 byte values (0 to 255). - :param float tilt_angle: Angle in degrees to tilt the ellipse (clockwise). + :param tilt_angle: Angle in degrees to tilt the ellipse (clockwise). Useful when drawing a circle with a low segment count, to make an octagon for example. - :param int num_segments: Number of triangle segments that make up this + :param num_segments: Number of triangle segments that make up this circle. Higher is better quality, but slower render time. The default value of -1 means arcade will try to calculate a reasonable amount of segments based on the size of the circle. @@ -325,16 +325,16 @@ def draw_ellipse_outline(center_x: float, center_y: float, """ Draw the outline of an ellipse. - :param float center_x: x position that is the center of the circle. - :param float center_y: y position that is the center of the circle. - :param float width: width of the ellipse. - :param float height: height of the ellipse. - :param RGBA255 color: A 3 or 4 length tuple of 0-255 channel values + :param center_x: x position that is the center of the circle. + :param center_y: y position that is the center of the circle. + :param width: width of the ellipse. + :param height: height of the ellipse. + :param color: A 3 or 4 length tuple of 0-255 channel values or a :py:class:`~arcade.types.Color` instance. - :param float border_width: Width of the circle outline in pixels. - :param float tilt_angle: Angle in degrees to tilt the ellipse (clockwise). + :param border_width: Width of the circle outline in pixels. + :param tilt_angle: Angle in degrees to tilt the ellipse (clockwise). Useful when drawing a circle with a low segment count, to make an octagon for example. - :param int num_segments: Number of triangle segments that make up this + :param num_segments: Number of triangle segments that make up this circle. Higher is better quality, but slower render time. The default value of -1 means arcade will try to calculate a reasonable amount of segments based on the size of the circle. @@ -377,7 +377,7 @@ def _generic_draw_line_strip(point_list: PointList, :param point_list: List of points making up the line. Each point is in a list. So it is a list of lists. - :param RGBA255 color: A color, specified as an RGBA tuple or a + :param color: A color, specified as an RGBA tuple or a :py:class:`~arcade.types.Color` instance. """ window = get_window() @@ -411,10 +411,10 @@ def draw_line_strip(point_list: PointList, """ Draw a multi-point line. - :param PointList point_list: List of x, y points that make up this strip - :param RGBA255 color: A color, specified as an RGBA tuple or a + :param point_list: List of x, y points that make up this strip + :param color: A color, specified as an RGBA tuple or a :py:class:`~arcade.types.Color` instance. - :param float line_width: Width of the line + :param line_width: Width of the line """ if line_width == 1: _generic_draw_line_strip(point_list, color, gl.GL_LINE_STRIP) @@ -436,13 +436,13 @@ def draw_line(start_x: float, start_y: float, end_x: float, end_y: float, """ Draw a line. - :param float start_x: x position of line starting point. - :param float start_y: y position of line starting point. - :param float end_x: x position of line ending point. - :param float end_y: y position of line ending point. - :param RGBA255 color: A color, specified as an RGBA tuple or a + :param start_x: x position of line starting point. + :param start_y: y position of line starting point. + :param end_x: x position of line ending point. + :param end_y: y position of line ending point. + :param color: A color, specified as an RGBA tuple or a :py:class:`~arcade.types.Color` instance. - :param float line_width: Width of the line in pixels. + :param line_width: Width of the line in pixels. """ window = get_window() ctx = window.ctx @@ -473,11 +473,11 @@ def draw_lines(point_list: PointList, Draw a line between each pair of points specified. - :param PointList point_list: List of points making up the lines. Each point is + :param point_list: List of points making up the lines. Each point is in a list. So it is a list of lists. - :param RGBA255 color: A color, specified as an RGBA tuple or a + :param color: A color, specified as an RGBA tuple or a :py:class:`~arcade.types.Color` instance. - :param float line_width: Width of the line in pixels. + :param line_width: Width of the line in pixels. """ window = get_window() ctx = window.ctx @@ -511,11 +511,11 @@ def draw_point(x: float, y: float, color: RGBA255, size: float): """ Draw a point. - :param float x: x position of point. - :param float y: y position of point. - :param RGBA255 color: A color, specified as an RGBA tuple or a + :param x: x position of point. + :param y: y position of point. + :param color: A color, specified as an RGBA tuple or a :py:class:`~arcade.types.Color` instance. - :param float size: Size of the point in pixels. + :param size: Size of the point in pixels. """ draw_rectangle_filled(x, y, size, size, color) @@ -524,11 +524,11 @@ def draw_points(point_list: PointList, color: RGBA255, size: float = 1): """ Draw a set of points. - :param PointList point_list: List of points Each point is + :param point_list: List of points Each point is in a list. So it is a list of lists. - :param RGBA255 color: A color, specified as an RGBA tuple or a + :param color: A color, specified as an RGBA tuple or a :py:class:`~arcade.types.Color` instance. - :param float size: Size of the point in pixels. + :param size: Size of the point in pixels. """ window = get_window() ctx = window.ctx @@ -565,9 +565,9 @@ def draw_polygon_filled(point_list: PointList, """ Draw a polygon that is filled in. - :param PointList point_list: List of points making up the lines. Each point is + :param point_list: List of points making up the lines. Each point is in a list. So it is a list of lists. - :param RGBA255 color: The color, specified in RGB or RGBA format. + :param color: The color, specified in RGB or RGBA format. """ triangle_points = earclip(point_list) flattened_list = tuple(i for g in triangle_points for i in g) @@ -579,11 +579,11 @@ def draw_polygon_outline(point_list: PointList, """ Draw a polygon outline. Also known as a "line loop." - :param PointList point_list: List of points making up the lines. Each point is + :param point_list: List of points making up the lines. Each point is in a list. So it is a list of lists. - :param RGBA255 color: The color of the outline as an RGBA :py:class:`tuple` or + :param color: The color of the outline as an RGBA :py:class:`tuple` or :py:class:`~arcade.types.Color` instance. - :param int line_width: Width of the line in pixels. + :param line_width: Width of the line in pixels. """ new_point_list = list(point_list) new_point_list.append(point_list[0]) @@ -610,13 +610,13 @@ def draw_triangle_filled(x1: float, y1: float, """ Draw a filled in triangle. - :param float x1: x value of first coordinate. - :param float y1: y value of first coordinate. - :param float x2: x value of second coordinate. - :param float y2: y value of second coordinate. - :param float x3: x value of third coordinate. - :param float y3: y value of third coordinate. - :param RGBA255 color: Color of the triangle as an RGBA :py:class:`tuple` or + :param x1: x value of first coordinate. + :param y1: y value of first coordinate. + :param x2: x value of second coordinate. + :param y2: y value of second coordinate. + :param x3: x value of third coordinate. + :param y3: y value of third coordinate. + :param color: Color of the triangle as an RGBA :py:class:`tuple` or :py:class:`~arcade.types.Color` instance. """ point_list = ( @@ -635,15 +635,15 @@ def draw_triangle_outline(x1: float, y1: float, """ Draw a the outline of a triangle. - :param float x1: x value of first coordinate. - :param float y1: y value of first coordinate. - :param float x2: x value of second coordinate. - :param float y2: y value of second coordinate. - :param float x3: x value of third coordinate. - :param float y3: y value of third coordinate. - :param RGBA255 color: RGBA255 of triangle as an RGBA + :param x1: x value of first coordinate. + :param y1: y value of first coordinate. + :param x2: x value of second coordinate. + :param y2: y value of second coordinate. + :param x3: x value of third coordinate. + :param y3: y value of third coordinate. + :param color: RGBA255 of triangle as an RGBA :py:class:`tuple` or :py:class`~arcade.types.Color` instance. - :param float border_width: Width of the border in pixels. Defaults to 1. + :param border_width: Width of the border in pixels. Defaults to 1. """ point_list = ( (x1, y1), @@ -672,13 +672,13 @@ def draw_lrtb_rectangle_outline(left: float, right: float, top: float, .. deprecated:: 3.0 Use :py:func:`draw_lrbt_rectangle_outline` instead! - :param float left: The x coordinate of the left edge of the rectangle. - :param float right: The x coordinate of the right edge of the rectangle. - :param float top: The y coordinate of the top of the rectangle. - :param float bottom: The y coordinate of the rectangle bottom. - :param RGBA255 color: The color of the rectangle as an RGBA + :param left: The x coordinate of the left edge of the rectangle. + :param right: The x coordinate of the right edge of the rectangle. + :param top: The y coordinate of the top of the rectangle. + :param bottom: The y coordinate of the rectangle bottom. + :param color: The color of the rectangle as an RGBA :py:class:`tuple` or :py:class`~arcade.types.Color` instance. - :param float border_width: The width of the border in pixels. Defaults to one. + :param border_width: The width of the border in pixels. Defaults to one. :Raises AttributeError: Raised if left > right or top < bottom. """ @@ -703,12 +703,12 @@ def draw_lrbt_rectangle_outline(left: float, right: float, bottom: float, top: f """ Draw a rectangle by specifying left, right, bottom and top edges. - :param float left: The x coordinate of the left edge of the rectangle. - :param float right: The x coordinate of the right edge of the rectangle. - :param float bottom: The y coordinate of the rectangle bottom. - :param float top: The y coordinate of the top of the rectangle. - :param Color color: The color of the rectangle. - :param float border_width: The width of the border in pixels. Defaults to one. + :param left: The x coordinate of the left edge of the rectangle. + :param right: The x coordinate of the right edge of the rectangle. + :param bottom: The y coordinate of the rectangle bottom. + :param top: The y coordinate of the top of the rectangle. + :param color: The color of the rectangle. + :param border_width: The width of the border in pixels. Defaults to one. :Raises ValueError: Raised if left > right or top < bottom. """ @@ -735,13 +735,13 @@ def draw_xywh_rectangle_outline(bottom_left_x: float, bottom_left_y: float, """ Draw a rectangle extending from bottom left to top right - :param float bottom_left_x: The x coordinate of the left edge of the rectangle. - :param float bottom_left_y: The y coordinate of the bottom of the rectangle. - :param float width: The width of the rectangle. - :param float height: The height of the rectangle. - :param RGBA255 color: The color of the rectangle as an RGBA + :param bottom_left_x: The x coordinate of the left edge of the rectangle. + :param bottom_left_y: The y coordinate of the bottom of the rectangle. + :param width: The width of the rectangle. + :param height: The height of the rectangle. + :param color: The color of the rectangle as an RGBA :py:class:`tuple` or :py:class`~arcade.types.Color` instance. - :param float border_width: The width of the border in pixels. Defaults to one. + :param border_width: The width of the border in pixels. Defaults to one. """ center_x = bottom_left_x + (width / 2) center_y = bottom_left_y + (height / 2) @@ -755,14 +755,14 @@ def draw_rectangle_outline(center_x: float, center_y: float, width: float, """ Draw a rectangle outline. - :param float center_x: x coordinate of top left rectangle point. - :param float center_y: y coordinate of top left rectangle point. - :param float width: width of the rectangle. - :param float height: height of the rectangle. - :param RGBA255 color: The color of the rectangle as an RGBA + :param center_x: x coordinate of top left rectangle point. + :param center_y: y coordinate of top left rectangle point. + :param width: width of the rectangle. + :param height: height of the rectangle. + :param color: The color of the rectangle as an RGBA :py:class:`tuple` or :py:class`~arcade.types.Color` instance. - :param float border_width: width of the lines, in pixels. - :param float tilt_angle: rotation of the rectangle. Defaults to zero (clockwise). + :param border_width: width of the lines, in pixels. + :param tilt_angle: rotation of the rectangle. Defaults to zero (clockwise). """ i_lb = center_x - width / 2 + border_width / 2, center_y - height / 2 + border_width / 2 i_rb = center_x + width / 2 - border_width / 2, center_y - height / 2 + border_width / 2 @@ -798,11 +798,11 @@ def draw_lrtb_rectangle_filled(left: float, right: float, top: float, .. deprecated:: 3.0 Use :py:func:`draw_lrbt_rectangle_filled` instead! - :param float left: The x coordinate of the left edge of the rectangle. - :param float right: The x coordinate of the right edge of the rectangle. - :param float top: The y coordinate of the top of the rectangle. - :param float bottom: The y coordinate of the rectangle bottom. - :param RGBA255 color: The color of the rectangle as an RGBA + :param left: The x coordinate of the left edge of the rectangle. + :param right: The x coordinate of the right edge of the rectangle. + :param top: The y coordinate of the top of the rectangle. + :param bottom: The y coordinate of the rectangle bottom. + :param color: The color of the rectangle as an RGBA :py:class:`tuple` or :py:class`~arcade.types.Color` instance. :Raises AttributeError: Raised if left > right or top < bottom. """ @@ -823,11 +823,11 @@ def draw_lrbt_rectangle_filled(left: float, right: float, bottom: float, top: fl """ Draw a rectangle by specifying left, right, bottom and top edges. - :param float left: The x coordinate of the left edge of the rectangle. - :param float right: The x coordinate of the right edge of the rectangle. - :param float bottom: The y coordinate of the rectangle bottom. - :param float top: The y coordinate of the top of the rectangle. - :param Color color: The color of the rectangle. + :param left: The x coordinate of the left edge of the rectangle. + :param right: The x coordinate of the right edge of the rectangle. + :param bottom: The y coordinate of the rectangle bottom. + :param top: The y coordinate of the top of the rectangle. + :param color: The color of the rectangle. :Raises ValueError: Raised if left > right or top < bottom. """ if left > right: @@ -849,11 +849,11 @@ def draw_xywh_rectangle_filled(bottom_left_x: float, bottom_left_y: float, """ Draw a filled rectangle extending from bottom left to top right - :param float bottom_left_x: The x coordinate of the left edge of the rectangle. - :param float bottom_left_y: The y coordinate of the bottom of the rectangle. - :param float width: The width of the rectangle. - :param float height: The height of the rectangle. - :param RGBA255 color: The color of the rectangleas an RGBA + :param bottom_left_x: The x coordinate of the left edge of the rectangle. + :param bottom_left_y: The y coordinate of the bottom of the rectangle. + :param width: The width of the rectangle. + :param height: The height of the rectangle. + :param color: The color of the rectangleas an RGBA :py:class:`tuple` or :py:class`~arcade.types.Color` instance. """ center_x = bottom_left_x + (width / 2) @@ -867,13 +867,13 @@ def draw_rectangle_filled(center_x: float, center_y: float, width: float, """ Draw a filled-in rectangle. - :param float center_x: x coordinate of rectangle center. - :param float center_y: y coordinate of rectangle center. - :param float width: width of the rectangle. - :param float height: height of the rectangle. - :param RGBA255 color: The color of the rectangle as an RGBA + :param center_x: x coordinate of rectangle center. + :param center_y: y coordinate of rectangle center. + :param width: width of the rectangle. + :param height: height of the rectangle. + :param color: The color of the rectangle as an RGBA :py:class:`tuple` or :py:class`~arcade.types.Color` instance. - :param float tilt_angle: rotation of the rectangle (clockwise). Defaults to zero. + :param tilt_angle: rotation of the rectangle (clockwise). Defaults to zero. """ window = get_window() ctx = window.ctx @@ -918,13 +918,13 @@ def draw_scaled_texture_rectangle(center_x: float, center_y: float, consider `pyglet's batching features `_. - :param float center_x: x coordinate of rectangle center. - :param float center_y: y coordinate of rectangle center. - :param int texture: identifier of texture returned from + :param center_x: x coordinate of rectangle center. + :param center_y: y coordinate of rectangle center. + :param texture: identifier of texture returned from load_texture() call - :param float scale: scale of texture - :param float angle: rotation of the rectangle (clockwise). Defaults to zero. - :param float alpha: Transparency of image. 0 is fully transparent, + :param scale: scale of texture + :param angle: rotation of the rectangle (clockwise). Defaults to zero. + :param alpha: Transparency of image. 0 is fully transparent, 255 (default) is fully visible """ texture.draw_scaled(center_x, center_y, scale, angle, alpha) @@ -939,13 +939,13 @@ def draw_texture_rectangle(center_x: float, center_y: float, """ Draw a textured rectangle on-screen. - :param float center_x: x coordinate of rectangle center. - :param float center_y: y coordinate of rectangle center. - :param float width: width of texture - :param float height: height of texture - :param int texture: identifier of texture returned from load_texture() call - :param float angle: rotation of the rectangle. Defaults to zero (clockwise). - :param float alpha: Transparency of image. 0 is fully transparent, 255 (default) is visible + :param center_x: x coordinate of rectangle center. + :param center_y: y coordinate of rectangle center. + :param width: width of texture + :param height: height of texture + :param texture: identifier of texture returned from load_texture() call + :param angle: rotation of the rectangle. Defaults to zero (clockwise). + :param alpha: Transparency of image. 0 is fully transparent, 255 (default) is visible """ texture.draw_sized(center_x, center_y, width, height, angle, alpha) @@ -958,13 +958,13 @@ def draw_lrwh_rectangle_textured(bottom_left_x: float, bottom_left_y: float, """ Draw a texture extending from bottom left to top right. - :param float bottom_left_x: The x coordinate of the left edge of the rectangle. - :param float bottom_left_y: The y coordinate of the bottom of the rectangle. - :param float width: The width of the rectangle. - :param float height: The height of the rectangle. - :param int texture: identifier of texture returned from load_texture() call - :param float angle: rotation of the rectangle. Defaults to zero (clockwise). - :param int alpha: Transparency of image. 0 is fully transparent, 255 (default) is visible + :param bottom_left_x: The x coordinate of the left edge of the rectangle. + :param bottom_left_y: The y coordinate of the bottom of the rectangle. + :param width: The width of the rectangle. + :param height: The height of the rectangle. + :param texture: identifier of texture returned from load_texture() call + :param angle: rotation of the rectangle. Defaults to zero (clockwise). + :param alpha: Transparency of image. 0 is fully transparent, 255 (default) is visible """ center_x = bottom_left_x + (width / 2) @@ -976,12 +976,11 @@ def get_pixel(x: int, y: int, components: int = 3) -> Tuple[int, ...]: """ Given an x, y, will return a color value of that point. - :param int x: x location - :param int y: y location - :param int components: Number of components to fetch. By default we fetch 3 + :param x: x location + :param y: y location + :param components: Number of components to fetch. By default we fetch 3 3 components (RGB). 4 components would be RGBA. - :rtype: Tuple[int, ...] """ # noinspection PyCallingNonCallable,PyTypeChecker @@ -1007,12 +1006,11 @@ def get_image(x: int = 0, y: int = 0, width: Optional[int] = None, height: Optio image = get_image() image.save('screenshot.png', 'PNG') - :param int x: Start (left) x location - :param int y: Start (top) y location - :param int width: Width of image. Leave blank for grabbing the 'rest' of the image - :param int height: Height of image. Leave blank for grabbing the 'rest' of the image + :param x: Start (left) x location + :param y: Start (top) y location + :param width: Width of image. Leave blank for grabbing the 'rest' of the image + :param height: Height of image. Leave blank for grabbing the 'rest' of the image :returns: A Pillow Image - :rtype: PIL.Image.Image """ window = get_window() diff --git a/arcade/examples/sprite_health.py b/arcade/examples/sprite_health.py index 1a1a95700..69892afc2 100644 --- a/arcade/examples/sprite_health.py +++ b/arcade/examples/sprite_health.py @@ -78,16 +78,16 @@ class IndicatorBar: """ Represents a bar which can display information about a sprite. - :param Player owner: The owner of this indicator bar. - :param arcade.SpriteList sprite_list: The sprite list used to draw the indicator + :param owner: The owner of this indicator bar. + :param sprite_list: The sprite list used to draw the indicator bar components. :param Tuple[float, float] position: The initial position of the bar. - :param Color full_color: The color of the bar. - :param Color background_color: The background color of the bar. - :param int width: The width of the bar. - :param int height: The height of the bar. - :param int border_size: The size of the bar's border. - :param float scale: The scale of the indicator bar. + :param full_color: The color of the bar. + :param background_color: The background color of the bar. + :param width: The width of the bar. + :param height: The height of the bar. + :param border_size: The size of the bar's border. + :param scale: The scale of the indicator bar. """ def __init__( diff --git a/arcade/experimental/bloom_filter.py b/arcade/experimental/bloom_filter.py index 050b56ec2..9cf979562 100644 --- a/arcade/experimental/bloom_filter.py +++ b/arcade/experimental/bloom_filter.py @@ -10,8 +10,8 @@ class BloomFilter: """ CRT Filter - :param int width: - :param int height: + :param width: + :param height: """ def __init__( diff --git a/arcade/experimental/crt_filter.py b/arcade/experimental/crt_filter.py index 8d0ca152d..59169f90f 100644 --- a/arcade/experimental/crt_filter.py +++ b/arcade/experimental/crt_filter.py @@ -8,12 +8,12 @@ class CRTFilter: """ CRT Filter - :param int width: - :param int height: - :param float resolution_down_scale: - :param float hard_scan: -8.0 soft, -16.0 medium - :param float hard_pix: Hardness of pixels in the scan line. -2.0 soft, -4.0 medium - :param Vec2 display_warp: Display warp. 0 = None, 1.0/8.0 = extreme + :param width: + :param height: + :param resolution_down_scale: + :param hard_scan: -8.0 soft, -16.0 medium + :param hard_pix: Hardness of pixels in the scan line. -2.0 soft, -4.0 medium + :param display_warp: Display warp. 0 = None, 1.0/8.0 = extreme """ def __init__( self, diff --git a/arcade/experimental/lights.py b/arcade/experimental/lights.py index 280dbe35b..26cff1013 100644 --- a/arcade/experimental/lights.py +++ b/arcade/experimental/lights.py @@ -27,11 +27,11 @@ def __init__( Note: It's important to separate lights that don't change properties and static ones with the ``usage`` parameter. - :param float center_x: X position of the light - :param float center_y: Y position of the light - :param float radius: Radius of the light - :param RGBA255 color: Color of the light - :param str mode: 'hard' or 'soft' light + :param center_x: X position of the light + :param center_y: Y position of the light + :param radius: Radius of the light + :param color: Color of the light + :param mode: 'hard' or 'soft' light """ if not (isinstance(color, tuple) or isinstance(color, list)): raise ValueError("Color must be a 3-4 element Tuple or List with red-green-blue and optionally an alpha.") @@ -165,7 +165,7 @@ def draw(self, position: Tuple[float, float] = (0, 0), target=None, ambient_colo """Draw the lights :param Tuple[float, float] position: Position offset (scrolling) :param target: The window or framebuffer we want to render to (default is window) - :param Color ambient_color: The ambient light color + :param ambient_color: The ambient light color """ if target is None: target = self.window diff --git a/arcade/experimental/profiling.py b/arcade/experimental/profiling.py index dd0314159..afca84f7f 100644 --- a/arcade/experimental/profiling.py +++ b/arcade/experimental/profiling.py @@ -32,7 +32,7 @@ class Profiler: The same profiler instance can be enabled multiple times to accumulate data. - :param str sort_by: function sort order + :param sort_by: function sort order """ def __init__(self, sort_by="tottime"): self._sort_by = sort_by diff --git a/arcade/experimental/shadertoy.py b/arcade/experimental/shadertoy.py index 8133628a0..15fdc3b33 100644 --- a/arcade/experimental/shadertoy.py +++ b/arcade/experimental/shadertoy.py @@ -50,8 +50,8 @@ class ShadertoyBase: uniform sampler2D iChannel2; uniform sampler2D iChannel3; - :param Tuple[int,int] size: screen/area size - :param str source: The mainImage shader source + :param size: screen/area size + :param source: The mainImage shader source """ def __init__(self, size: Tuple[int, int], source: str): self._ctx = get_window().ctx @@ -262,7 +262,7 @@ def render( """ Render the shadertoy project to the screen. - :param float time: Override the time + :param time: Override the time :param time_delta: Override the time delta :param mouse_position: Override mouse position :param size: Override the size @@ -283,7 +283,7 @@ def reload(self, source: str): """ Update the shader source code. - :param str source: New mainImage shader source + :param source: New mainImage shader source """ self._set_source(source) @@ -348,9 +348,9 @@ class ShadertoyBuffer(ShadertoyBase): An offscreen framebuffer we can render to with the supplied shader or render any other content into. - :param Tuple[int,int] size: Size of framebuffer / texture - :param str source: mainImage shader source - :param bool repeat: Repeat/wrap mode for the underlying texture + :param size: Size of framebuffer / texture + :param source: mainImage shader source + :param repeat: Repeat/wrap mode for the underlying texture """ def __init__(self, size: Tuple[int, int], source: str, repeat: bool = False): super().__init__(size, source) @@ -406,7 +406,7 @@ def resize(self, size: Tuple[int, int]): """ Change the internal buffer size. - :param Tuple[int,int] size: New size + :param size: New size """ if self._size == size: return @@ -429,7 +429,7 @@ class Shadertoy(ShadertoyBase): def __init__(self, size: Tuple[int, int], main_source: str): """ :param [int, int] size: pixel size if the output - :param str main_source: The main glsl source with mainImage function + :param main_source: The main glsl source with mainImage function """ super().__init__(size, main_source) @@ -479,8 +479,8 @@ def create_from_file(cls, size: Tuple[int, int], path: Union[str, Path]) -> "Sha """ Create a Shadertoy from a mainImage shader file. - :param Tuple[int,int] size: Size of shadertoy in pixels - :param str path: Path to mainImage shader file + :param size: Size of shadertoy in pixels + :param path: Path to mainImage shader file """ path = arcade.resources.resolve(path) with open(path) as fd: @@ -491,8 +491,8 @@ def create_buffer(self, source: str, repeat: bool = False) -> ShadertoyBuffer: """ Shortcut for creating a buffer from mainImage shader file. - :param str source: Path to shader file - :param bool repeat: Buffer/texture repeat at borders + :param source: Path to shader file + :param repeat: Buffer/texture repeat at borders """ return ShadertoyBuffer(self._size, source, repeat=repeat) @@ -501,7 +501,7 @@ def create_buffer_from_file(self, path: Union[str, Path]) -> ShadertoyBuffer: Shortcut for creating a ShadertoyBuffer from shaders source. The size of the framebuffer will be the same as the Shadertoy. - :param str path: Path to shader source + :param path: Path to shader source """ path = arcade.resources.resolve(path) with open(path) as fd: @@ -512,7 +512,7 @@ def resize(self, size: Tuple[int, int]): """ Resize the internal buffers - :param Tuple[int,int] size: The new size in pixels + :param size: The new size in pixels """ self._size = size diff --git a/arcade/experimental/texture_render_target.py b/arcade/experimental/texture_render_target.py index 0da073d5f..4a26d7228 100644 --- a/arcade/experimental/texture_render_target.py +++ b/arcade/experimental/texture_render_target.py @@ -15,8 +15,8 @@ class RenderTargetTexture: def __init__(self, width: int, height: int): """Create a RenderTargetTexture. - :param int width: Width of the render target in pixels - :param int height: Height of the render target in pixels + :param width: Width of the render target in pixels + :param height: Height of the render target in pixels """ self.window = get_window() if not self.window: diff --git a/arcade/geometry.py b/arcade/geometry.py index e38e130aa..b04f16cd9 100644 --- a/arcade/geometry.py +++ b/arcade/geometry.py @@ -14,10 +14,9 @@ def are_polygons_intersecting(poly_a: PointList, poly_b: PointList) -> bool: """ Return True if two polygons intersect. - :param HitBox poly_a: List of points that define the first polygon. - :param HitBox poly_b: List of points that define the second polygon. + :param poly_a: List of points that define the first polygon. + :param poly_b: List of points that define the second polygon. :Returns: True or false depending if polygons intersect - :rtype bool: """ #if either are [], they don't intersect if not poly_a or not poly_b: @@ -61,9 +60,9 @@ def is_point_in_box(p: Point, q: Point, r: Point) -> bool: """ Return True if point q is inside the box defined by p and r. - :param Point p: Point 1 - :param Point q: Point 2 - :param Point r: Point 3 + :param p: Point 1 + :param q: Point 2 + :param r: Point 3 :Returns: True or false depending if points are collinear """ return ( @@ -84,9 +83,9 @@ def get_triangle_orientation(p: Point, q: Point, r: Point) -> int: * 1 --> Clockwise * 2 --> Counterclockwise - :param Point p: Point 1 - :param Point q: Point 2 - :param Point r: Point 3 + :param p: Point 1 + :param q: Point 2 + :param r: Point 3 :Returns: 0, 1, or 2 depending on orientation """ val = ((q[1] - p[1]) * (r[0] - q[0])) - ((q[0] - p[0]) * (r[1] - q[1])) @@ -104,10 +103,10 @@ def are_lines_intersecting(p1: Point, q1: Point, p2: Point, q2: Point) -> bool: Given two lines defined by points p1, q1 and p2, q2, the function returns true if the two lines intersect. - :param Point p1: Point 1 - :param Point q1: Point 2 - :param Point p2: Point 3 - :param Point q2: Point 4 + :param p1: Point 1 + :param q1: Point 2 + :param p2: Point 3 + :param q2: Point 4 :Returns: True or false depending if lines intersect """ o1 = get_triangle_orientation(p1, q1, p2) @@ -143,9 +142,9 @@ def is_point_in_polygon(x: float, y: float, polygon: PointList) -> bool: """ Checks if a point is inside a polygon of three or more points. - :param float x: X coordinate of point - :param float y: Y coordinate of point - :param PointList polygon_point_list: List of points that define the polygon. + :param x: X coordinate of point + :param y: Y coordinate of point + :param polygon_point_list: List of points that define the polygon. :Returns: True or false depending if point is inside polygon """ p = x, y diff --git a/arcade/gl/buffer.py b/arcade/gl/buffer.py index 2c90bb4bb..de7c37d70 100644 --- a/arcade/gl/buffer.py +++ b/arcade/gl/buffer.py @@ -29,12 +29,12 @@ class Buffer: .. warning:: Buffer objects should be created using :py:meth:`arcade.gl.Context.buffer` - :param Context ctx: The context this buffer belongs to - :param BufferProtocol data: The data this buffer should contain. + :param ctx: The context this buffer belongs to + :param data: The data this buffer should contain. It can be a ``bytes`` instance or any object supporting the buffer protocol. - :param int reserve: Create a buffer of a specific byte size - :param str usage: A hit of this buffer is ``static`` or ``dynamic`` (can mostly be ignored) + :param reserve: Create a buffer of a specific byte size + :param usage: A hit of this buffer is ``static`` or ``dynamic`` (can mostly be ignored) """ __slots__ = "_ctx", "_glo", "_size", "_usage", "__weakref__" @@ -140,9 +140,8 @@ def delete_glo(ctx: "Context", glo: gl.GLuint): def read(self, size: int = -1, offset: int = 0) -> bytes: """Read data from the buffer. - :param int size: The bytes to read. -1 means the entire buffer (default) - :param int offset: Byte read offset - :rtype: bytes + :param size: The bytes to read. -1 means the entire buffer (default) + :param offset: Byte read offset """ if size == -1: size = self._size - offset @@ -185,8 +184,8 @@ def write(self, data: BufferProtocol, offset: int = 0): truncated to fit. If the supplied data is smaller than the buffer, the remaining bytes will be left unchanged. - :param bytes data: The byte data to write. This can be bytes or any object supporting the buffer protocol. - :param int offset: The byte offset + :param data: The byte data to write. This can be bytes or any object supporting the buffer protocol. + :param offset: The byte offset """ gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._glo) size, data = data_to_ctypes(data) @@ -199,10 +198,10 @@ def write(self, data: BufferProtocol, offset: int = 0): def copy_from_buffer(self, source: "Buffer", size=-1, offset=0, source_offset=0): """Copy data into this buffer from another buffer - :param Buffer source: The buffer to copy from - :param int size: The amount of bytes to copy - :param int offset: The byte offset to write the data in this buffer - :param int source_offset: The byte offset to read from the source buffer + :param source: The buffer to copy from + :param size: The amount of bytes to copy + :param offset: The byte offset to write the data in this buffer + :param source_offset: The byte offset to read from the source buffer """ # Read the entire source buffer into this buffer if size == -1: @@ -233,8 +232,8 @@ def orphan(self, size: int = -1, double: bool = False): If the current buffer is busy in rendering operations it will be deallocated by OpenGL when completed. - :param int size: New size of buffer. -1 will retain the current size. - :param bool double: Is passed in with `True` the buffer size will be doubled + :param size: New size of buffer. -1 will retain the current size. + :param double: Is passed in with `True` the buffer size will be doubled """ if size > -1: self._size = size @@ -249,9 +248,9 @@ def bind_to_uniform_block(self, binding: int = 0, offset: int = 0, size: int = - """Bind this buffer to a uniform block location. In most cases it will be sufficient to only provide a binding location. - :param int binding: The binding location - :param int offset: byte offset - :param int size: size of the buffer to bind. + :param binding: The binding location + :param offset: byte offset + :param size: size of the buffer to bind. """ if size < 0: size = self.size @@ -262,9 +261,9 @@ def bind_to_storage_buffer(self, *, binding=0, offset=0, size=-1): """ Bind this buffer as a shader storage buffer. - :param int binding: The binding location - :param int offset: Byte offset in the buffer - :param int size: The size in bytes. The entire buffer will be mapped by default. + :param binding: The binding location + :param offset: Byte offset in the buffer + :param size: The size in bytes. The entire buffer will be mapped by default. """ if size < 0: size = self.size diff --git a/arcade/gl/compute_shader.py b/arcade/gl/compute_shader.py index 2bedc4487..5bb556081 100644 --- a/arcade/gl/compute_shader.py +++ b/arcade/gl/compute_shader.py @@ -117,9 +117,9 @@ def run(self, group_x=1, group_y=1, group_z=1) -> None: a size for a dimension or uses ``1`` as size you don't have to supply this parameter. - :param int group_x: The number of work groups to be launched in the X dimension. - :param int group_y: The number of work groups to be launched in the y dimension. - :param int group_z: The number of work groups to be launched in the z dimension. + :param group_x: The number of work groups to be launched in the X dimension. + :param group_y: The number of work groups to be launched in the y dimension. + :param group_z: The number of work groups to be launched in the z dimension. """ self.use() gl.glDispatchCompute(group_x, group_y, group_z) diff --git a/arcade/gl/context.py b/arcade/gl/context.py index 7e15c6d98..a20979007 100644 --- a/arcade/gl/context.py +++ b/arcade/gl/context.py @@ -335,7 +335,6 @@ def gc(self) -> int: This is only needed when ``gc_mode`` is ``context_gc``. :return: The number of resources destroyed - :rtype: int """ # Loop the array until all objects are gone. # Deleting one object might add new ones so we need @@ -790,8 +789,8 @@ def copy_framebuffer(self, src: Framebuffer, dst: Framebuffer): * Only the source framebuffer can be multisampled * Framebuffers cannot have integer attachments - :param Framebuffer src: The framebuffer to copy from - :param Framebuffer dst: The framebuffer we copy to + :param src: The framebuffer to copy from + :param dst: The framebuffer we copy to """ gl.glBindFramebuffer(gl.GL_READ_FRAMEBUFFER, src._glo) gl.glBindFramebuffer(gl.GL_DRAW_FRAMEBUFFER, dst._glo) @@ -844,11 +843,10 @@ def buffer( dynamic The data contents will be modified repeatedly and used many times. - :param BufferProtocol data: The buffer data. This can be a ``bytes`` instance or any + :param data: The buffer data. This can be a ``bytes`` instance or any any other object supporting the buffer protocol. - :param int reserve: The number of bytes to reserve - :param str usage: Buffer usage. 'static', 'dynamic' or 'stream' - :rtype: :py:class:`~arcade.gl.Buffer` + :param reserve: The number of bytes to reserve + :param usage: Buffer usage. 'static', 'dynamic' or 'stream' """ return Buffer(self, data, reserve=reserve, usage=usage) @@ -860,9 +858,8 @@ def framebuffer( ) -> Framebuffer: """Create a Framebuffer. - :param List[arcade.gl.Texture] color_attachments: List of textures we want to render into - :param arcade.gl.Texture depth_attachment: Depth texture - :rtype: :py:class:`~arcade.gl.Framebuffer` + :param color_attachments: List of textures we want to render into + :param depth_attachment: Depth texture """ return Framebuffer( self, color_attachments=color_attachments, depth_attachment=depth_attachment @@ -891,15 +888,15 @@ def texture( Magnifying filters: ``GL_NEAREST``, ``GL_LINEAR`` :param Tuple[int, int] size: The size of the texture - :param int components: Number of components (1: R, 2: RG, 3: RGB, 4: RGBA) - :param str dtype: The data type of each component: f1, f2, f4 / i1, i2, i4 / u1, u2, u4 - :param BufferProtocol data: The texture data (optional). Can be ``bytes`` + :param components: Number of components (1: R, 2: RG, 3: RGB, 4: RGBA) + :param dtype: The data type of each component: f1, f2, f4 / i1, i2, i4 / u1, u2, u4 + :param data: The texture data (optional). Can be ``bytes`` or any object supporting the buffer protocol. - :param GLenum wrap_x: How the texture wraps in x direction - :param GLenum wrap_y: How the texture wraps in y direction - :param Tuple[GLenum,GLenum] filter: Minification and magnification filter - :param int samples: Creates a multisampled texture for values > 0 - :param bool immutable: Make the storage (not the contents) immutable. This can sometimes be + :param wrap_x: How the texture wraps in x direction + :param wrap_y: How the texture wraps in y direction + :param filter: Minification and magnification filter + :param samples: Creates a multisampled texture for values > 0 + :param immutable: Make the storage (not the contents) immutable. This can sometimes be required when using textures with compute shaders. """ return Texture2D( @@ -921,7 +918,7 @@ def depth_texture(self, size: Tuple[int, int], *, data: Optional[BufferProtocol] in a :py:class:`~arcade.gl.Framebuffer`. :param Tuple[int, int] size: The size of the texture - :param BufferProtocol data: The texture data (optional). Can be + :param data: The texture data (optional). Can be ``bytes`` or any object supporting the buffer protocol. """ @@ -996,11 +993,11 @@ def geometry( mode=ctx.POINTS, ) - :param list content: List of :py:class:`~arcade.gl.BufferDescription` (optional) - :param Buffer index_buffer: Index/element buffer (optional) - :param int mode: The default draw mode (optional) - :param int mode: The default draw mode (optional) - :param int index_element_size: Byte size of a single index/element in the index buffer. + :param content: List of :py:class:`~arcade.gl.BufferDescription` (optional) + :param index_buffer: Index/element buffer (optional) + :param mode: The default draw mode (optional) + :param mode: The default draw mode (optional) + :param index_element_size: Byte size of a single index/element in the index buffer. In other words, the index buffer can be 8, 16 or 32 bit integers. Can be 1, 2 or 4 (8, 16 or 32 bit unsigned integer) """ @@ -1027,22 +1024,21 @@ def program( ) -> Program: """Create a :py:class:`~arcade.gl.Program` given the vertex, fragment and geometry shader. - :param str vertex_shader: vertex shader source - :param str fragment_shader: fragment shader source (optional) - :param str geometry_shader: geometry shader source (optional) - :param str tess_control_shader: tessellation control shader source (optional) - :param str tess_evaluation_shader: tessellation evaluation shader source (optional) - :param list common: Common shader sources injected into all shaders - :param dict defines: Substitute #defines values in the source (optional) - :param Optional[Sequence[str]] varyings: The name of the out attributes in a transform shader. + :param vertex_shader: vertex shader source + :param fragment_shader: fragment shader source (optional) + :param geometry_shader: geometry shader source (optional) + :param tess_control_shader: tessellation control shader source (optional) + :param tess_evaluation_shader: tessellation evaluation shader source (optional) + :param common: Common shader sources injected into all shaders + :param defines: Substitute #defines values in the source (optional) + :param varyings: The name of the out attributes in a transform shader. This is normally not necessary since we auto detect them, but some more complex out structures we can't detect. - :param str varyings_capture_mode: The capture mode for transforms. + :param varyings_capture_mode: The capture mode for transforms. ``"interleaved"`` means all out attribute will be written to a single buffer. ``"separate"`` means each out attribute will be written separate buffers. Based on these settings the `transform()` method will accept a single buffer or a list of buffer. - :rtype: :py:class:`~arcade.gl.Program` """ source_vs = ShaderSource(self, vertex_shader, common, gl.GL_VERTEX_SHADER) source_fs = ( @@ -1098,11 +1094,10 @@ def query(self, *, samples=True, time=True, primitives=True) -> Query: """ Create a query object for measuring rendering calls in opengl. - :param bool samples: Collect written samples - :param bool time: Measure rendering duration - :param bool primitives: Collect the number of primitives emitted + :param samples: Collect written samples + :param time: Measure rendering duration + :param primitives: Collect the number of primitives emitted - :rtype: :py:class:`~arcade.gl.Query` """ return Query(self, samples=samples, time=time, primitives=primitives) @@ -1110,8 +1105,8 @@ def compute_shader(self, *, source: str, common: Iterable[str] = ()) -> ComputeS """ Create a compute shader. - :param str source: The glsl source - :param Iterable[str] common: Common / library source injected into compute shader + :param source: The glsl source + :param common: Common / library source injected into compute shader """ src = ShaderSource(self, source, common, gl.GL_COMPUTE_SHADER) return ComputeShader(self, src.get_source()) @@ -1144,7 +1139,7 @@ def incr(self, key: str) -> None: """ Increments a counter. - :param str key: The attribute name / counter to increment. + :param key: The attribute name / counter to increment. """ created, freed = getattr(self, key) setattr(self, key, (created + 1, freed)) @@ -1162,7 +1157,7 @@ def decr(self, key): """ Decrement a counter. - :param str key: The attribute name / counter to decrement. + :param key: The attribute name / counter to decrement. """ created, freed = getattr(self, key) setattr(self, key, (created, freed + 1)) diff --git a/arcade/gl/framebuffer.py b/arcade/gl/framebuffer.py index 714fc71bb..6a4744e92 100644 --- a/arcade/gl/framebuffer.py +++ b/arcade/gl/framebuffer.py @@ -39,9 +39,9 @@ class Framebuffer: ] ) - :param Context ctx: The context this framebuffer belongs to - :param List[arcade.gl.Texture] color_attachments: List of color attachments. - :param arcade.gl.Texture depth_attachment: A depth attachment (optional) + :param ctx: The context this framebuffer belongs to + :param color_attachments: List of color attachments. + :param depth_attachment: A depth attachment (optional) """ #: Is this the default framebuffer? (window buffer) @@ -321,7 +321,7 @@ def activate(self): def use(self, *, force: bool = False): """Bind the framebuffer making it the target of all rendering commands - :param bool force: Force the framebuffer binding even if the system + :param force: Force the framebuffer binding even if the system already believes it's already bound. """ self._use(force=force) @@ -366,9 +366,9 @@ def clear( If the background color is an ``RGB`` value instead of ``RGBA``` we assume alpha value 255. - :param tuple color: A 3 or 4 component tuple containing the color - :param float depth: Value to clear the depth buffer (unused) - :param bool normalized: If the color values are normalized or not + :param color: A 3 or 4 component tuple containing the color + :param depth: Value to clear the depth buffer (unused) + :param normalized: If the color values are normalized or not :param Tuple[int, int, int, int] viewport: The viewport range to clear """ with self.activate(): @@ -409,10 +409,10 @@ def read( """ Read framebuffer pixels - :param Tuple[int,int,int,int] viewport: The x, y, with, height to read - :param int components: - :param int attachment: The attachment id to read from - :param str dtype: The data type to read + :param viewport: The x, y, with, height to read + :param components: + :param attachment: The attachment id to read from + :param dtype: The data type to read :return: pixel data as a bytearray """ # TODO: use texture attachment info to determine read format? diff --git a/arcade/gl/geometry.py b/arcade/gl/geometry.py index 941009c91..0bc84bbf5 100644 --- a/arcade/gl/geometry.py +++ b/arcade/gl/geometry.py @@ -27,9 +27,8 @@ def quad_2d(size: Tuple[float, float] = (1.0, 1.0), pos: Tuple[float, float] = ( """ Creates 2D quad Geometry using 2 triangle strip with texture coordinates. - :param tuple size: width and height - :param float pos: Center position x and y - :rtype: A :py:class:`~arcade.gl.geometry.Geometry` instance. + :param size: width and height + :param pos: Center position x and y """ ctx = _get_active_context() width, height = size @@ -53,10 +52,10 @@ def screen_rectangle(bottom_left_x: float, bottom_left_y: float, width: float, h """ Creates screen rectangle using 2 triangle strip with texture coordinates. - :param float bottom_left_x: Bottom left x position - :param float bottom_left_y: Bottom left y position - :param float width: Width of the rectangle - :param float height: Height of the rectangle + :param bottom_left_x: Bottom left x position + :param bottom_left_y: Bottom left y position + :param width: Width of the rectangle + :param height: Height of the rectangle """ ctx = _get_active_context() data = array('f', [ @@ -78,9 +77,8 @@ def cube( ) -> Geometry: """Creates a cube with normals and texture coordinates. - :param tuple size: size of the cube as a 3-component tuple - :param tuple center: center of the cube as a 3-component tuple - :rtype: arcade.gl.Geometry + :param size: size of the cube as a 3-component tuple + :param center: center of the cube as a 3-component tuple :returns: A cube """ ctx = _get_active_context() @@ -221,11 +219,11 @@ def sphere( """ Creates a 3D sphere. - :param float radius: Radius or the sphere - :param int rings: number or horizontal rings - :param int sectors: number of vertical segments - :param bool normals: Include normals in the VAO - :param bool uvs: Include texture coordinates in the VAO + :param radius: Radius or the sphere + :param rings: number or horizontal rings + :param sectors: number of vertical segments + :param normals: Include normals in the VAO + :param uvs: Include texture coordinates in the VAO :return: A geometry object """ ctx = _get_active_context() diff --git a/arcade/gl/glsl.py b/arcade/gl/glsl.py index 9388d84e2..b8b14f2db 100644 --- a/arcade/gl/glsl.py +++ b/arcade/gl/glsl.py @@ -24,11 +24,11 @@ class ShaderSource: NOTE: We do assume the source is neat enough to be parsed this way and don't contain several statements on one line. - :param Context ctx: The context this framebuffer belongs to - :param str source: The source code + :param ctx: The context this framebuffer belongs to + :param source: The source code :common List[str] common: Common source code to inject - :param int source_type: The shader type - :param arcade.gl.Texture depth_attachment: A depth attachment (optional) + :param source_type: The shader type + :param depth_attachment: A depth attachment (optional) """ def __init__( self, @@ -97,7 +97,7 @@ def inject_common_sources(self, common: Optional[Iterable[str]]) -> None: def get_source(self, *, defines: Optional[Dict[str, str]] = None) -> str: """Return the shader source - :param dict defines: Defines to replace in the source. + :param defines: Defines to replace in the source. """ if not defines: return "\n".join(self._lines) @@ -129,8 +129,8 @@ def _find_glsl_version(self) -> int: def apply_defines(lines: List[str], defines: Dict[str, str]) -> List[str]: """Locate and apply #define values - :param List[str] lines: List of source lines - :param dict defines: dict with ``name: value`` pairs. + :param lines: List of source lines + :param defines: dict with ``name: value`` pairs. """ for nr, line in enumerate(lines): line = line.strip() diff --git a/arcade/gl/program.py b/arcade/gl/program.py index dd8cc8fa2..3b8ca7777 100644 --- a/arcade/gl/program.py +++ b/arcade/gl/program.py @@ -40,14 +40,14 @@ class Program: program['MyUniform'] = value - :param Context ctx: The context this program belongs to - :param str vertex_shader: vertex shader source - :param str fragment_shader: fragment shader source - :param str geometry_shader: geometry shader source - :param str tess_control_shader: tessellation control shader source - :param str tess_evaluation_shader: tessellation evaluation shader source - :param List[str] varyings: List of out attributes used in transform feedback. - :param str varyings_capture_mode: The capture mode for transforms. + :param ctx: The context this program belongs to + :param vertex_shader: vertex shader source + :param fragment_shader: fragment shader source + :param geometry_shader: geometry shader source + :param tess_control_shader: tessellation control shader source + :param tess_evaluation_shader: tessellation evaluation shader source + :param varyings: List of out attributes used in transform feedback. + :param varyings_capture_mode: The capture mode for transforms. ``"interleaved"`` means all out attribute will be written to a single buffer. ``"separate"`` means each out attribute will be written separate buffers. Based on these settings the `transform()` method will accept a single @@ -299,8 +299,8 @@ def set_uniform_safe(self, name: str, value: Any): """ Safely set a uniform catching KeyError. - :param str name: The uniform name - :param Any value: The uniform value + :param name: The uniform name + :param value: The uniform value """ try: self[name] = value @@ -315,8 +315,8 @@ def set_uniform_array_safe(self, name: str, value: List[Any]): actual array and sets a subset of the values if needed. If the uniform don't exist no action will be done. - :param str name: Name of uniform - :param List[Any] value: List of values + :param name: Name of uniform + :param value: List of values """ if name not in self._uniforms: return diff --git a/arcade/gl/texture.py b/arcade/gl/texture.py index 234b1d6fa..437818cd1 100644 --- a/arcade/gl/texture.py +++ b/arcade/gl/texture.py @@ -39,20 +39,20 @@ class Texture2D: 'u2': UNSIGNED_SHORT 'u4': UNSIGNED_INT - :param Context ctx: The context the object belongs to + :param ctx: The context the object belongs to :param Tuple[int, int] size: The size of the texture - :param int components: The number of components (1: R, 2: RG, 3: RGB, 4: RGBA) - :param str dtype: The data type of each component: f1, f2, f4 / i1, i2, i4 / u1, u2, u4 - :param BufferProtocol data: The texture data (optional). Can be bytes or any object supporting the buffer protocol. - :param Tuple[gl.GLuint,gl.GLuint] filter: The minification/magnification filter of the texture - :param gl.GLuint wrap_x: Wrap mode x - :param gl.GLuint wrap_y: Wrap mode y - :param int target: The texture type (Ignored. Legacy) - :param bool depth: creates a depth texture if `True` - :param int samples: Creates a multisampled texture for values > 0. + :param components: The number of components (1: R, 2: RG, 3: RGB, 4: RGBA) + :param dtype: The data type of each component: f1, f2, f4 / i1, i2, i4 / u1, u2, u4 + :param data: The texture data (optional). Can be bytes or any object supporting the buffer protocol. + :param filter: The minification/magnification filter of the texture + :param wrap_x: Wrap mode x + :param wrap_y: Wrap mode y + :param target: The texture type (Ignored. Legacy) + :param depth: creates a depth texture if `True` + :param samples: Creates a multisampled texture for values > 0. This value will be clamped between 0 and the max sample capability reported by the drivers. - :param bool immutable: Make the storage (not the contents) immutable. This can sometimes be + :param immutable: Make the storage (not the contents) immutable. This can sometimes be required when using textures with compute shaders. """ @@ -624,9 +624,8 @@ def read(self, level: int = 0, alignment: int = 1) -> bytes: """ Read the contents of the texture. - :param int level: The texture level to read - :param int alignment: Alignment of the start of each row in memory in number of bytes. Possible values: 1,2,4 - :rtype: bytearray + :param level: The texture level to read + :param alignment: Alignment of the start of each row in memory in number of bytes. Possible values: 1,2,4 """ if self._samples > 0: raise ValueError("Multisampled textures cannot be read directly") @@ -661,10 +660,10 @@ def write(self, data: BufferOrBufferProtocol, level: int = 0, viewport=None) -> :ref:`prog-guide-gl-buffer-protocol-typing` for more information. - :param BufferOrBufferProtocol data: :class:`~arcade.gl.Buffer` or + :param data: :class:`~arcade.gl.Buffer` or buffer protocol object with data to write. - :param int level: The texture level to write + :param level: The texture level to write :param Union[Tuple[int, int], Tuple[int, int, int, int]] viewport: The area of the texture to write. 2 or 4 component tuple """ @@ -742,8 +741,8 @@ def build_mipmaps(self, base: int = 0, max_level: int = 1000) -> None: # Set up linear interpolating minification filter texture.filter = ctx.LINEAR_MIPMAP_LINEAR, ctx.LINEAR - :param int base: Level the mipmaps start at (usually 0) - :param int max_level: The maximum number of levels to generate + :param base: Level the mipmaps start at (usually 0) + :param max_level: The maximum number of levels to generate Also see: https://www.khronos.org/opengl/wiki/Texture#Mip_maps """ @@ -770,8 +769,8 @@ def delete_glo(ctx: "Context", glo: gl.GLuint): Destroy the texture. This is called automatically when the object is garbage collected. - :param arcade.gl.Context ctx: OpenGL Context - :param gl.GLuint glo: The OpenGL texture id + :param ctx: OpenGL Context + :param glo: The OpenGL texture id """ # If we have no context, then we are shutting down, so skip this if gl.current_context is None: @@ -785,7 +784,7 @@ def delete_glo(ctx: "Context", glo: gl.GLuint): def use(self, unit: int = 0) -> None: """Bind the texture to a channel, - :param int unit: The texture unit to bind the texture. + :param unit: The texture unit to bind the texture. """ gl.glActiveTexture(gl.GL_TEXTURE0 + unit) gl.glBindTexture(self._target, self._glo) @@ -797,10 +796,10 @@ def bind_to_image(self, unit: int, read: bool = True, write: bool = True, level: Note that either or both ``read`` and ``write`` needs to be ``True``. The supported modes are: read only, write only, read-write - :param int unit: The image unit - :param bool read: The compute shader intends to read from this image - :param bool write: The compute shader intends to write to this image - :param int level: + :param unit: The image unit + :param read: The compute shader intends to read from this image + :param write: The compute shader intends to write to this image + :param level: """ if self._ctx.gl_api == "gles" and not self._immutable: raise ValueError("Textures bound to image units must be created with immutable=True") diff --git a/arcade/gl/types.py b/arcade/gl/types.py index 2ca225c25..158d38c3e 100644 --- a/arcade/gl/types.py +++ b/arcade/gl/types.py @@ -119,11 +119,11 @@ class AttribFormat: """" Represents an attribute in a BufferDescription or a Program. - :param str name: Name of the attribute - :param GLenumLike gl_type: The OpenGL type such as GL_FLOAT, GL_HALF_FLOAT etc. - :param int bytes_per_component: Number of bytes a single component takes - :param int offset: (Optional offset for BufferDescription) - :param int location: (Optional location for program attribute) + :param name: Name of the attribute + :param gl_type: The OpenGL type such as GL_FLOAT, GL_HALF_FLOAT etc. + :param bytes_per_component: Number of bytes a single component takes + :param offset: (Optional offset for BufferDescription) + :param location: (Optional location for program attribute) """ __slots__ = ( @@ -188,11 +188,11 @@ class BufferDescription: ['in_pos', 'in_uv'], ) - :param Buffer buffer: The buffer to describe - :param str formats: The format of each attribute - :param list attributes: List of attributes names (strings) - :param list normalized: list of attribute names that should be normalized - :param bool instanced: ``True`` if this is per instance data + :param buffer: The buffer to describe + :param formats: The format of each attribute + :param attributes: List of attributes names (strings) + :param normalized: list of attribute names that should be normalized + :param instanced: ``True`` if this is per instance data """ # Describe all variants of a format string to simplify parsing (single component) diff --git a/arcade/gl/vertex_array.py b/arcade/gl/vertex_array.py index c468bc150..b3af1cb57 100644 --- a/arcade/gl/vertex_array.py +++ b/arcade/gl/vertex_array.py @@ -245,10 +245,10 @@ def render( ): """Render the VertexArray to the currently active framebuffer. - :param GLuint mode: Primitive type to render. TRIANGLES, LINES etc. - :param int first: The first vertex to render from - :param int vertices: Number of vertices to render - :param int instances: OpenGL instance, used in using vertices over and over + :param mode: Primitive type to render. TRIANGLES, LINES etc. + :param first: The first vertex to render from + :param vertices: Number of vertices to render + :param instances: OpenGL instance, used in using vertices over and over """ gl.glBindVertexArray(self.glo) if self._ibo is not None: @@ -267,11 +267,11 @@ def render_indirect(self, buffer: Buffer, mode: GLuintLike, count, first, stride .. Warning:: This requires OpenGL 4.3 - :param Buffer buffer: The buffer containing one or multiple draw parameters - :param GLuint mode: Primitive type to render. TRIANGLES, LINES etc. - :param int count: The number if indirect draw calls to run - :param int first: The first indirect draw call to start on - :param int stride: The byte stride of the draw command buffer. + :param buffer: The buffer containing one or multiple draw parameters + :param mode: Primitive type to render. TRIANGLES, LINES etc. + :param count: The number if indirect draw calls to run + :param first: The first indirect draw call to start on + :param stride: The byte stride of the draw command buffer. Keep the default (0) if the buffer is tightly packed. """ # The default buffer stride for array and indexed @@ -311,13 +311,13 @@ def transform_interleaved( ): """Run a transform feedback. - :param Buffer buffer: The buffer to write the output - :param GLenumLike mode: The input primitive mode - :param GLenumLike output_mode: The output primitive mode - :param int first: Offset start vertex - :param int vertices: Number of vertices to render - :param int instances: Number of instances to render - :param int buffer_offset: Byte offset for the buffer (target) + :param buffer: The buffer to write the output + :param mode: The input primitive mode + :param output_mode: The output primitive mode + :param first: Offset start vertex + :param vertices: Number of vertices to render + :param instances: Number of instances to render + :param buffer_offset: Byte offset for the buffer (target) """ if vertices < 0: raise ValueError(f"Cannot determine the number of vertices: {vertices}") @@ -367,13 +367,13 @@ def transform_separate( """ Run a transform feedback writing to separate buffers. - :param List[Buffer] buffers: The buffers to write the output - :param GLenumLike mode: The input primitive mode - :param GLenumLike output_mode: The output primitive mode - :param int first: Offset start vertex - :param int vertices: Number of vertices to render - :param int instances: Number of instances to render - :param int buffer_offset: Byte offset for the buffer (target) + :param buffers: The buffers to write the output + :param mode: The input primitive mode + :param output_mode: The output primitive mode + :param first: Offset start vertex + :param vertices: Number of vertices to render + :param instances: Number of instances to render + :param buffer_offset: Byte offset for the buffer (target) """ if vertices < 0: raise ValueError(f"Cannot determine the number of vertices: {vertices}") @@ -423,10 +423,10 @@ class Geometry: Geometry objects should be created through :py:meth:`arcade.gl.Context.geometry` - :param Context ctx: The context this object belongs to - :param list content: List of BufferDescriptions - :param Buffer index_buffer: Index/element buffer - :param int mode: The default draw mode + :param ctx: The context this object belongs to + :param content: List of BufferDescriptions + :param index_buffer: Index/element buffer + :param mode: The default draw mode """ __slots__ = ( @@ -456,11 +456,11 @@ def __init__( self._vao_cache: Dict[str, VertexArray] = {} self._num_vertices: int = -1 """ - :param Context ctx: The context this object belongs to - :param list content: (optional) List of BufferDescriptions - :param Buffer index_buffer: (optional) Index/element buffer - :param int mode: (optional) The default draw mode - :param int index_element_size: Byte size of the index buffer datatype. Can be 1, 2 or 4 (8, 16 or 32bit integer) + :param ctx: The context this object belongs to + :param content: (optional) List of BufferDescriptions + :param index_buffer: (optional) Index/element buffer + :param mode: (optional) The default draw mode + :param index_element_size: Byte size of the index buffer datatype. Can be 1, 2 or 4 (8, 16 or 32bit integer) """ if self._index_buffer and self._index_element_size not in (1, 2, 4): raise ValueError("index_element_size must be 1, 2, or 4") @@ -550,11 +550,11 @@ def render( so overriding vertices is not needed unless you have a special case or have resized the buffers after the geometry instance was created. - :param Program program: The Program to render with - :param GLenumLike mode: Override what primitive mode should be used - :param int first: Offset start vertex - :param int vertices: Override the number of vertices to render - :param int instances: Number of instances to render + :param program: The Program to render with + :param mode: Override what primitive mode should be used + :param first: Offset start vertex + :param vertices: Override the number of vertices to render + :param instances: Number of instances to render """ program.use() vao = self.instance(program) @@ -628,13 +628,13 @@ def render_indirect( in the buffer. By default we assume this is 16 for array rendering (no index buffer) and 20 for indexed rendering (with index buffer) - :param Program program: The program to execute - :param Buffer buffer: The buffer containing one or multiple draw parameters - :param GLuint mode: Primitive type to render. TRIANGLES, LINES etc. - :param int count: The number if indirect draw calls to run. + :param program: The program to execute + :param buffer: The buffer containing one or multiple draw parameters + :param mode: Primitive type to render. TRIANGLES, LINES etc. + :param count: The number if indirect draw calls to run. If omitted all draw commands in the buffer will be executed. - :param int first: The first indirect draw call to start on - :param int stride: The byte stride of the draw command buffer. + :param first: The first indirect draw call to start on + :param stride: The byte stride of the draw command buffer. Keep the default (0) if the buffer is tightly packed. """ program.use() @@ -658,14 +658,14 @@ def transform( If a geometry shader is used the output primitive mode is automatically detected. - :param Program program: The Program to render with + :param program: The Program to render with :param Union[Buffer, Sequence[Buffer]] buffer: The buffer(s) we transform into. This depends on the programs ``varyings_capture_mode``. We can transform into one buffer interlaved or transform each attribute into separate buffers. - :param int first: Offset start vertex - :param int vertices: Number of vertices to render - :param int instances: Number of instances to render - :param int buffer_offset: Byte offset for the buffer + :param first: Offset start vertex + :param vertices: Number of vertices to render + :param instances: Number of instances to render + :param buffer_offset: Byte offset for the buffer """ program.use() vao = self.instance(program) diff --git a/arcade/gui/constructs.py b/arcade/gui/constructs.py index 3e24def5b..cf8885567 100644 --- a/arcade/gui/constructs.py +++ b/arcade/gui/constructs.py @@ -101,15 +101,15 @@ def on_action(self, event: UIOnActionEvent): class UIButtonRow(UIBoxLayout): """ Places buttons in a row. - :param bool vertical: Whether the button row is vertical or not. - :param str align: Where to align the button row. - :param Any size_hint: Tuple of floats (0.0 - 1.0) of how much space of the parent should be requested. + :param vertical: Whether the button row is vertical or not. + :param align: Where to align the button row. + :param size_hint: Tuple of floats (0.0 - 1.0) of how much space of the parent should be requested. :param size_hint_min: Min width and height in pixel. :param size_hint_max: Max width and height in pixel. - :param int space_between: The space between the children. - :param Any style: Not used. + :param space_between: The space between the children. + :param style: Not used. :param Tuple[str, ...] button_labels: The labels for the buttons. - :param Callable callback: The callback function which will receive the text of the clicked button. + :param callback: The callback function which will receive the text of the clicked button. """ def __init__( diff --git a/arcade/gui/events.py b/arcade/gui/events.py index 3b134e4d4..00b885195 100644 --- a/arcade/gui/events.py +++ b/arcade/gui/events.py @@ -133,7 +133,7 @@ class UIOnActionEvent(UIEvent): """ Notification about an action - :param Any action: Value describing the action, mostly a string + :param action: Value describing the action, mostly a string """ action: Any diff --git a/arcade/gui/nine_patch.py b/arcade/gui/nine_patch.py index bd2328e90..e1d75ef69 100644 --- a/arcade/gui/nine_patch.py +++ b/arcade/gui/nine_patch.py @@ -54,16 +54,16 @@ class NinePatchTexture: * Areas ``(2)`` and ``(8)`` only stretch horizontally. * Areas ``(4)`` and ``(6)`` only stretch vertically. - :param int left: The width of the left border of the 9-patch + :param left: The width of the left border of the 9-patch (in pixels) - :param int right: The width of the right border of the 9-patch + :param right: The width of the right border of the 9-patch (in pixels) - :param int bottom: The height of the bottom border of the 9-patch + :param bottom: The height of the bottom border of the 9-patch (in pixels) - :param int top: The height of the top border of the 9-patch + :param top: The height of the top border of the 9-patch (in pixels) - :param Texture texture: The raw texture to use for the 9-patch - :param TextureAtlas atlas: Specify an atlas other than arcade's default + :param texture: The raw texture to use for the 9-patch + :param atlas: Specify an atlas other than arcade's default texture atlas """ diff --git a/arcade/gui/surface.py b/arcade/gui/surface.py index 19f69608f..1141a3fc0 100644 --- a/arcade/gui/surface.py +++ b/arcade/gui/surface.py @@ -168,7 +168,7 @@ def draw( The surface will be rendered at the configured ``position`` and limited by the given ``area``. The area can be out of bounds. - :param Optional[Rect] area: Limit the area in the surface we're drawing (x, y, w, h) + :param area: Limit the area in the surface we're drawing (x, y, w, h) """ # Set blend function blend_func = self.ctx.blend_func @@ -187,8 +187,8 @@ def resize(self, *, size: Tuple[int, int], pixel_ratio: float) -> None: """ Resize the internal texture by re-allocating a new one - :param Tuple[int,int] size: The new size in pixels (xy) - :param float pixel_ratio: The pixel scale of the window + :param size: The new size in pixels (xy) + :param pixel_ratio: The pixel scale of the window """ # Texture re-allocation is expensive so we should block unnecessary calls. if self._size == size and self._pixel_ratio == pixel_ratio: diff --git a/arcade/gui/ui_manager.py b/arcade/gui/ui_manager.py index 1e210d522..1cb78f19f 100644 --- a/arcade/gui/ui_manager.py +++ b/arcade/gui/ui_manager.py @@ -123,7 +123,7 @@ def remove(self, child: UIWidget): """ Removes the given widget from UIManager. - :param UIWidget child: widget to remove + :param child: widget to remove """ for children in self.children.values(): if child in children: diff --git a/arcade/gui/widgets/__init__.py b/arcade/gui/widgets/__init__.py index af821900b..d40fcc9eb 100644 --- a/arcade/gui/widgets/__init__.py +++ b/arcade/gui/widgets/__init__.py @@ -209,8 +209,8 @@ class UIWidget(EventDispatcher, ABC): change the position or the size of its children. If you want control over positioning or sizing, use a :class:`~arcade.gui.UILayout`. - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left :param width: width of widget :param height: height of widget :param size_hint: Tuple of floats (0.0-1.0), how much space of the parent should be requested @@ -577,8 +577,8 @@ def with_background( A color or texture can be used for background, if a texture is given, start and end point can be added to use the texture as ninepatch. - :param RGBA255 color: A color used as background - :param arcade.Texture texture: A texture or ninepatch texture used as background + :param color: A color used as background + :param texture: A texture or ninepatch texture used as background :return: self """ if color is not ...: @@ -647,8 +647,8 @@ class UIInteractiveWidget(UIWidget): """ Base class for widgets which use mouse interaction (hover, pressed, clicked) - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left :param width: width of widget :param height: height of widget :param size_hint: Tuple of floats (0.0-1.0), how much space of the parent should be requested @@ -731,8 +731,8 @@ class UIDummy(UIInteractiveWidget): * Outputs its `rect` attribute to the console * Changes its color to a random fully opaque color - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left :param color: fill color for the widget :param width: width of widget :param height: height of widget @@ -797,8 +797,8 @@ def do_render(self, surface: Surface): class UISpriteWidget(UIWidget): """Create a UI element with a sprite that controls what is displayed. - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left :param width: width of widget :param height: height of widget :param sprite: Sprite to embed in gui @@ -849,8 +849,8 @@ class UILayout(UIWidget): """ Base class for widgets, which position themselves or their children. - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left :param width: width of widget :param height: height of widget :param children: Child widgets of this group @@ -882,8 +882,8 @@ class UISpace(UIWidget): """ Widget reserving space, can also have a background color. - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left :param width: width of widget :param height: height of widget :param color: Color for widget area diff --git a/arcade/gui/widgets/buttons.py b/arcade/gui/widgets/buttons.py index a0d790df1..ffb063e9b 100644 --- a/arcade/gui/widgets/buttons.py +++ b/arcade/gui/widgets/buttons.py @@ -34,17 +34,17 @@ class UITextureButton(UIInteractiveWidget, UIStyledWidget[UITextureButtonStyle], There are four states of the UITextureButton i.e normal, hovered, pressed and disabled. - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left - :param float width: width of widget. Defaults to texture width if not specified. - :param float height: height of widget. Defaults to texture height if not specified. - :param Texture texture: texture to display for the widget. - :param Texture texture_hovered: different texture to display if mouse is hovering over button. - :param Texture texture_pressed: different texture to display if mouse button is pressed while hovering over button. - :param str text: text to add to the button. - :param bool multiline: allows to wrap text, if not enough width available + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left + :param width: width of widget. Defaults to texture width if not specified. + :param height: height of widget. Defaults to texture height if not specified. + :param texture: texture to display for the widget. + :param texture_hovered: different texture to display if mouse is hovering over button. + :param texture_pressed: different texture to display if mouse button is pressed while hovering over button. + :param text: text to add to the button. + :param multiline: allows to wrap text, if not enough width available :param style: Used to style the button for different states. - :param float scale: scale the button, based on the base texture size. + :param scale: scale the button, based on the base texture size. :param size_hint: Tuple of floats (0.0-1.0), how much space of the parent should be requested :param size_hint_min: min width and height in pixel :param size_hint_max: max width and height in pixel @@ -226,12 +226,12 @@ class UIFlatButton(UIInteractiveWidget, UIStyledWidget, UITextWidget): There are four states of the UITextureButton i.e normal, hovered, pressed and disabled. - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left - :param float width: width of widget. Defaults to texture width if not specified. - :param float height: height of widget. Defaults to texture height if not specified. - :param str text: text to add to the button. - :param bool multiline: allows to wrap text, if not enough width available + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left + :param width: width of widget. Defaults to texture width if not specified. + :param height: height of widget. Defaults to texture height if not specified. + :param text: text to add to the button. + :param multiline: allows to wrap text, if not enough width available :param style: Used to style the button """ diff --git a/arcade/gui/widgets/dropdown.py b/arcade/gui/widgets/dropdown.py index a4ad4b885..dff5d4c98 100644 --- a/arcade/gui/widgets/dropdown.py +++ b/arcade/gui/widgets/dropdown.py @@ -25,12 +25,12 @@ class UIDropdown(UILayout): def on_change(event: UIOnChangeEvent): print(event.old_value, event.new_value) - :param float x: x coordinate of bottom left - :param float y: y coordinate of bottom left - :param float width: Width of each of the option. - :param float height: Height of each of the option. - :param str default: The default value shown. - :param list[str] options: The options displayed when the layout is clicked. + :param x: x coordinate of bottom left + :param y: y coordinate of bottom left + :param width: Width of each of the option. + :param height: Height of each of the option. + :param default: The default value shown. + :param options: The options displayed when the layout is clicked. :param style: Used to style the dropdown. """ DIVIDER = None diff --git a/arcade/gui/widgets/layout.py b/arcade/gui/widgets/layout.py index df32a9105..e04228c45 100644 --- a/arcade/gui/widgets/layout.py +++ b/arcade/gui/widgets/layout.py @@ -198,8 +198,8 @@ class UIBoxLayout(UILayout): children) will be distributed to the child widgets based on their ``size_hint``. - :param float x: ``x`` coordinate of the bottom left corner. - :param float y: ``y`` coordinate of the bottom left corner. + :param x: ``x`` coordinate of the bottom left corner. + :param y: ``y`` coordinate of the bottom left corner. :param vertical: Layout children vertical (True) or horizontal (False). :param align: Align children in orthogonal direction:: - ``x``: ``left``, ``center``, and ``right`` @@ -474,14 +474,14 @@ class UIGridLayout(UILayout): Children are resized based on ``size_hint``. Maximum and minimum ``size_hint``s only take effect if a ``size_hint`` is given. - :param float x: ``x`` coordinate of bottom left corner. - :param float y: ``y`` coordinate of bottom left corner. - :param str align_horizontal: Align children in orthogonal direction. + :param x: ``x`` coordinate of bottom left corner. + :param y: ``y`` coordinate of bottom left corner. + :param align_horizontal: Align children in orthogonal direction. Options include ``left``, ``center``, and ``right``. - :param str align_vertical: Align children in orthogonal direction. Options + :param align_vertical: Align children in orthogonal direction. Options include ``top``, ``center``, and ``bottom``. - :param Iterable[UIWidget] children: Initial list of children. More can be + :param children: Initial list of children. More can be added later. :param size_hint: A size hint for :py:class:`~arcade.gui.UILayout`, if the :py:class:`~arcade.gui.UIWidget` would like to grow. @@ -489,9 +489,9 @@ class UIGridLayout(UILayout): :param size_hint_max: Maximum width and height in pixels. :param horizontal_spacing: Space between columns. :param vertical_spacing: Space between rows. - :param int column_count: Number of columns in the grid. This can be changed + :param column_count: Number of columns in the grid. This can be changed later. - :param int row_count: Number of rows in the grid. This can be changed + :param row_count: Number of rows in the grid. This can be changed later. """ @@ -633,14 +633,14 @@ def add( """ Add a widget to the grid layout. - :param UIWidget child: Specified child widget to add. - :param int col_num: Column index in which the widget is to be added. + :param child: Specified child widget to add. + :param col_num: Column index in which the widget is to be added. The first column is numbered 0; which is the top left corner. - :param int row_num: The row number in which the widget is to be added. + :param row_num: The row number in which the widget is to be added. The first row is numbered 0; which is the - :param int col_span: Number of columns the widget will stretch for. - :param int row_span: Number of rows the widget will stretch for. + :param col_span: Number of columns the widget will stretch for. + :param row_span: Number of rows the widget will stretch for. """ return super().add( child, diff --git a/arcade/gui/widgets/slider.py b/arcade/gui/widgets/slider.py index e2acdb972..bb748a1aa 100644 --- a/arcade/gui/widgets/slider.py +++ b/arcade/gui/widgets/slider.py @@ -42,13 +42,13 @@ class UISlider(UIStyledWidget[UISliderStyle]): There are four states of the UISlider i.e normal, hovered, pressed and disabled. - :param float value: Current value of the curosr of the slider. - :param float min_value: Minimum value of the slider. - :param float max_value: Maximum value of the slider. - :param float x: x coordinate of bottom left. - :param float y: y coordinate of bottom left. - :param float width: Width of the slider. - :param float height: Height of the slider. + :param value: Current value of the curosr of the slider. + :param min_value: Minimum value of the slider. + :param max_value: Maximum value of the slider. + :param x: x coordinate of bottom left. + :param y: y coordinate of bottom left. + :param width: Width of the slider. + :param height: Height of the slider. :param Mapping[str, "UISlider.UIStyle"] | None style: Used to style the slider for different states. """ diff --git a/arcade/gui/widgets/text.py b/arcade/gui/widgets/text.py index 41315248b..c855613df 100644 --- a/arcade/gui/widgets/text.py +++ b/arcade/gui/widgets/text.py @@ -35,28 +35,28 @@ class UILabel(UIWidget): By default, a label will fit its initial content. If the text is changed use :py:meth:`~arcade.gui.UILabel.fit_content` to adjust the size. - :param float x: x position (default anchor is bottom-left). - :param float y: y position (default anchor is bottom-left). - :param float width: Width of the label. Defaults to text width if not + :param x: x position (default anchor is bottom-left). + :param y: y position (default anchor is bottom-left). + :param width: Width of the label. Defaults to text width if not specified. See :py:meth:`~pyglet.text.layout.TextLayout.content_width`. - :param float height: Height of the label. Defaults to text height if not + :param height: Height of the label. Defaults to text height if not specified. See :py:meth:`~pyglet.text.layout.TextLayout.content_height`. - :param str text: Text displayed on the label. + :param text: Text displayed on the label. :param font_name: A list of fonts to use. Arcade will start at the beginning of the tuple and keep trying to load fonts until success. - :param float font_size: Font size of font. - :param RGBA255 text_color: Color of the text. - :param bool bold: If enabled, the label's text will be in a **bold** style. - :param bool italic: If enabled, the label's text will be in an *italic* + :param font_size: Font size of font. + :param text_color: Color of the text. + :param bold: If enabled, the label's text will be in a **bold** style. + :param italic: If enabled, the label's text will be in an *italic* style. - :param bool stretch: Stretch font style. - :param str align: Horizontal alignment of text on a line. This only applies + :param stretch: Stretch font style. + :param align: Horizontal alignment of text on a line. This only applies if a width is supplied. Valid options include ``"left"``, ``"center"`` or ``"right"``. - :param float dpi: Resolution of the fonts in the layout. Defaults to 96. - :param bool multiline: If enabled, a ``\\n`` will start a new line. A + :param dpi: Resolution of the fonts in the layout. Defaults to 96. + :param multiline: If enabled, a ``\\n`` will start a new line. A :py:class:`~arcade.gui.UITextWidget` with ``multiline`` of True is the same thing as a :py:class:`~arcade.gui.UITextArea`. @@ -266,8 +266,8 @@ class UIInputText(UIWidget): around the caret. Arcade confirms that the field is active before allowing users to type, so it is okay to have multiple of these. - :param float x: x position (default anchor is bottom-left). - :param float y: y position (default anchor is bottom-left). + :param x: x position (default anchor is bottom-left). + :param y: y position (default anchor is bottom-left). :param width: Width of the text field. :param height: Height of the text field. :param text: Initial text displayed. This can be modified later @@ -440,8 +440,8 @@ class UITextArea(UIWidget): A text area that allows users to view large documents of text by scrolling the mouse. - :param float x: x position (default anchor is bottom-left). - :param float y: y position (default anchor is bottom-left). + :param x: x position (default anchor is bottom-left). + :param y: y position (default anchor is bottom-left). :param width: Width of the text area. :param height: Height of the text area. :param text: Initial text displayed. diff --git a/arcade/hitbox/__init__.py b/arcade/hitbox/__init__.py index fb34a27fd..a73e9dbd7 100644 --- a/arcade/hitbox/__init__.py +++ b/arcade/hitbox/__init__.py @@ -25,7 +25,7 @@ def calculate_hit_box_points_simple(image: Image, *args) -> PointList: Given an RGBA image, this returns points that make up a hit box around it. Attempts to trim out transparent pixels. - :param Image image: Image get hit box from. + :param image: Image get hit box from. :Returns: List of points """ @@ -40,8 +40,8 @@ def calculate_hit_box_points_detailed( Given an RGBA image, this returns points that make up a hit box around it. Attempts to trim out transparent pixels. - :param Image image: Image get hit box from. - :param int hit_box_detail: How detailed to make the hit box. There's a + :param image: Image get hit box from. + :param hit_box_detail: How detailed to make the hit box. There's a trade-off in number of points vs. accuracy. :Returns: List of points diff --git a/arcade/hitbox/bounding_box.py b/arcade/hitbox/bounding_box.py index 923f8ab4a..3af39a834 100644 --- a/arcade/hitbox/bounding_box.py +++ b/arcade/hitbox/bounding_box.py @@ -16,7 +16,7 @@ def calculate(self, image: Image, **kwargs) -> PointList: Given an RGBA image, this returns points that make up a hit box around it without any attempt to trim out transparent pixels. - :param Image image: Image get hit box from. + :param image: Image get hit box from. :Returns: List of points """ diff --git a/arcade/hitbox/pymunk.py b/arcade/hitbox/pymunk.py index 2a5a4cc8e..b933c7ffc 100644 --- a/arcade/hitbox/pymunk.py +++ b/arcade/hitbox/pymunk.py @@ -37,8 +37,8 @@ def calculate(self, image: Image, detail: Optional[float] = None, **kwargs) -> P """ Given an RGBA image, this returns points that make up a hit box around it. - :param Image image: Image get hit box from. - :param int detail: How detailed to make the hit box. There's a + :param image: Image get hit box from. + :param detail: How detailed to make the hit box. There's a trade-off in number of points vs. accuracy. :Returns: List of points @@ -68,8 +68,8 @@ def to_points_list(self, image: Image, line_set: List[Vec2d]) -> PointList: Coordinates are offset so ``(0,0)`` is the center of the image. - :param Image image: Image to trace. - :param List[Vec2d] line_set: Line set to convert. + :param image: Image to trace. + :param line_set: Line set to convert. """ # Convert to normal points, offset fo 0,0 is center, flip the y hh = image.height / 2.0 @@ -97,7 +97,7 @@ def trace_image(self, image: Image) -> PolylineSet: holes in the image. If more than one line set is returned it's important to pick the one that covers the most of the image. - :param Image image: Image to trace. + :param image: Image to trace. :return: Line sets """ def sample_func(sample_point: Point) -> int: @@ -153,7 +153,7 @@ def select_largest_line_set(self, line_sets: PolylineSet) -> List[Vec2d]: """ Given a list of line sets, return the one that covers the most of the image. - :param PolylineSet line_sets: List of line sets. + :param line_sets: List of line sets. :return: List of points that make up the line set. """ if len(line_sets) == 1: diff --git a/arcade/hitbox/simple.py b/arcade/hitbox/simple.py index 5eff90e84..d2f39b91d 100644 --- a/arcade/hitbox/simple.py +++ b/arcade/hitbox/simple.py @@ -17,7 +17,7 @@ def calculate(self, image: Image, **kwargs) -> PointList: Given an RGBA image, this returns points that make up a hit box around it. Attempts to trim out transparent pixels. - :param Image image: + :param image: :Returns: List of points """ diff --git a/arcade/math.py b/arcade/math.py index 42f727b96..9201c1522 100644 --- a/arcade/math.py +++ b/arcade/math.py @@ -284,10 +284,10 @@ def get_distance(x1: float, y1: float, x2: float, y2: float) -> float: """ Get the distance between two points. - :param float x1: x coordinate of the first point - :param float y1: y coordinate of the first point - :param float x2: x coordinate of the second point - :param float y2: y coordinate of the second point + :param x1: x coordinate of the first point + :param y1: y coordinate of the first point + :param x2: x coordinate of the second point + :param y2: y coordinate of the second point :return: Distance between the two points """ return math.hypot(x1 - x2, y1 - y2) @@ -309,7 +309,6 @@ def rotate_point( :param cy: y value of the center point you want to rotate around :param angle_degrees: Angle, in degrees, to rotate :return: Return rotated (x, y) pair - :rtype: Point """ temp_x = x - cx temp_y = y - cy @@ -332,10 +331,10 @@ def get_angle_degrees(x1: float, y1: float, x2: float, y2: float) -> float: """ Get the angle in degrees between two points. - :param float x1: x coordinate of the first point - :param float y1: y coordinate of the first point - :param float x2: x coordinate of the second point - :param float y2: y coordinate of the second point + :param x1: x coordinate of the first point + :param y1: y coordinate of the first point + :param x2: x coordinate of the second point + :param y2: y coordinate of the second point """ x_diff = x2 - x1 y_diff = y2 - y1 @@ -346,10 +345,10 @@ def get_angle_radians(x1: float, y1: float, x2: float, y2: float) -> float: """ Get the angle in radians between two points. - :param float x1: x coordinate of the first point - :param float y1: y coordinate of the first point - :param float x2: x coordinate of the second point - :param float y2: y coordinate of the second point + :param x1: x coordinate of the first point + :param y1: y coordinate of the first point + :param x2: x coordinate of the second point + :param y2: y coordinate of the second point """ x_diff = x2 - x1 y_diff = y2 - y1 diff --git a/arcade/paths.py b/arcade/paths.py index 64ba1829b..2f3bf2ea1 100644 --- a/arcade/paths.py +++ b/arcade/paths.py @@ -35,9 +35,9 @@ def _spot_is_blocked(position: Point, """ Return if position is blocked - :param Point position: position to put moving_sprite at - :param Sprite moving_sprite: Sprite to use - :param SpriteList blocking_sprites: List of Sprites to check against + :param position: position to put moving_sprite at + :param moving_sprite: Sprite to use + :param blocking_sprites: List of Sprites to check against :return: If the Sprite would hit anything in blocking_sprites at the position """ @@ -52,8 +52,8 @@ def _heuristic(start: Point, goal: Point) -> float: """ Returns a heuristic value for the passed points. - :param Point start: The 1st point to compare - :param Point goal: The 2nd point to compare + :param start: The 1st point to compare + :param goal: The 2nd point to compare :return: The heuristic of the 2 points """ @@ -71,10 +71,10 @@ class _AStarGraph(object): A grid which tracks 2 barriers and a moving sprite. :param Union[List, Tuple, Set] barriers: Is turned into a set, and then used for _AStarSearch - :param int left: Far left side x value - :param int right: Far right side x value - :param int bottom: Far bottom side y value - :param int top: Far top side y value + :param left: Far left side x value + :param right: Far right side x value + :param bottom: Far bottom side y value + :param top: Far top side y value """ def __init__(self, barriers: Union[List, Tuple, Set], @@ -105,7 +105,7 @@ def get_vertex_neighbours(self, pos: Point) -> List[Tuple[float, float]]: These are not guaranteed to be reachable or valid points. - :param Point pos: Which position to search around + :param pos: Which position to search around :return: Returns vertexes around the point """ @@ -127,8 +127,8 @@ def move_cost(self, a: Point, b: Point) -> float: A barrier's cost is float("inf) so that that the Algorithm will never go on it - :param Point a: The 1st point to compare - :param Point b: The 2nd point to compare + :param a: The 1st point to compare + :param b: The 2nd point to compare :return: The move cost of moving between of the 2 points """ @@ -147,8 +147,8 @@ def _AStarSearch(start: Point, end: Point, graph: _AStarGraph) -> Optional[List[ Graph is used to check for barriers. - :param Point start: point to start at - :param Point end: point to end at + :param start: point to start at + :param end: point to end at :return: The path from start to end. Returns None if is path is not found """ @@ -230,14 +230,14 @@ class AStarBarrierList: Class that manages a list of barriers that can be encountered during A* path finding. - :param BasicSprite moving_sprite: Sprite that will be moving - :param SpriteList blocking_sprites: Sprites that can block movement - :param int grid_size: Size of the grid, in pixels - :param int left: Left border of playing field - :param int right: Right border of playing field - :param int bottom: Bottom of playing field - :param int top: Top of playing field - :param Optional[Set] barrier_list: SpriteList of barriers to use in _AStarSearch, None if not recalculated + :param moving_sprite: Sprite that will be moving + :param blocking_sprites: Sprites that can block movement + :param grid_size: Size of the grid, in pixels + :param left: Left border of playing field + :param right: Right border of playing field + :param bottom: Bottom of playing field + :param top: Top of playing field + :param barrier_list: SpriteList of barriers to use in _AStarSearch, None if not recalculated """ def __init__(self, moving_sprite: Sprite, @@ -294,10 +294,10 @@ def astar_calculate_path(start_point: Point, """ Calculates the path using AStarSearch Algorithm and returns the path - :param Point start_point: Where it starts - :param Point end_point: Where it ends - :param AStarBarrierList astar_barrier_list: AStarBarrierList with the boundries to use in the AStarSearch Algorithm - :param bool diagonal_movement: Whether of not to use diagonals in the AStarSearch Algorithm + :param start_point: Where it starts + :param end_point: Where it ends + :param astar_barrier_list: AStarBarrierList with the boundries to use in the AStarSearch Algorithm + :param diagonal_movement: Whether of not to use diagonals in the AStarSearch Algorithm :return: List of points(the path), or None if no path is found """ @@ -334,11 +334,11 @@ def has_line_of_sight(observer: Point, """ Determine if we have line of sight between two points. - :param Point observer: Start position - :param Point target: End position position - :param SpriteList walls: List of all blocking sprites - :param int max_distance: Max distance point 1 can see - :param int check_resolution: Check every x pixels for a sprite. Trade-off between accuracy and speed. + :param observer: Start position + :param target: End position position + :param walls: List of all blocking sprites + :param max_distance: Max distance point 1 can see + :param check_resolution: Check every x pixels for a sprite. Trade-off between accuracy and speed. .. warning:: Try to make sure spatial hashing is enabled on ``walls``! @@ -369,8 +369,8 @@ def has_line_of_sight(observer: Point, # """ # Bresenham's line algorithm -# :param Point start: -# :param Point end: +# :param start: +# :param end: # :return: List of points # """ # x1, y1 = start diff --git a/arcade/perf_info.py b/arcade/perf_info.py index d9dc1372a..26c2e084d 100644 --- a/arcade/perf_info.py +++ b/arcade/perf_info.py @@ -182,7 +182,7 @@ def get_fps(frame_count: int = 60) -> float: See :ref:`performance_statistics_example` for an example of how to use function. - :param int frame_count: How many frames to calculate the FPS over. + :param frame_count: How many frames to calculate the FPS over. """ cur_time = time.perf_counter() if len(_frame_times) == 0: diff --git a/arcade/physics_engines.py b/arcade/physics_engines.py index 13ad84fb6..289d4f8a0 100644 --- a/arcade/physics_engines.py +++ b/arcade/physics_engines.py @@ -228,7 +228,7 @@ class PhysicsEngineSimple: games. It is easier to get started with this engine than more sophisticated engines like PyMunk. - :param Sprite player_sprite: The moving sprite + :param player_sprite: The moving sprite :param Union[SpriteList, Iterable[SpriteList] walls: The sprites it can't move through. This can be one or multiple spritelists. """ @@ -269,10 +269,10 @@ class PhysicsEnginePlatformer: and ``boundary_right`` attribute of the Sprite. You need only set an initial ``change_x`` or ``change_y`` on it. - :param Sprite player_sprite: The moving sprite + :param player_sprite: The moving sprite :param Optional[Union[SpriteList, Iterable[SpriteList]]] platforms: Sprites the player can't move through. This value should only be used for moving Sprites. Static sprites should be sent to the ``walls`` parameter. - :param float gravity_constant: Downward acceleration per frame + :param gravity_constant: Downward acceleration per frame :param Optional[Union[SpriteList, Iterable[SpriteList]]] ladders: Ladders the user can climb on :param Optional[Union[SpriteList, Iterable[SpriteList]]] walls: Sprites the player can't move through. This value should only be used for static Sprites. Moving sprites should be sent to the ``platforms`` parameter. @@ -329,7 +329,6 @@ def can_jump(self, y_distance: float = 5) -> bool: and we return a True. :returns: True if there is a platform below us - :rtype: bool """ # Move down to see if we are on a platform @@ -357,7 +356,7 @@ def enable_multi_jump(self, allowed_jumps: int): If you enable multi-jump, you MUST call increment_jump_counter() every time the player jumps. Otherwise they can jump infinitely. - :param int allowed_jumps: + :param allowed_jumps: """ self.allowed_jumps = allowed_jumps self.allow_multi_jump = True diff --git a/arcade/pymunk_physics_engine.py b/arcade/pymunk_physics_engine.py index dc1279627..87d797b81 100644 --- a/arcade/pymunk_physics_engine.py +++ b/arcade/pymunk_physics_engine.py @@ -378,10 +378,10 @@ def step(self, """ Tell the physics engine to perform calculations. - :param float delta_time: Time to move the simulation forward. Keep this + :param delta_time: Time to move the simulation forward. Keep this value constant, do not use varying values for each step. - :param bool resync_sprites: Resynchronize Arcade graphical sprites to be + :param resync_sprites: Resynchronize Arcade graphical sprites to be at the same location as their Pymunk counterparts. If running multiple steps per frame, set this to false for the first steps, and true for the last diff --git a/arcade/resources/__init__.py b/arcade/resources/__init__.py index 9c3e65946..addb55248 100644 --- a/arcade/resources/__init__.py +++ b/arcade/resources/__init__.py @@ -115,7 +115,7 @@ def add_resource_handle(handle: str, path: Union[str, Path]) -> None: the first path, it will look in the next path, and so on. The search is done in reverse order, so the last path added is searched first. - :param str handle: The name of the handle + :param handle: The name of the handle :param Union[str, Path] path: The absolute path to a directory """ if isinstance(path, str): @@ -144,7 +144,7 @@ def get_resource_handle_paths(handle: str) -> List[Path]: """ Returns the paths for a resource handle. - :param str handle: The name of the handle + :param handle: The name of the handle """ try: return handles[handle] diff --git a/arcade/sections.py b/arcade/sections.py index d3515f6db..263c1a6ef 100644 --- a/arcade/sections.py +++ b/arcade/sections.py @@ -21,27 +21,27 @@ class Section: A Section represents a rectangular portion of the viewport Events are dispatched to the section based on it's position on the screen. - :param int left: the left position of this section - :param int bottom: the bottom position of this section - :param int width: the width of this section - :param int height: the height of this section - :param Optional[str] name: the name of this section + :param left: the left position of this section + :param bottom: the bottom position of this section + :param width: the width of this section + :param height: the height of this section + :param name: the name of this section :param Union[bool, Iterable] accept_keyboard_keys: whether or not this section captures keyboard keys through. keyboard events. If the param is an iterable means the keyboard keys that are captured in press/release events: for example: [arcade.key.UP, arcade.key.DOWN] will only capture this two keys :param Union[bool, Iterable] accept_mouse_events: whether or not this section captures mouse events. If the param is an iterable means the mouse events that are captured. for example: ['on_mouse_press', 'on_mouse_release'] will only capture this two events. - :param Optional[Iterable] prevent_dispatch: a list of event names that will not be dispatched to subsequent + :param prevent_dispatch: a list of event names that will not be dispatched to subsequent sections. You can pass None (default) or {True} to prevent the dispatch of all events. - :param Optional[Iterable] prevent_dispatch_view: a list of event names that will not be dispatched to the view. + :param prevent_dispatch_view: a list of event names that will not be dispatched to the view. You can pass None (default) or {True} to prevent the dispatch of all events to the view. - :param bool local_mouse_coordinates: if True the section mouse events will receive x, y coordinates section + :param local_mouse_coordinates: if True the section mouse events will receive x, y coordinates section related to the section dimensions and position (not related to the screen) - :param bool enabled: if False the section will not capture any events - :param bool modal: if True the section will be a modal section: will prevent updates and event captures on + :param enabled: if False the section will not capture any events + :param modal: if True the section will be a modal section: will prevent updates and event captures on other sections. Will also draw last (on top) but capture events first. - :param int draw_order: The order this section will have when on_draw is called. + :param draw_order: The order this section will have when on_draw is called. The lower the number the earlier this will get draw. This can be different from the event capture order or the on_update order which is defined by the insertion order. @@ -522,9 +522,9 @@ def get_first_section(self, x: int, y: int, *, event_capture: bool = True) -> Op """ Returns the first section based on x,y position - :param int x: the x axis coordinate - :param int y: the y axis coordinate - :param bool event_capture: True will use event capture dimensions, False will use section draw size + :param x: the x axis coordinate + :param y: the y axis coordinate + :param event_capture: True will use event capture dimensions, False will use section draw size :return: a section if match the params otherwise None """ for section in self._sections: @@ -539,9 +539,9 @@ def get_sections(self, x: int, y: int, *, event_capture: bool = True) -> Generat """ Returns a list of sections based on x,y position - :param int x: the x axis coordinate - :param int y: the y axis coordinate - :param bool event_capture: True will use event capture dimensions, False will use section draw size + :param x: the x axis coordinate + :param y: the y axis coordinate + :param event_capture: True will use event capture dimensions, False will use section draw size :return: a generator with the sections that match the params """ for section in self._sections: diff --git a/arcade/shape_list.py b/arcade/shape_list.py index 2fab7f237..b8da0e230 100644 --- a/arcade/shape_list.py +++ b/arcade/shape_list.py @@ -68,10 +68,10 @@ class Shape: This shape can be drawn using the draw() method, or added to a ShapeElementList for drawing in batch. - :param PointList points: A list of points that make up the shape. - :param Sequence[RGBA255] colors: A list of colors that correspond to the points. - :param int mode: The OpenGL drawing mode. Defaults to GL_TRIANGLES. - :param Program program: The program to use when drawing this shape (Shape.draw() only) + :param points: A list of points that make up the shape. + :param colors: A list of colors that correspond to the points. + :param mode: The OpenGL drawing mode. Defaults to GL_TRIANGLES. + :param program: The program to use when drawing this shape (Shape.draw() only) """ def __init__( self, @@ -134,12 +134,12 @@ def create_line( """ Create a Shape object for a line. - :param float start_x: Starting x position - :param float start_y: Starting y position - :param float end_x: Ending x position - :param float end_y: Ending y position - :param RGBA255 color: Color of the line - :param float line_width: Width of the line + :param start_x: Starting x position + :param start_y: Starting y position + :param end_x: Ending x position + :param end_y: Ending y position + :param color: Color of the line + :param line_width: Width of the line """ points = get_points_for_thick_line(start_x, start_y, end_x, end_y, line_width) color_list = [color, color, color, color] @@ -156,12 +156,12 @@ def create_line_generic_with_colors( This function is used by ``create_line_strip`` and ``create_line_loop``, just changing the OpenGL type for the line drawing. - :param PointList point_list: A list of points that make up the shape. - :param Sequence[RBGALike] color_sequence: A sequence of colors such + :param point_list: A list of points that make up the shape. + :param color_sequence: A sequence of colors such as a :py:class:`list`; each color must be either a :py:class:`~arcade.types.Color` instance or a 4-length RGBA :py:class:`tuple`. - :param float shape_mode: The OpenGL drawing mode. Defaults to GL_TRIANGLES. + :param shape_mode: The OpenGL drawing mode. Defaults to GL_TRIANGLES. """ return Shape( points=point_list, @@ -179,9 +179,9 @@ def create_line_generic( This function is used by ``create_line_strip`` and ``create_line_loop``, just changing the OpenGL type for the line drawing. - :param PointList point_list: A list of points that make up the shape. - :param RGBA255 color: A color such as a :py:class:`~arcade.types.Color` - :param float shape_mode: The OpenGL drawing mode. Defaults to GL_TRIANGLES. + :param point_list: A list of points that make up the shape. + :param color: A color such as a :py:class:`~arcade.types.Color` + :param shape_mode: The OpenGL drawing mode. Defaults to GL_TRIANGLES. """ colors = [Color.from_iterable(color)] * len(point_list) return create_line_generic_with_colors(point_list, colors, shape_mode) @@ -198,9 +198,9 @@ def create_line_strip( Internally, thick lines are created by two triangles. - :param PointList point_list: - :param RGBA255 color: - :param PointList line_width: + :param point_list: + :param color: + :param line_width: """ if line_width == 1: return create_line_generic(point_list, color, gl.GL_LINE_STRIP) @@ -230,9 +230,9 @@ def create_line_loop( Create a multi-point line loop to be rendered later. This works faster than draw_line because the vertexes are only loaded to the graphics card once, rather than each frame. - :param PointList point_list: A list of points that make up the shape. - :param RGBA255 color: A color such as a :py:class:`~arcade.types.Color` - :param float line_width: Width of the line + :param point_list: A list of points that make up the shape. + :param color: A color such as a :py:class:`~arcade.types.Color` + :param line_width: Width of the line """ point_list = list(point_list) + [point_list[0]] return create_line_strip(point_list, color, line_width) @@ -246,9 +246,9 @@ def create_lines( Create a multi-point line loop to be rendered later. This works faster than draw_line because the vertexes are only loaded to the graphics card once, rather than each frame. - :param PointList point_list: A list of points that make up the shape. - :param RGBA255 color: A color such as a :py:class:`~arcade.types.Color` - :param float line_width: Width of the line + :param point_list: A list of points that make up the shape. + :param color: A color such as a :py:class:`~arcade.types.Color` + :param line_width: Width of the line """ return create_line_generic(point_list, color, gl.GL_LINES) @@ -262,9 +262,9 @@ def create_lines_with_colors( Create a line segments to be rendered later. This works faster than draw_line because the vertexes are only loaded to the graphics card once, rather than each frame. - :param PointList point_list: Line segments start and end point tuples list - :param RGBA255 color_list: Three or four byte tuples list for every point - :param float line_width: Width of the line + :param point_list: Line segments start and end point tuples list + :param color_list: Three or four byte tuples list for every point + :param line_width: Width of the line :Returns Shape: """ @@ -300,8 +300,8 @@ def create_polygon(point_list: PointList, color: RGBA255) -> Shape: draw that list. This allows nearly unlimited shapes to be drawn just as fast as one. - :param PointList point_list: A list of points that make up the shape. - :param RGBA255 color: A color such as a :py:class:`~arcade.types.Color` + :param point_list: A list of points that make up the shape. + :param color: A color such as a :py:class:`~arcade.types.Color` """ # We assume points were given in order, either clockwise or counter clockwise. # Polygon is assumed to be monotone. @@ -334,12 +334,12 @@ def create_rectangle_filled( draw that list. This allows nearly unlimited shapes to be drawn just as fast as one. - :param float center_x: X position of the center of the rectangle - :param float center_y: Y position of the center of the rectangle - :param float width: Width of the rectangle - :param float height: Height of the rectangle - :param RGBA255 color: A color such as a :py:class:`~arcade.types.Color` - :param float tilt_angle: Angle to tilt the rectangle in degrees + :param center_x: X position of the center of the rectangle + :param center_y: Y position of the center of the rectangle + :param width: Width of the rectangle + :param height: Height of the rectangle + :param color: A color such as a :py:class:`~arcade.types.Color` + :param tilt_angle: Angle to tilt the rectangle in degrees """ return create_rectangle( center_x, center_y, @@ -369,13 +369,13 @@ def create_rectangle_outline( draw that list. This allows nearly unlimited shapes to be drawn just as fast as one. - :param float center_x: X position of the center of the rectangle - :param float center_y: Y position of the center of the rectangle - :param float width: Width of the rectangle - :param float height: Height of the rectangle - :param RGBA255 color: A color such as a :py:class:`~arcade.types.Color` - :param float border_width: Width of the border - :param float tilt_angle: Angle to tilt the rectangle in degrees + :param center_x: X position of the center of the rectangle + :param center_y: Y position of the center of the rectangle + :param width: Width of the rectangle + :param height: Height of the rectangle + :param color: A color such as a :py:class:`~arcade.types.Color` + :param border_width: Width of the border + :param tilt_angle: Angle to tilt the rectangle in degrees """ return create_rectangle( center_x, center_y, @@ -398,11 +398,11 @@ def get_rectangle_points( Utility function that will return all four coordinate points of a rectangle given the x, y center, width, height, and rotation. - :param float center_x: X position of the center of the rectangle - :param float center_y: Y position of the center of the rectangle - :param float width: Width of the rectangle - :param float height: Height of the rectangle - :param float tilt_angle: Angle to tilt the rectangle in degrees + :param center_x: X position of the center of the rectangle + :param center_y: Y position of the center of the rectangle + :param width: Width of the rectangle + :param height: Height of the rectangle + :param tilt_angle: Angle to tilt the rectangle in degrees """ x1 = -width / 2 + center_x y1 = -height / 2 + center_y @@ -446,14 +446,14 @@ def create_rectangle( draw that list. This allows nearly unlimited shapes to be drawn just as fast as one. - :param float center_x: X position of the center of the rectangle - :param float center_y: Y position of the center of the rectangle - :param float width: Width of the rectangle - :param float height: Height of the rectangle - :param RGBA255 color: A color such as a :py:class:`~arcade.types.Color` - :param float border_width: Width of the border - :param float tilt_angle: Angle to tilt the rectangle in degrees - :param bool filled: If True, the rectangle is filled. If False, it is an outline. + :param center_x: X position of the center of the rectangle + :param center_y: Y position of the center of the rectangle + :param width: Width of the rectangle + :param height: Height of the rectangle + :param color: A color such as a :py:class:`~arcade.types.Color` + :param border_width: Width of the border + :param tilt_angle: Angle to tilt the rectangle in degrees + :param filled: If True, the rectangle is filled. If False, it is an outline. """ data: List[Point] = cast(List[Point], get_rectangle_points(center_x, center_y, width, height, tilt_angle)) @@ -549,8 +549,8 @@ def create_triangles_filled_with_colors( draw that list. This allows nearly unlimited shapes to be drawn just as fast as one. - :param PointList point_list: Triangles vertices tuples. - :param Sequence[RBGALike] color_sequence: A sequence of colors such + :param point_list: Triangles vertices tuples. + :param color_sequence: A sequence of colors such as a :py:class:`list`; each color must be either a :py:class:`~arcade.types.Color` instance or a 4-length RGBA :py:class:`tuple`. @@ -576,8 +576,8 @@ def create_triangles_strip_filled_with_colors( draw that list. This allows nearly unlimited shapes to be drawn just as fast as one. - :param PointList point_list: Triangles vertices tuples. - :param Sequence[RBGALike] color_sequence: A sequence of colors such + :param point_list: Triangles vertices tuples. + :param color_sequence: A sequence of colors such as a :py:class:`list`; each color must be either a :py:class:`~arcade.types.Color` instance or a 4-length RGBA :py:class:`tuple`. @@ -658,15 +658,15 @@ def create_ellipse( draw that list. This allows nearly unlimited shapes to be drawn just as fast as one. - :param float center_x: X position of the center of the ellipse. - :param float center_y: Y position of the center of the ellipse. - :param float width: Width of the ellipse. - :param float height: Height of the ellipse. - :param RGBA255 color: Color of the ellipse. - :param float border_width: Width of the border. - :param float tilt_angle: Angle to tilt the ellipse. - :param int num_segments: Number of segments to use to draw the ellipse. - :param bool filled: If True, create a filled ellipse. If False, create an outline. + :param center_x: X position of the center of the ellipse. + :param center_y: Y position of the center of the ellipse. + :param width: Width of the ellipse. + :param height: Height of the ellipse. + :param color: Color of the ellipse. + :param border_width: Width of the border. + :param tilt_angle: Angle to tilt the ellipse. + :param num_segments: Number of segments to use to draw the ellipse. + :param filled: If True, create a filled ellipse. If False, create an outline. """ # Create an array with the vertex point_list point_list = [] @@ -717,14 +717,14 @@ def create_ellipse_filled_with_colors( draw that list. This allows nearly unlimited shapes to be drawn just as fast as one. - :param float center_x: X position of the center of the ellipse. - :param float center_y: Y position of the center of the ellipse. - :param float width: Width of the ellipse. - :param float height: Height of the ellipse. - :param RGBA255 outside_color: Color of the outside of the ellipse. - :param RGBA255 inside_color: Color of the inside of the ellipse. - :param float tilt_angle: Angle to tilt the ellipse. - :param int num_segments: Number of segments to use to draw the ellipse. + :param center_x: X position of the center of the ellipse. + :param center_y: Y position of the center of the ellipse. + :param width: Width of the ellipse. + :param height: Height of the ellipse. + :param outside_color: Color of the outside of the ellipse. + :param inside_color: Color of the inside of the ellipse. + :param tilt_angle: Angle to tilt the ellipse. + :param num_segments: Number of segments to use to draw the ellipse. """ # Create an array with the vertex data # Create an array with the vertex point_list @@ -830,8 +830,8 @@ def clear(self, position: bool = True, angle: bool = True) -> None: """ Clear all the contents from the shape list. - :param bool position: Reset the position to 0,0 - :param bool angle: Reset the angle to 0 + :param position: Reset the position to 0,0 + :param angle: Reset the angle to 0 """ self.shape_list.clear() self.batches.clear() diff --git a/arcade/sound.py b/arcade/sound.py index 03d2cf6fb..c4dc0a38a 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -63,10 +63,10 @@ def play( """ Play the sound. - :param float volume: Volume, from 0=quiet to 1=loud - :param float pan: Pan, from -1=left to 0=centered to 1=right - :param bool loop: Loop, false to play once, true to loop continuously - :param float speed: Change the speed of the sound which also changes pitch, default 1.0 + :param volume: Volume, from 0=quiet to 1=loud + :param pan: Pan, from -1=left to 0=centered to 1=right + :param loop: Loop, false to play once, true to loop continuously + :param speed: Change the speed of the sound which also changes pitch, default 1.0 """ if ( isinstance(self.source, media.StreamingSource) @@ -127,9 +127,8 @@ def is_playing(self, player: media.Player) -> bool: """ Return if the sound is currently playing or not - :param pyglet.media.Player player: Player returned from :func:`play_sound`. + :param player: Player returned from :func:`play_sound`. :returns: A boolean, ``True`` if the sound is playing. - :rtype: bool """ return player.playing @@ -138,9 +137,8 @@ def get_volume(self, player: media.Player) -> float: """ Get the current volume. - :param pyglet.media.Player player: Player returned from :func:`play_sound`. + :param player: Player returned from :func:`play_sound`. :returns: A float, 0 for volume off, 1 for full volume. - :rtype: float """ return player.volume # type: ignore # pending https://github.com/pyglet/pyglet/issues/847 @@ -148,8 +146,8 @@ def set_volume(self, volume, player: media.Player) -> None: """ Set the volume of a sound as it is playing. - :param float volume: Floating point volume. 0 is silent, 1 is full. - :param pyglet.media.Player player: Player returned from :func:`play_sound`. + :param volume: Floating point volume. 0 is silent, 1 is full. + :param player: Player returned from :func:`play_sound`. """ player.volume = volume @@ -158,7 +156,7 @@ def get_stream_position(self, player: media.Player) -> float: Return where we are in the stream. This will reset back to zero when it is done playing. - :param pyglet.media.Player player: Player returned from :func:`play_sound`. + :param player: Player returned from :func:`play_sound`. """ return player.time @@ -168,12 +166,11 @@ def load_sound(path: Union[str, Path], streaming: bool = False) -> Optional[Soun """ Load a sound. - :param Path path: Name of the sound file to load. - :param bool streaming: Boolean for determining if we stream the sound + :param path: Name of the sound file to load. + :param streaming: Boolean for determining if we stream the sound or load it all into memory. Set to ``True`` for long sounds to save memory, ``False`` for short sounds to speed playback. :returns: Sound object which can be used by the :func:`play_sound` function. - :rtype: Sound """ # Initialize the audio driver if it hasn't been already. # This call is to avoid audio driver initialization @@ -200,11 +197,11 @@ def play_sound( """ Play a sound. - :param Sound sound: Sound loaded by :func:`load_sound`. Do NOT use a string here for the filename. - :param float volume: Volume, from 0=quiet to 1=loud - :param float pan: Pan, from -1=left to 0=centered to 1=right - :param bool looping: Should we loop the sound over and over? - :param float speed: Change the speed of the sound which also changes pitch, default 1.0 + :param sound: Sound loaded by :func:`load_sound`. Do NOT use a string here for the filename. + :param volume: Volume, from 0=quiet to 1=loud + :param pan: Pan, from -1=left to 0=centered to 1=right + :param looping: Should we loop the sound over and over? + :param speed: Change the speed of the sound which also changes pitch, default 1.0 """ if sound is None: print("Unable to play sound, no data passed in.") @@ -226,7 +223,7 @@ def stop_sound(player: media.Player): """ Stop a sound that is currently playing. - :param pyglet.media.Player player: Player returned from :func:`play_sound`. + :param player: Player returned from :func:`play_sound`. """ if isinstance(player, Sound): raise ValueError( diff --git a/arcade/sprite/animated.py b/arcade/sprite/animated.py index 40ba2b2a9..25f86303e 100644 --- a/arcade/sprite/animated.py +++ b/arcade/sprite/animated.py @@ -57,7 +57,7 @@ def update_animation(self, delta_time: float = 1 / 60) -> None: """ Logic for updating the animation. - :param float delta_time: Time since last update. + :param delta_time: Time since last update. """ self.time_counter += delta_time while self.time_counter > self.frames[self.cur_frame_idx].duration / 1000.0: @@ -116,7 +116,7 @@ def update_animation(self, delta_time: float = 1 / 60) -> None: """ Logic for texture animation. - :param float delta_time: Time since last update. + :param delta_time: Time since last update. """ x1 = self.center_x x2 = self.last_texture_change_center_x diff --git a/arcade/sprite/base.py b/arcade/sprite/base.py index df3856de7..f318f8d8d 100644 --- a/arcade/sprite/base.py +++ b/arcade/sprite/base.py @@ -305,7 +305,6 @@ def visible(self) -> bool: # Toggle visible sprite.visible = not sprite.visible - :rtype: bool """ return self._color[3] > 0 @@ -425,7 +424,7 @@ def on_update(self, delta_time: float = 1 / 60) -> None: Update the sprite. Similar to update, but also takes a delta-time. It can be called manually or by the SpriteList's on_update method. - :param float delta_time: Time since last update. + :param delta_time: Time since last update. """ pass @@ -436,7 +435,7 @@ def update_animation(self, delta_time: float = 1 / 60) -> None: This can be called manually or by the SpriteList's update_animation method. - :param float delta_time: Time since last update. + :param delta_time: Time since last update. """ pass @@ -598,9 +597,8 @@ def collides_with_point(self, point: Point) -> bool: """ Check if point is within the current sprite. - :param Point point: Point to check. + :param point: Point to check. :return: True if the point is contained within the sprite's boundary. - :rtype: bool """ from arcade.geometry import is_point_in_polygon @@ -610,9 +608,8 @@ def collides_with_point(self, point: Point) -> bool: def collides_with_sprite(self: SpriteType, other: SpriteType) -> bool: """Will check if a sprite is overlapping (colliding) another Sprite. - :param Sprite other: the other sprite to check against. + :param other: the other sprite to check against. :return: True or False, whether or not they are overlapping. - :rtype: bool """ from arcade import check_for_collision @@ -623,9 +620,8 @@ def collides_with_list( ) -> List[SpriteType]: """Check if current sprite is overlapping with any other sprite in a list - :param SpriteList sprite_list: SpriteList to check against + :param sprite_list: SpriteList to check against :return: List of all overlapping Sprites from the original SpriteList - :rtype: list """ from arcade import check_for_collision_with_list diff --git a/arcade/sprite/colored.py b/arcade/sprite/colored.py index 25ff50fa3..c52b7d38d 100644 --- a/arcade/sprite/colored.py +++ b/arcade/sprite/colored.py @@ -24,14 +24,14 @@ class SpriteSolidColor(Sprite): sprite type, so concerns about memory usage non-existent regardless of size or number of sprite variations. - :param int width: Width of the sprite in pixels - :param int height: Height of the sprite in pixels - :param float center_x: Initial x position of the sprite - :param float center_y: Initial y position of the sprite - :param ColorLike color: The color of the sprite as a + :param width: Width of the sprite in pixels + :param height: Height of the sprite in pixels + :param center_x: Initial x position of the sprite + :param center_y: Initial y position of the sprite + :param color: The color of the sprite as a :py:class:`~arcade.types.Color`, an RGBA tuple, or an RGB tuple. - :param float angle: Initial angle of the sprite in degrees + :param angle: Initial angle of the sprite in degrees """ __slots__ = () @@ -85,9 +85,9 @@ class SpriteCircle(Sprite): ``True``. The circle will fade from an opaque center to transparent at the edges. - :param int radius: Radius of the circle in pixels - :param Color color: The Color of the sprite as an RGB or RGBA tuple - :param bool soft: If ``True``, the circle will fade from an opaque + :param radius: Radius of the circle in pixels + :param color: The Color of the sprite as an RGB or RGBA tuple + :param soft: If ``True``, the circle will fade from an opaque center to transparent edges. """ diff --git a/arcade/sprite/sprite.py b/arcade/sprite/sprite.py index 3089fceca..ceeeb3a9a 100644 --- a/arcade/sprite/sprite.py +++ b/arcade/sprite/sprite.py @@ -37,11 +37,11 @@ class Sprite(BasicSprite, PymunkMixin): It uses fewer resources at the cost of having fewer features. - :param str path_or_texture: Path to an image file, or a texture object. - :param float center_x: Location of the sprite in pixels. - :param float center_y: Location of the sprite in pixels. - :param float scale: Show the image at this many times its original size. - :param float angle: The initial rotation of the sprite in degrees + :param path_or_texture: Path to an image file, or a texture object. + :param center_x: Location of the sprite in pixels. + :param center_y: Location of the sprite in pixels. + :param scale: Show the image at this many times its original size. + :param angle: The initial rotation of the sprite in degrees """ __slots__ = ( @@ -250,7 +250,6 @@ def properties(self) -> Dict[str, Any]: """ Get or set custom sprite properties. - :rtype: Dict[str, Any] """ if self._properties is None: self._properties = {} @@ -375,7 +374,7 @@ def append_texture(self, texture: Texture): Appends a new texture to the list of textures that can be applied to this sprite. - :param arcade.Texture texture: Texture to add to the list of available textures + :param texture: Texture to add to the list of available textures """ self.textures.append(texture) @@ -385,7 +384,7 @@ def set_texture(self, texture_no: int) -> None: Set the current texture by texture number. The number is the index into ``self.textures``. - :param int texture_no: Index into ``self.textures`` + :param texture_no: Index into ``self.textures`` """ texture = self.textures[texture_no] self.texture = texture diff --git a/arcade/sprite_list/collision.py b/arcade/sprite_list/collision.py index 585ee70b9..77f8ff577 100644 --- a/arcade/sprite_list/collision.py +++ b/arcade/sprite_list/collision.py @@ -26,10 +26,9 @@ def get_distance_between_sprites(sprite1: SpriteType, sprite2: SpriteType) -> fl """ Returns the distance between the center of two given sprites - :param Sprite sprite1: Sprite one - :param Sprite sprite2: Sprite two + :param sprite1: Sprite one + :param sprite2: Sprite two :return: Distance - :rtype: float """ return get_distance(*sprite1._position, *sprite2._position) @@ -41,12 +40,11 @@ def get_closest_sprite( """ Given a Sprite and SpriteList, returns the closest sprite, and its distance. - :param Sprite sprite: Target sprite - :param SpriteList sprite_list: List to search for closest sprite. + :param sprite: Target sprite + :param sprite_list: List to search for closest sprite. :return: A tuple containing the closest sprite and the minimum distance. If the spritelist is empty we return ``None``. - :rtype: Optional[Tuple[Sprite, float]] """ if len(sprite_list) == 0: return None @@ -69,7 +67,6 @@ def check_for_collision(sprite1: BasicSprite, sprite2: BasicSprite) -> bool: :param sprite2: Second sprite :Returns: True or False depending if the sprites intersect. - :rtype: bool """ if __debug__: if not isinstance(sprite1, BasicSprite): @@ -89,11 +86,10 @@ def _check_for_collision(sprite1: BasicSprite, sprite2: BasicSprite) -> bool: """ Check for collision between two sprites. - :param Sprite sprite1: Sprite 1 - :param Sprite sprite2: Sprite 2 + :param sprite1: Sprite 1 + :param sprite2: Sprite 2 :returns: True if sprites overlap. - :rtype: bool """ #NOTE: for speed becuase attribute look ups are slow. @@ -187,15 +183,14 @@ def check_for_collision_with_list( """ Check for a collision between a sprite, and a list of sprites. - :param Sprite sprite: Sprite to check - :param SpriteList sprite_list: SpriteList to check against - :param int method: Collision check method. + :param sprite: Sprite to check + :param sprite_list: SpriteList to check against + :param method: Collision check method. 0 is auto-select. (spatial if available, GPU if 1500+ sprites, else simple) 1 is Spatial Hashing if available, 2 is GPU based, 3 is simple check-everything. Defaults to 0. :returns: List of sprites colliding, or an empty list. - :rtype: list """ if __debug__: if not isinstance(sprite, BasicSprite): @@ -238,13 +233,12 @@ def check_for_collision_with_lists( """ Check for a collision between a Sprite, and a list of SpriteLists. - :param Sprite sprite: Sprite to check - :param Iterable[SpriteList] sprite_lists: SpriteLists to check against - :param int method: Collision check method. 1 is Spatial Hashing if available, + :param sprite: Sprite to check + :param sprite_lists: SpriteLists to check against + :param method: Collision check method. 1 is Spatial Hashing if available, 2 is GPU based, 3 is slow CPU-bound check-everything. Defaults to 1. :returns: List of sprites colliding, or an empty list. - :rtype: list """ if __debug__: if not isinstance(sprite, BasicSprite): @@ -277,11 +271,10 @@ def get_sprites_at_point(point: Point, sprite_list: SpriteList[SpriteType]) -> L the specified point. If a sprite has a different center_x/center_y but touches the point, this will return that sprite. - :param Point point: Point to check - :param SpriteList sprite_list: SpriteList to check against + :param point: Point to check + :param sprite_list: SpriteList to check against :returns: List of sprites colliding, or an empty list. - :rtype: list """ if __debug__: if not isinstance(sprite_list, SpriteList): @@ -308,11 +301,10 @@ def get_sprites_at_exact_point(point: Point, sprite_list: SpriteList[SpriteType] Get a list of sprites whose center_x, center_y match the given point. This does NOT return sprites that overlap the point, the center has to be an exact match. - :param Point point: Point to check - :param SpriteList sprite_list: SpriteList to check against + :param point: Point to check + :param sprite_list: SpriteList to check against :returns: List of sprites colliding, or an empty list. - :rtype: list """ if __debug__: if not isinstance(sprite_list, SpriteList): @@ -340,11 +332,10 @@ def get_sprites_in_rect(rect: Rect, sprite_list: SpriteList[SpriteType]) -> List The rectangle is specified as a tuple of (left, right, bottom, top). - :param Rect rect: Rectangle to check - :param SpriteList sprite_list: SpriteList to check against + :param rect: Rectangle to check + :param sprite_list: SpriteList to check against :returns: List of sprites colliding, or an empty list. - :rtype: list """ if __debug__: if not isinstance(sprite_list, SpriteList): diff --git a/arcade/sprite_list/spatial_hash.py b/arcade/sprite_list/spatial_hash.py index 55e30b4dd..a65005649 100644 --- a/arcade/sprite_list/spatial_hash.py +++ b/arcade/sprite_list/spatial_hash.py @@ -18,7 +18,7 @@ class SpatialHash(Generic[SpriteType]): See: https://www.gamedev.net/articles/programming/general-and-gameplay-programming/spatial-hashing-r2697/ - :param int cell_size: Size (width and height) of the cells in the spatial hash + :param cell_size: Size (width and height) of the cells in the spatial hash """ def __init__(self, cell_size: int) -> None: # Sanity check the cell size @@ -52,7 +52,7 @@ def add(self, sprite: SpriteType) -> None: """ Add a sprite to the spatial hash. - :param Sprite sprite: The sprite to add + :param sprite: The sprite to add """ min_point = trunc(sprite.left), trunc(sprite.bottom) max_point = trunc(sprite.right), trunc(sprite.top) @@ -77,7 +77,7 @@ def move(self, sprite: SpriteType) -> None: """ Shortcut to remove and re-add a sprite. - :param Sprite sprite: The sprite to move + :param sprite: The sprite to move """ self.remove(sprite) self.add(sprite) @@ -86,7 +86,7 @@ def remove(self, sprite: SpriteType) -> None: """ Remove a Sprite. - :param Sprite sprite: The sprite to remove + :param sprite: The sprite to remove """ # Remove the sprite from all the buckets it is in for bucket in self.buckets_for_sprite[sprite]: @@ -99,9 +99,8 @@ def get_sprites_near_sprite(self, sprite: BasicSprite) -> Set[SpriteType]: """ Get all the sprites that are in the same buckets as the given sprite. - :param Sprite sprite: The sprite to check + :param sprite: The sprite to check :return: A set of close-by sprites - :rtype: Set """ min_point = trunc(sprite.left), trunc(sprite.bottom) max_point = trunc(sprite.right), trunc(sprite.top) @@ -122,10 +121,9 @@ def get_sprites_near_point(self, point: Point) -> Set[SpriteType]: """ Return sprites in the same bucket as the given point. - :param Point point: The point to check + :param point: The point to check :return: A set of close-by sprites - :rtype: Set """ hash_point = self.hash((trunc(point[0]), trunc(point[1]))) # Return a copy of the set. @@ -135,9 +133,8 @@ def get_sprites_near_rect(self, rect: Rect) -> Set[SpriteType]: """ Return sprites in the same buckets as the given rectangle. - :param Rect rect: The rectangle to check (left, right, bottom, top) + :param rect: The rectangle to check (left, right, bottom, top) :return: A set of sprites in the rectangle - :rtype: Set """ left, right, bottom, top = rect min_point = trunc(left), trunc(bottom) diff --git a/arcade/sprite_list/sprite_list.py b/arcade/sprite_list/sprite_list.py index cb1b15d38..fdc4a42a3 100644 --- a/arcade/sprite_list/sprite_list.py +++ b/arcade/sprite_list/sprite_list.py @@ -74,23 +74,23 @@ class SpriteList(Generic[SpriteType]): For the advanced options check the advanced section in the arcade documentation. - :param bool use_spatial_hash: If set to True, this will make creating a sprite, and + :param use_spatial_hash: If set to True, this will make creating a sprite, and moving a sprite in the SpriteList slower, but it will speed up collision detection with items in the SpriteList. Great for doing collision detection with static walls/platforms in large maps. - :param int spatial_hash_cell_size: The cell size of the spatial hash (default: 128) - :param TextureAtlas atlas: (Advanced) The texture atlas for this sprite list. If no + :param spatial_hash_cell_size: The cell size of the spatial hash (default: 128) + :param atlas: (Advanced) The texture atlas for this sprite list. If no atlas is supplied the global/default one will be used. - :param int capacity: (Advanced) The initial capacity of the internal buffer. + :param capacity: (Advanced) The initial capacity of the internal buffer. It's a suggestion for the maximum amount of sprites this list can hold. Can normally be left with default value. - :param bool lazy: (Advanced) Enabling lazy spritelists ensures no internal OpenGL + :param lazy: (Advanced) Enabling lazy spritelists ensures no internal OpenGL resources are created until the first draw call or ``initialize()`` is called. This can be useful when making spritelists in threads because only the main thread is allowed to interact with OpenGL. - :param bool visible: Setting this to False will cause the SpriteList to not + :param visible: Setting this to False will cause the SpriteList to not be drawn. When draw is called, the method will just return without drawing. """ @@ -288,7 +288,6 @@ def visible(self) -> bool: Get or set the visible flag for this spritelist. If visible is ``False`` the ``draw()`` has no effect. - :rtype: bool """ return self._visible @@ -320,7 +319,6 @@ def color(self) -> Color: 2. Multiply the color channels together: ``texture_color * sprite_color * spritelist_color`` 3. Multiply the floating point values by 255 and round the result - :rtype: Color """ return Color.from_normalized(self._color) @@ -363,7 +361,6 @@ def alpha_normalized(self) -> float: This is a shortcut for setting the alpha value in the spritelist color. - :rtype: float """ return self._color[3] @@ -509,7 +506,6 @@ def _next_slot(self) -> int: Get the next available slot in sprite buffers :return: index slot, buffer_slot - :rtype: int """ # Reuse old slots from deleted sprites if self._sprite_buffer_free_slots: @@ -525,9 +521,8 @@ def index(self, sprite: SpriteType) -> int: """ Return the index of a sprite in the spritelist - :param Sprite sprite: Sprite to find and return the index of + :param sprite: Sprite to find and return the index of - :rtype: int """ return self.sprite_list.index(sprite) @@ -585,7 +580,7 @@ def pop(self, index: int = -1) -> SpriteType: """ Pop off the last sprite, or the given index, from the list - :param int index: Index of sprite to remove, defaults to -1 for the last item. + :param index: Index of sprite to remove, defaults to -1 for the last item. """ if len(self.sprite_list) == 0: raise (ValueError("pop from empty list")) @@ -598,7 +593,7 @@ def append(self, sprite: SpriteType): """ Add a new sprite to the list. - :param Sprite sprite: Sprite to add to the list. + :param sprite: Sprite to add to the list. """ # print(f"{id(self)} : {id(sprite)} append") if sprite in self.sprite_slot: @@ -633,8 +628,8 @@ def append(self, sprite: SpriteType): def swap(self, index_1: int, index_2: int): """ Swap two sprites by index - :param int index_1: Item index to swap - :param int index_2: Item index to swap + :param index_1: Item index to swap + :param index_2: Item index to swap """ # Swap order in spritelist sprite_1 = self.sprite_list[index_1] @@ -653,7 +648,7 @@ def swap(self, index_1: int, index_2: int): def remove(self, sprite: SpriteType): """ Remove a specific sprite from the list. - :param Sprite sprite: Item to remove from the list + :param sprite: Item to remove from the list """ # print(f"{id(self)} : {id(sprite)} remove") try: @@ -686,7 +681,7 @@ def extend(self, sprites: Union[Iterable[SpriteType], "SpriteList"]): """ Extends the current list with the given iterable - :param list sprites: Iterable of Sprites to add to the list + :param sprites: Iterable of Sprites to add to the list """ for sprite in sprites: self.append(sprite) @@ -695,8 +690,8 @@ def insert(self, index: int, sprite: SpriteType): """ Inserts a sprite at a given index. - :param int index: The index at which to insert - :param Sprite sprite: The sprite to insert + :param index: The index at which to insert + :param sprite: The sprite to insert """ if sprite in self.sprite_list: raise ValueError("Sprite is already in list") @@ -786,7 +781,7 @@ def create_y_pos_comparison(sprite): spritelist.sort(key=create_y_pos_comparison) :param key: A function taking a sprite as an argument returning a comparison key - :param bool reverse: If set to ``True`` the sprites will be sorted in reverse + :param reverse: If set to ``True`` the sprites will be sorted in reverse """ # Ensure the index buffer is normalized self._normalize_index_buffer() @@ -869,8 +864,8 @@ def move(self, change_x: float, change_y: float) -> None: This can be a very expensive operation depending on the size of the sprite list. - :param float change_x: Amount to change all x values by - :param float change_y: Amount to change all y values by + :param change_x: Amount to change all x values by + :param change_y: Amount to change all y values by """ for sprite in self.sprite_list: sprite.center_x += change_x @@ -881,7 +876,7 @@ def preload_textures(self, texture_list: List["Texture"]) -> None: Preload a set of textures that will be used for sprites in this sprite list. - :param array texture_list: List of textures. + :param texture_list: List of textures. """ if not self.ctx: raise ValueError("Cannot preload textures before the window is created") @@ -1173,7 +1168,7 @@ def _update_position(self, sprite: SpriteType) -> None: ``update_location`` should be called to move them once the sprites are in the list. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_pos_data[slot * 3] = sprite._position[0] @@ -1188,7 +1183,7 @@ def _update_position_x(self, sprite: SpriteType) -> None: ``update_location`` should be called to move them once the sprites are in the list. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_pos_data[slot * 3] = sprite._position[0] @@ -1202,7 +1197,7 @@ def _update_position_y(self, sprite: SpriteType) -> None: ``update_location`` should be called to move them once the sprites are in the list. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_pos_data[slot * 3 + 1] = sprite._position[1] @@ -1213,7 +1208,7 @@ def _update_depth(self, sprite: SpriteType) -> None: Called by the Sprite class to update the depth of the specified sprite. Necessary for batch drawing of items. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_pos_data[slot * 3 + 2] = sprite._depth @@ -1225,7 +1220,7 @@ def _update_color(self, sprite: SpriteType) -> None: of the specified sprite. Necessary for batch drawing of items. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_color_data[slot * 4] = int(sprite._color[0]) @@ -1239,7 +1234,7 @@ def _update_size(self, sprite: SpriteType) -> None: Called by the Sprite class to update the size/scale in this sprite. Necessary for batch drawing of items. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_size_data[slot * 2] = sprite._width @@ -1251,7 +1246,7 @@ def _update_width(self, sprite: SpriteType): Called by the Sprite class to update the size/scale in this sprite. Necessary for batch drawing of items. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_size_data[slot * 2] = sprite._width @@ -1262,7 +1257,7 @@ def _update_height(self, sprite: SpriteType): Called by the Sprite class to update the size/scale in this sprite. Necessary for batch drawing of items. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_size_data[slot * 2 + 1] = sprite._height @@ -1273,7 +1268,7 @@ def _update_angle(self, sprite: SpriteType): Called by the Sprite class to update the angle in this sprite. Necessary for batch drawing of items. - :param Sprite sprite: Sprite to update. + :param sprite: Sprite to update. """ slot = self.sprite_slot[sprite] self._sprite_angle_data[slot] = sprite._angle diff --git a/arcade/text.py b/arcade/text.py index 8a5ef12bd..a14b427c2 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -97,7 +97,7 @@ def _draw_pyglet_label(label: pyglet.text.Label) -> None: Originally part of draw_text in this module, now abstracted and improved so that both arcade.Text and arcade.draw_text can make use of it. - :param pyglet.text.Label label: a pyglet label to wrap and draw + :param label: a pyglet label to wrap and draw """ assert isinstance(label, pyglet.text.Label) window = arcade.get_window() @@ -128,24 +128,24 @@ class Text: :py:func:`~arcade.draw_text`. See its documentation for in-depth explanation for how to use each of them. For example code, see :ref:`drawing_text_objects`. - :param str text: Initial text to display. Can be an empty string - :param float start_x: x position to align the text's anchor point with - :param float start_y: y position to align the text's anchor point with - :param float start_z: z position to align the text's anchor point with - :param RGBA255 color: Color of the text as an RGBA tuple or a + :param text: Initial text to display. Can be an empty string + :param start_x: x position to align the text's anchor point with + :param start_y: y position to align the text's anchor point with + :param start_z: z position to align the text's anchor point with + :param color: Color of the text as an RGBA tuple or a :py:class:`~arcade.types.Color` instance. - :param float font_size: Size of the text in points - :param float width: A width limit in pixels - :param str align: Horizontal alignment; values other than "left" require width to be set + :param font_size: Size of the text in points + :param width: A width limit in pixels + :param align: Horizontal alignment; values other than "left" require width to be set :param Union[str, Tuple[str, ...]] font_name: A font name, path to a font file, or list of names - :param bool bold: Whether to draw the text as bold - :param bool italic: Whether to draw the text as italic - :param str anchor_x: How to calculate the anchor point's x coordinate. + :param bold: Whether to draw the text as bold + :param italic: Whether to draw the text as italic + :param anchor_x: How to calculate the anchor point's x coordinate. Options: "left", "center", or "right" - :param str anchor_y: How to calculate the anchor point's y coordinate. + :param anchor_y: How to calculate the anchor point's y coordinate. Options: "top", "bottom", "center", or "baseline". - :param bool multiline: Requires width to be set; enables word wrap rather than clipping - :param float rotation: rotation in degrees, counter-clockwise from horizontal + :param multiline: Requires width to be set; enables word wrap rather than clipping + :param rotation: rotation in degrees, counter-clockwise from horizontal All constructor arguments other than ``text`` have a corresponding property. To access the current text, use the ``value`` property @@ -540,9 +540,9 @@ def draw_debug( Draw test with debug geometry showing the content area, outline and the anchor point. - :param RGBA255 anchor_color: Color of the anchor point - :param RGBA255 background_color: Color the content background - :param RGBA255 outline_color: Color of the content outline + :param anchor_color: Color of the anchor point + :param background_color: Color the content background + :param outline_color: Color of the content outline """ left = self.left right = self.right @@ -607,18 +607,18 @@ def create_text_sprite( it is added to a SpriteList which uses a different atlas, you will likely just see a black box drawn in its place. - :param str text: Initial text to display. Can be an empty string - :param RGBA255 color: Color of the text as a tuple or list of 3 (RGB) or 4 (RGBA) integers - :param float font_size: Size of the text in points - :param float width: A width limit in pixels - :param str align: Horizontal alignment; values other than "left" require width to be set - :param FontNameOrNames font_name: A font name, path to a font file, or list of names - :param bool bold: Whether to draw the text as bold - :param bool italic: Whether to draw the text as italic - :param str anchor_x: How to calculate the anchor point's x coordinate. + :param text: Initial text to display. Can be an empty string + :param color: Color of the text as a tuple or list of 3 (RGB) or 4 (RGBA) integers + :param font_size: Size of the text in points + :param width: A width limit in pixels + :param align: Horizontal alignment; values other than "left" require width to be set + :param font_name: A font name, path to a font file, or list of names + :param bold: Whether to draw the text as bold + :param italic: Whether to draw the text as italic + :param anchor_x: How to calculate the anchor point's x coordinate. Options: "left", "center", or "right" - :param bool multiline: Requires width to be set; enables word wrap rather than clipping - :param Optional[arcade.TextureAtlas] texture_atlas: The texture atlas to use for the + :param multiline: Requires width to be set; enables word wrap rather than clipping + :param texture_atlas: The texture atlas to use for the newly created texture. The default global atlas will be used if this is None. """ text_object = Text( @@ -701,22 +701,22 @@ def draw_text( Example code can be found at :ref:`drawing_text`. - :param Any text: Text to display. The object passed in will be converted to a string - :param float start_x: x position to align the text's anchor point with - :param float start_y: y position to align the text's anchor point with - :param float start_z: z position to align the text's anchor point with - :param RGBA255 color: Color of the text as an RGBA tuple or + :param text: Text to display. The object passed in will be converted to a string + :param start_x: x position to align the text's anchor point with + :param start_y: y position to align the text's anchor point with + :param start_z: z position to align the text's anchor point with + :param color: Color of the text as an RGBA tuple or :py:class:`~arcade.types.Color` instance. - :param float font_size: Size of the text in points - :param float width: A width limit in pixels - :param str align: Horizontal alignment; values other than "left" require width to be set + :param font_size: Size of the text in points + :param width: A width limit in pixels + :param align: Horizontal alignment; values other than "left" require width to be set :param Union[str, Tuple[str, ...]] font_name: A font name, path to a font file, or list of names - :param bool bold: Whether to draw the text as bold - :param bool italic: Whether to draw the text as italic - :param str anchor_x: How to calculate the anchor point's x coordinate - :param str anchor_y: How to calculate the anchor point's y coordinate - :param bool multiline: Requires width to be set; enables word wrap rather than clipping - :param float rotation: rotation in degrees, counter-clockwise from horizontal + :param bold: Whether to draw the text as bold + :param italic: Whether to draw the text as italic + :param anchor_x: How to calculate the anchor point's x coordinate + :param anchor_y: How to calculate the anchor point's y coordinate + :param multiline: Requires width to be set; enables word wrap rather than clipping + :param rotation: rotation in degrees, counter-clockwise from horizontal By default, the text is placed so that: diff --git a/arcade/texture/generate.py b/arcade/texture/generate.py index 61a273d8d..a9102e6fe 100644 --- a/arcade/texture/generate.py +++ b/arcade/texture/generate.py @@ -26,10 +26,10 @@ def make_circle_texture( """ Return a Texture of a circle with the given diameter and color. - :param int diameter: Diameter of the circle and dimensions of the square :class:`Texture` returned. - :param RGBA255 color: Color of the circle as a + :param diameter: Diameter of the circle and dimensions of the square :class:`Texture` returned. + :param color: Color of the circle as a :py:class:`~arcade.types.Color` instance a 3 or 4 tuple. - :param str name: Custom or pre-chosen name for this texture + :param name: Custom or pre-chosen name for this texture :returns: New :class:`Texture` object. """ @@ -54,16 +54,15 @@ def make_soft_circle_texture( """ Return a :class:`Texture` of a circle with the given diameter and color, fading out at its edges. - :param int diameter: Diameter of the circle and dimensions of the square :class:`Texture` returned. - :param RGBA255 color: Color of the circle as a 4-length tuple or + :param diameter: Diameter of the circle and dimensions of the square :class:`Texture` returned. + :param color: Color of the circle as a 4-length tuple or :py:class:`~arcade.types.Color` instance. - :param int center_alpha: Alpha value of the circle at its center. - :param int outer_alpha: Alpha value of the circle at its edges. - :param str name: Custom or pre-chosen name for this texture - :param str hit_box_algorithm: The hit box algorithm + :param center_alpha: Alpha value of the circle at its center. + :param outer_alpha: Alpha value of the circle at its edges. + :param name: Custom or pre-chosen name for this texture + :param hit_box_algorithm: The hit box algorithm :returns: New :class:`Texture` object. - :rtype: arcade.Texture """ # Name must be unique for caching name = cache.crate_str_from_values( @@ -108,11 +107,11 @@ def make_soft_square_texture( """ Return a :class:`Texture` of a square with the given diameter and color, fading out at its edges. - :param int size: Diameter of the square and dimensions of the square Texture returned. - :param RGBA255 color: Color of the square. - :param int center_alpha: Alpha value of the square at its center. - :param int outer_alpha: Alpha value of the square at its edges. - :param str name: Custom or pre-chosen name for this texture + :param size: Diameter of the square and dimensions of the square Texture returned. + :param color: Color of the square. + :param center_alpha: Alpha value of the square at its center. + :param outer_alpha: Alpha value of the square at its edges. + :param name: Custom or pre-chosen name for this texture :returns: New :class:`Texture` object. """ diff --git a/arcade/texture/loading.py b/arcade/texture/loading.py index f6e6eb6aa..0aef48ff1 100644 --- a/arcade/texture/loading.py +++ b/arcade/texture/loading.py @@ -34,12 +34,12 @@ def load_texture( specify a sub-rectangle of the image to load. If not specified, the entire image is loaded. - :param str file_name: Name of the file to that holds the texture. - :param int x: X coordinate of the texture in the image. - :param int y: Y coordinate of the texture in the image. - :param int width: Width of the texture in the image. - :param int height: Height of the texture in the image. - :param str hit_box_algorithm: + :param file_name: Name of the file to that holds the texture. + :param x: X coordinate of the texture in the image. + :param y: Y coordinate of the texture in the image. + :param width: Width of the texture in the image. + :param height: Height of the texture in the image. + :param hit_box_algorithm: :returns: New :class:`Texture` object. :raises: ValueError """ @@ -69,12 +69,12 @@ def _load_tilemap_texture( specify a sub-rectangle of the image to load. If not specified, the entire image is loaded. - :param str file_name: Name of the file to that holds the texture. - :param int x: X coordinate of the texture in the image. - :param int y: Y coordinate of the texture in the image. - :param int width: Width of the texture in the image. - :param int height: Height of the texture in the image. - :param str hit_box_algorithm: + :param file_name: Name of the file to that holds the texture. + :param x: X coordinate of the texture in the image. + :param y: Y coordinate of the texture in the image. + :param width: Width of the texture in the image. + :param height: Height of the texture in the image. + :param hit_box_algorithm: :returns: New :class:`Texture` object. :raises: ValueError """ @@ -136,8 +136,8 @@ def _load_or_get_image( """ Load an image, or return a cached version - :param str file_path: Path to image - :param str hit_box_algorithm: The hit box algorithm + :param file_path: Path to image + :param hit_box_algorithm: The hit box algorithm :param hash: Hash of the image :return: Tuple of image data and a boolean indicating if the image was fetched from cache @@ -169,8 +169,8 @@ def load_texture_pair( Load a texture pair, with the second being a mirror image of the first. Useful when doing animations and the character can face left/right. - :param str file_name: Path to texture - :param str hit_box_algorithm: The hit box algorithm + :param file_name: Path to texture + :param hit_box_algorithm: The hit box algorithm """ LOG.info("load_texture_pair: %s ", file_name) texture = load_texture(file_name, hit_box_algorithm=hit_box_algorithm) @@ -196,13 +196,13 @@ def load_textures( left, see: http://programarcadegames.com/index.php?chapter=introduction_to_graphics&lang=en#section_5 - :param str file_name: Name of the file. - :param List image_location_list: List of image sub-locations. Each rectangle should be + :param file_name: Name of the file. + :param image_location_list: List of image sub-locations. Each rectangle should be a `List` of four floats: `[x, y, width, height]`. - :param bool mirrored: If set to `True`, the image is mirrored left to right. - :param bool flipped: If set to `True`, the image is flipped upside down. - :param str hit_box_algorithm: One of None, 'None', 'Simple' (default) or 'Detailed'. - :param float hit_box_detail: Float, defaults to 4.5. Used with 'Detailed' to hit box + :param mirrored: If set to `True`, the image is mirrored left to right. + :param flipped: If set to `True`, the image is flipped upside down. + :param hit_box_algorithm: One of None, 'None', 'Simple' (default) or 'Detailed'. + :param hit_box_detail: Float, defaults to 4.5. Used with 'Detailed' to hit box :returns: List of :class:`Texture`'s. :raises: ValueError @@ -261,13 +261,13 @@ def load_spritesheet( hit_box_algorithm: Optional[HitBoxAlgorithm] = None, ) -> List[Texture]: """ - :param str file_name: Name of the file to that holds the texture. - :param int sprite_width: Width of the sprites in pixels - :param int sprite_height: Height of the sprites in pixels - :param int columns: Number of tiles wide the image is. - :param int count: Number of tiles in the image. - :param int margin: Margin between images - :param str hit_box_algorithm: The hit box algorithm + :param file_name: Name of the file to that holds the texture. + :param sprite_width: Width of the sprites in pixels + :param sprite_height: Height of the sprites in pixels + :param columns: Number of tiles wide the image is. + :param count: Number of tiles in the image. + :param margin: Margin between images + :param hit_box_algorithm: The hit box algorithm :returns List: List of :class:`Texture` objects. """ LOG.info("load_spritesheet: %s ", file_name) diff --git a/arcade/texture/texture.py b/arcade/texture/texture.py index 40a69373f..43a097476 100644 --- a/arcade/texture/texture.py +++ b/arcade/texture/texture.py @@ -48,8 +48,8 @@ class ImageData: The ability to provide a hash directly is mainly there for ensuring we can load and save texture atlases to disk. - :param PIL.Image.Image image: The image for this texture - :param str hash: The hash of the image + :param image: The image for this texture + :param hash: The hash of the image """ __slots__ = ("image", "hash", "__weakref__") @@ -122,11 +122,11 @@ class Texture: and the hit box data for this image used in collision detection. Usually created by the :class:`load_texture` or :class:`load_textures` commands. - :param PIL.Image.Image image: The image or ImageData for this texture - :param str hit_box_algorithm: The algorithm to use for calculating the hit box. - :param HitBox hit_box_points: A list of hitbox points for the texture to use (Optional). + :param image: The image or ImageData for this texture + :param hit_box_algorithm: The algorithm to use for calculating the hit box. + :param hit_box_points: A list of hitbox points for the texture to use (Optional). Completely overrides the hit box algorithm. - :param str hash: Optional unique name for the texture. Can be used to make this texture + :param hash: Optional unique name for the texture. Can be used to make this texture globally unique. By default the hash of the pixel data is used. """ @@ -232,9 +232,9 @@ def create_cache_name( """ Create a cache name for the texture. - :param ImageData image_data: The image data + :param image_data: The image data :param hit_box_algorithm: The hit box algorithm - :param dict hit_box_args: The hit box algorithm arguments + :param hit_box_args: The hit box algorithm arguments :param Tuple[int, int, int, int] vertex_order: The vertex order :return: str """ @@ -318,7 +318,7 @@ def image(self) -> PIL.Image.Image: It can cause problems with the texture atlas and hit box points. - :param PIL.Image.Image image: The image to set + :param image: The image to set """ return self._image_data.image @@ -351,7 +351,6 @@ def width(self) -> int: if the texture has been transformed or the size have been set manually. - :rtype: int """ return self._size[0] @@ -368,7 +367,6 @@ def height(self) -> int: if the texture has been transformed or the size have been set manually. - :rtype: int """ return self._size[1] @@ -385,7 +383,6 @@ def size(self) -> Tuple[int, int]: if the texture has been transformed or the size have been set manually. - :rtype: Tuple[int, int] """ return self._size @@ -417,9 +414,9 @@ def create_filled(cls, name: str, size: Tuple[int, int], color: RGBA255) -> "Tex """ Create a filled texture. This is an alias for :py:meth:`create_empty`. - :param str name: Name of the texture + :param name: Name of the texture :param Tuple[int, int] size: Size of the texture - :param RGBA255 color: Color of the texture + :param color: Color of the texture :return: Texture """ return cls.create_empty(name, size, color) @@ -438,8 +435,8 @@ def create_empty( with the dimensions in ``size`` because there is no non-blank pixel data to calculate a hit box. - :param str name: The unique name for this texture - :param Tuple[int,int] size: The xy size of the internal image + :param name: The unique name for this texture + :param size: The xy size of the internal image This function has multiple uses, including: @@ -586,7 +583,7 @@ def rotate_90(self, count: int = 1) -> "Texture": has updated hit box data and a transform that will be applied to the image when it's drawn (GPU side). - :param int count: Number of 90 degree steps to rotate. + :param count: Number of 90 degree steps to rotate. :return: Texture """ angles = [None, Rotate90Transform, Rotate180Transform, Rotate270Transform] @@ -627,7 +624,7 @@ def transform( """ Create a new texture with the given transform applied. - :param Transform transform: Transform to apply + :param transform: Transform to apply :return: New texture """ new_hit_box_points = transform.transform_hit_box_points(self._hit_box_points) @@ -668,11 +665,11 @@ def crop( the crop is 0 width or height, the original texture is returned. - :param int x: X position to start crop - :param int y: Y position to start crop - :param int width: Width of crop - :param int height: Height of crop - :param bool cache: If True, the cropped texture will be cached + :param x: X position to start crop + :param y: Y position to start crop + :param width: Width of crop + :param height: Height of crop + :param cache: If True, the cropped texture will be cached :return: Texture """ # Return self if the crop is the same size as the original image @@ -730,7 +727,7 @@ def remove_from_cache(self, ignore_error: bool = True) -> None: """ Remove this texture from the cache. - :param bool ignore_error: If True, ignore errors if the texture is not in the cache + :param ignore_error: If True, ignore errors if the texture is not in the cache :return: None """ _cache.texture_cache.delete(self) @@ -799,12 +796,12 @@ def draw_sized( and should be used sparingly. The method simply creates a sprite internally and draws it. - :param float center_x: X position to draw texture - :param float center_y: Y position to draw texture - :param float width: Width to draw texture - :param float height: Height to draw texture - :param float angle: Angle to draw texture - :param int alpha: Alpha value to draw texture + :param center_x: X position to draw texture + :param center_y: Y position to draw texture + :param width: Width to draw texture + :param height: Height to draw texture + :param angle: Angle to draw texture + :param alpha: Alpha value to draw texture """ from arcade import Sprite @@ -840,11 +837,11 @@ def draw_scaled( and should be used sparingly. The method simply creates a sprite internally and draws it. - :param float center_x: X location of where to draw the texture. - :param float center_y: Y location of where to draw the texture. - :param float scale: Scale to draw rectangle. Defaults to 1. - :param float angle: Angle to rotate the texture by. - :param int alpha: The transparency of the texture `(0-255)`. + :param center_x: X location of where to draw the texture. + :param center_y: Y location of where to draw the texture. + :param scale: Scale to draw rectangle. Defaults to 1. + :param angle: Angle to rotate the texture by. + :param alpha: The transparency of the texture `(0-255)`. """ from arcade import Sprite diff --git a/arcade/texture_atlas/base.py b/arcade/texture_atlas/base.py index b76355312..f1a20c7b2 100644 --- a/arcade/texture_atlas/base.py +++ b/arcade/texture_atlas/base.py @@ -82,13 +82,13 @@ class AtlasRegion: +-----------------+--------------------+ (0, 0) (1, 0) - :param str atlas: The atlas this region belongs to - :param str texture: The arcade texture - :param int x: The x position of the texture - :param int y: The y position of the texture - :param int width: The width of the texture in pixels - :param int height: The height of the texture in pixels - :param tuple texture_coordinates: The texture coordinates (optional) + :param atlas: The atlas this region belongs to + :param texture: The arcade texture + :param x: The x position of the texture + :param y: The y position of the texture + :param width: The width of the texture in pixels + :param height: The height of the texture in pixels + :param texture_coordinates: The texture coordinates (optional) """ __slots__ = ( @@ -212,11 +212,11 @@ class TextureAtlas: coordinates to flip, rotate or mirror the image. :param Tuple[int, int] size: The width and height of the atlas in pixels - :param int border: Currently no effect; Should always be 1 to avoid textures bleeding - :param Sequence[Texture] textures: The texture for this atlas - :param bool auto_resize: Automatically resize the atlas when full - :param Context ctx: The context for this atlas (will use window context if left empty) - :param int capacity: The number of textures the atlas keeps track of. + :param border: Currently no effect; Should always be 1 to avoid textures bleeding + :param textures: The texture for this atlas + :param auto_resize: Automatically resize the atlas when full + :param ctx: The context for this atlas (will use window context if left empty) + :param capacity: The number of textures the atlas keeps track of. This is multiplied by 4096. Meaning capacity=2 is 8192 textures. This value can affect the performance of the atlas. """ @@ -313,7 +313,6 @@ def width(self) -> int: """ The width of the texture atlas in pixels - :rtype: int """ return self._size[0] @@ -322,7 +321,6 @@ def height(self) -> int: """ The height of the texture atlas in pixels - :rtype: int """ return self._size[1] @@ -331,7 +329,6 @@ def size(self) -> Tuple[int, int]: """ The width and height of the texture atlas in pixels - :rtype: Tuple[int,int] """ return self._size @@ -340,7 +337,6 @@ def max_width(self) -> int: """ The maximum width of the atlas in pixels - :rtype: int """ return self._max_size[0] @@ -349,7 +345,6 @@ def max_height(self) -> int: """ The maximum height of the atlas in pixels - :rtype: int """ return self._max_size[1] @@ -358,7 +353,6 @@ def max_size(self) -> Tuple[int, int]: """ The maximum size of the atlas in pixels (x, y) - :rtype: Tuple[int,int] """ return self._max_size @@ -368,7 +362,6 @@ def auto_resize(self) -> bool: Get or set the auto resize flag for the atlas. If enabled the atlas will resize itself when full. - :rtype: bool """ return self._auto_resize @@ -381,7 +374,6 @@ def border(self) -> int: """ The texture border in pixels - :rtype: int """ return self._border @@ -390,7 +382,6 @@ def texture(self) -> "Texture2D": """ The atlas texture. - :rtype: Texture """ return self._texture @@ -399,7 +390,6 @@ def image_uv_texture(self) -> "Texture2D": """ Texture coordinate texture for images. - :rtype: Texture """ return self._image_uv_texture @@ -408,7 +398,6 @@ def texture_uv_texture(self) -> "Texture2D": """ Texture coordinate texture for textures. - :rtype: Texture """ return self._texture_uv_texture @@ -424,7 +413,6 @@ def textures(self) -> List["Texture"]: A new list is constructed from the internal weak set of textures. - :rtype: Set[Texture] """ return list(self._textures) @@ -435,7 +423,6 @@ def images(self) -> List["ImageData"]: A new list is constructed from the internal weak set of images. - :rtype: List[ImageData] """ return list(self._images) @@ -443,7 +430,7 @@ def add(self, texture: "Texture") -> Tuple[int, AtlasRegion]: """ Add a texture to the atlas. - :param Texture texture: The texture to add + :param texture: The texture to add :return: texture_id, AtlasRegion tuple """ # If the texture is already in the atlas we also have the image @@ -586,9 +573,9 @@ def write_image(self, image: PIL.Image.Image, x: int, y: int) -> None: """ Write a PIL image to the atlas in a specific region. - :param PIL.Image.Image image: The pillow image - :param int x: The x position to write the texture - :param int y: The y position to write the texture + :param image: The pillow image + :param x: The x position to write the texture + :param y: The y position to write the texture """ # Write into atlas at the allocated location + border viewport = ( @@ -644,7 +631,7 @@ def remove(self, texture: "Texture") -> None: This doesn't erase the pixel data from the atlas texture itself, but leaves the area unclaimed. - :param Texture texture: The texture to remove + :param texture: The texture to remove """ self._textures.remove(texture) # Reclaim the texture uv slot @@ -678,7 +665,7 @@ def update_texture_image(self, texture: "Texture"): faster than removing the old texture, adding the new one and re-building the entire atlas. - :param Texture texture: The texture to update + :param texture: The texture to update """ region = self._image_regions[texture.image_data.hash] region.verify_image_size(texture.image_data) @@ -694,7 +681,7 @@ def get_image_region_info(self, hash: str) -> AtlasRegion: """ Get the region info for and image by has - :param str hash: The hash of the image + :param hash: The hash of the image :return: The AtlasRegion for the given texture name """ return self._image_regions[hash] @@ -711,7 +698,7 @@ def get_texture_id(self, atlas_name: str) -> int: """ Get the uv slot for a texture by atlas name - :param str atlas_name: The name of the texture in the atlas + :param atlas_name: The name of the texture in the atlas :return: The texture id for the given texture name """ return self._texture_uv_slots[atlas_name] @@ -720,7 +707,7 @@ def get_image_id(self, hash: str) -> int: """ Get the uv slot for a image by hash - :param str hash: The hash of the image + :param hash: The hash of the image :return: The texture id for the given texture name """ return self._image_uv_slots[hash] @@ -743,7 +730,7 @@ def resize(self, size: Tuple[int, int]) -> None: and we don't have to transfer each texture individually from system memory to graphics memory. - :param Tuple[int,int] size: The new size + :param size: The new size """ LOG.info("[%s] Resizing atlas from %s to %s", id(self), self._size, size) @@ -841,8 +828,8 @@ def clear( lose track of the old texture ids. This means the sprite list must be rebuild from scratch. - :param bool texture_ids: Clear the assigned texture ids - :param bool texture: Clear the contents of the atlas texture itself + :param texture_ids: Clear the assigned texture ids + :param texture: Clear the contents of the atlas texture itself """ if texture: self._fbo.clear() @@ -867,7 +854,7 @@ def use_uv_texture(self, unit: int = 0) -> None: This is to avoid a full update every time a texture is added to the atlas. - :param int unit: The texture unit to bind the uv texture + :param unit: The texture unit to bind the uv texture """ if self._image_uv_data_changed: self._image_uv_texture.write(self._image_uv_data, 0) @@ -902,8 +889,8 @@ def render_into( with atlas.render_into(texture, projection=(0, 100, 0, 100)) # Draw geometry - :param Texture texture: The texture area to render into - :param Tuple[float,float,float,float] projection: The ortho projection to render with. + :param texture: The texture area to render into + :param projection: The ortho projection to render with. This parameter can be left blank if no projection changes are needed. The tuple values are: (left, right, button, top) """ @@ -929,8 +916,8 @@ def create_from_texture_sequence(cls, textures: Sequence["Texture"], border: int """ Create a texture atlas of a reasonable size from a sequence of textures. - :param Sequence[Texture] textures: A sequence of textures (list, set, tuple, generator etc.) - :param int border: The border for the atlas in pixels (space between each texture) + :param textures: A sequence of textures (list, set, tuple, generator etc.) + :param border: The border for the atlas in pixels (space between each texture) """ textures = sorted(set(textures), key=lambda x: x.image.size[1]) size = TextureAtlas.calculate_minimum_size(textures) @@ -942,7 +929,7 @@ def calculate_minimum_size(cls, textures: Sequence["Texture"], border: int = 1): Calculate the minimum atlas size needed to store the the provided sequence of textures - :param Sequence[Texture] textures: Sequence of textures + :param textures: Sequence of textures :param border: The border around each texture in pixels :return: An estimated minimum size as a (width, height) tuple """ @@ -977,7 +964,7 @@ def get_texture_image(self, texture: "Texture") -> Image.Image: This can be used to inspect the contents of the atlas or to save the texture to disk. - :param Texture texture: The texture to get the image for + :param texture: The texture to get the image for :return: A pillow image containing the pixel data in the atlas """ region = self.get_image_region_info(texture.image_data.hash) @@ -1008,7 +995,7 @@ def sync_texture_image(self, texture: "Texture") -> None: unless you know exactly what you're doing. Textures are supposed to be immutable. - :param Texture texture: The texture to update + :param texture: The texture to update """ texture.image_data.image = self.get_texture_image(texture) @@ -1025,9 +1012,9 @@ def to_image( Borders can also be drawn into the image to visualize the regions of the atlas. - :param bool flip: Flip the image horizontally - :param int components: Number of components. (3 = RGB, 4 = RGBA) - :param bool draw_borders: Draw region borders into image + :param flip: Flip the image horizontally + :param components: Number of components. (3 = RGB, 4 = RGBA) + :param draw_borders: Draw region borders into image :param color: RGB color of the borders :return: A pillow image containing the atlas texture """ @@ -1067,9 +1054,9 @@ def show( Borders can also be drawn into the image to visualize the regions of the atlas. - :param bool flip: Flip the image horizontally - :param int components: Number of components. (3 = RGB, 4 = RGBA) - :param bool draw_borders: Draw region borders into image + :param flip: Flip the image horizontally + :param components: Number of components. (3 = RGB, 4 = RGBA) + :param draw_borders: Draw region borders into image :param color: RGB color of the borders """ self.to_image( @@ -1093,9 +1080,9 @@ def save( Borders can also be drawn into the image to visualize the regions of the atlas. - :param str path: The path to save the atlas on disk - :param bool flip: Flip the image horizontally - :param int components: Number of components. (3 = RGB, 4 = RGBA) + :param path: The path to save the atlas on disk + :param flip: Flip the image horizontally + :param components: Number of components. (3 = RGB, 4 = RGBA) :param color: RGB color of the borders :return: A pillow image containing the atlas texture """ diff --git a/arcade/tilemap/tilemap.py b/arcade/tilemap/tilemap.py index 23955b59f..726479600 100644 --- a/arcade/tilemap/tilemap.py +++ b/arcade/tilemap/tilemap.py @@ -110,22 +110,22 @@ class TileMap: :param Union[str, Path] map_file: A JSON map file for a Tiled map to initialize from - :param float scaling: Global scaling to apply to all Sprites. + :param scaling: Global scaling to apply to all Sprites. :param Dict[str, Dict[str, Any]] layer_options: Extra parameters for each layer. - :param bool use_spatial_hash: If set to True, this will make moving a sprite + :param use_spatial_hash: If set to True, this will make moving a sprite in the SpriteList slower, but it will speed up collision detection with items in the SpriteList. Great for doing collision detection with static walls/platforms. - :param str hit_box_algorithm: The hit box algorithm to use for the Sprite's in this layer. - :param pytiled_parser.TiledMap tiled_map: An already parsed pytiled-parser map object. + :param hit_box_algorithm: The hit box algorithm to use for the Sprite's in this layer. + :param tiled_map: An already parsed pytiled-parser map object. Passing this means that the ``map_file`` argument will be ignored, and the pre-parsed map will instead be used. This can be helpful for working with Tiled World files. - :param pyglet.math.Vec2 offset: Can be used to offset the position of all sprites and objects + :param offset: Can be used to offset the position of all sprites and objects within the map. This will be applied in addition to any offsets from Tiled. This value can be overridden with the layer_options dict. - :param Optional[arcade.TextureAtlas] texture_atlas: A default texture atlas to use for the + :param texture_atlas: A default texture atlas to use for the SpriteLists created by this map. If not supplied the global default atlas will be used. - :param bool lazy: SpriteLists will be created lazily. + :param lazy: SpriteLists will be created lazily. The `layer_options` parameter can be used to specify per layer arguments. @@ -320,8 +320,8 @@ def get_cartesian( If you have a map with 128x128 pixel Tiles, and you supply coordinates 500, 250 to this function you'll receive back 3, 2 - :param float x: The X Coordinate to convert - :param float y: The Y Coordinate to convert + :param x: The X Coordinate to convert + :param y: The Y Coordinate to convert """ x = math.floor(x / (self.tile_width * self.scaling)) y = math.floor(y / (self.tile_height * self.scaling)) @@ -1025,17 +1025,17 @@ def load_tilemap( of the `TileMap` class :param Union[str, Path] map_file: The JSON map file. - :param float scaling: The global scaling to apply to all Sprite's within the map. - :param bool use_spatial_hash: If set to True, this will make moving a sprite + :param scaling: The global scaling to apply to all Sprite's within the map. + :param use_spatial_hash: If set to True, this will make moving a sprite in the SpriteList slower, but it will speed up collision detection with items in the SpriteList. Great for doing collision detection with static walls/platforms. - :param str hit_box_algorithm: The hit box algorithm to use for collision detection. + :param hit_box_algorithm: The hit box algorithm to use for collision detection. :param Dict[str, Dict[str, Any]] layer_options: Layer specific options for the map. - :param pyglet.math.Vec2 offset: Can be used to offset the position of all sprites and objects + :param offset: Can be used to offset the position of all sprites and objects within the map. This will be applied in addition to any offsets from Tiled. This value can be overridden with the layer_options dict. - :param bool lazy: SpriteLists will be created lazily. + :param lazy: SpriteLists will be created lazily. """ return TileMap( map_file=map_file, diff --git a/arcade/types.py b/arcade/types.py index 28f312d96..6dce6ed51 100644 --- a/arcade/types.py +++ b/arcade/types.py @@ -270,7 +270,7 @@ def from_uint32(cls, color: int) -> Self: >>> Color.from_uint32(0xFF0000FF) Color(r=255, g=0, b=0, a=255) - :param int color: An int between 0 and 4294967295 (``0xFFFFFFFF``) + :param color: An int between 0 and 4294967295 (``0xFFFFFFFF``) """ if not 0 <= color <= MAX_UINT32: raise IntOutsideRangeError("color", color, 0, MAX_UINT32) @@ -301,7 +301,7 @@ def from_normalized(cls, color_normalized: RGBANormalized) -> Self: >>> Color.from_normalized(normalized_half_opacity_green) Color(r=0, g=255, b=0, a=127) - :param RGBANormalized color_normalized: The color as normalized (0.0 to 1.0) RGBA values. + :param color_normalized: The color as normalized (0.0 to 1.0) RGBA values. :return: """ r, g, b, *_a = color_normalized @@ -399,10 +399,10 @@ def random( >>> Color.random(a=255) Color(r=25, g=99, b=234, a=255) - :param int r: Fixed value for red channel - :param int g: Fixed value for green channel - :param int b: Fixed value for blue channel - :param int a: Fixed value for alpha channel + :param r: Fixed value for red channel + :param g: Fixed value for green channel + :param b: Fixed value for blue channel + :param a: Fixed value for alpha channel """ if r is None: r = random.randint(0, 255) diff --git a/arcade/window_commands.py b/arcade/window_commands.py index dfacc931c..381fdd500 100644 --- a/arcade/window_commands.py +++ b/arcade/window_commands.py @@ -50,9 +50,8 @@ def get_display_size(screen_id: int = 0) -> Tuple[int, int]: The size of the primary monitor is returned by default. - :param int screen_id: The screen number + :param screen_id: The screen number :return: Tuple containing the width and height of the screen - :rtype: tuple """ display = pyglet.canvas.Display() screen = display.get_screens()[screen_id] @@ -68,7 +67,7 @@ def pause(seconds: float) -> None: This is mostly used for unit tests and is not likely to be a good solution for pausing an application or game. - :param float seconds: Time interval to pause in seconds. + :param seconds: Time interval to pause in seconds. """ time.sleep(cast(float, seconds)) @@ -94,7 +93,7 @@ def set_window(window: Optional["Window"]) -> None: """ Set a handle to the current window. - :param Window window: Handle to the current window. + :param window: Handle to the current window. """ global _window _window = window @@ -137,10 +136,10 @@ def set_viewport(left: float, right: float, bottom: float, top: float) -> None: and ``window.ctx.viewport`` (:py:meth:`~arcade.gl.Context.viewport`) can be used to set viewport and projection separately. - :param Number left: Left-most (smallest) x value. - :param Number right: Right-most (largest) x value. - :param Number bottom: Bottom (smallest) y value. - :param Number top: Top (largest) y value. + :param left: Left-most (smallest) x value. + :param right: Right-most (largest) x value. + :param bottom: Bottom (smallest) y value. + :param top: Top (largest) y value. """ window = get_window() # Get the active framebuffer @@ -338,8 +337,8 @@ def some_action(delta_time): arcade.schedule(some_action, 1) # Unschedule - :param Callable function_pointer: Pointer to the function to be called. - :param float interval: Interval to call the function (float or integer) + :param function_pointer: Pointer to the function to be called. + :param interval: Interval to call the function (float or integer) """ pyglet.clock.schedule_interval(function_pointer, interval) @@ -356,7 +355,7 @@ def some_action(delta_time): arcade.schedule(some_action, 1) arcade.unschedule(some_action) - :param Callable function_pointer: Pointer to the function to be unscheduled. + :param function_pointer: Pointer to the function to be unscheduled. """ pyglet.clock.unschedule(function_pointer) @@ -376,7 +375,7 @@ def some_action(delta_time): # Call the function once after 1 second arcade.schedule_one(some_action, 1) - :param Callable function_pointer: Pointer to the function to be called. - :param float delay: Delay in seconds + :param function_pointer: Pointer to the function to be called. + :param delay: Delay in seconds """ pyglet.clock.schedule_once(function_pointer, delay) diff --git a/doc/conf.py b/doc/conf.py index a2f981ef1..01a99c7a6 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -175,6 +175,13 @@ "ref.python", ] +def strip_init_return_typehint(app, what, name, obj, options, signature, return_annotation): + # Prevent a the `-> None` annotation from appearing after classes. + # This annotation comes from the `__init__`, but it renders on the class, + # e.g. `Foo() -> None` + # From the user's perspective, this is wrong: `Foo() -> Foo` not `None` + if what == "class" and return_annotation is None: + return (signature, None) def warn_undocumented_members(_app, what, name, _obj, _options, lines): if len(lines) == 0: @@ -288,5 +295,6 @@ def setup(app): app.connect('source-read', source_read) app.connect('build-finished', post_process) app.connect("autodoc-process-docstring", warn_undocumented_members) + app.connect('autodoc-process-signature', strip_init_return_typehint, -1000) app.connect('autodoc-process-bases', on_autodoc_process_bases) app.add_transform(Transform) diff --git a/util/convert_rst_to_google_docs.py b/util/convert_rst_to_google_docs.py new file mode 100644 index 000000000..2fda3b1d8 --- /dev/null +++ b/util/convert_rst_to_google_docs.py @@ -0,0 +1,64 @@ +import glob +import re + +fn_signature_w_docstring_regexp = re.compile( + r""" + (?P + (?P + def \s+ + (?P \S+ ) # Function name + \( .*? \) # Parameter list + ) + (?P # Return type annotation + \s* -> \s* + (?P .{1,300}? ) + )? + : + ) + [\r?\n\s]+ + (?P + \"\"\" # Docstring start + (?P .*? ) + \"\"\" # Docstring end + ) + """, + re.X | re.DOTALL) +docstring_rtype_regexp = re.compile( + r""" + \ + + :rtype: \s* (?P .*? ) \r?\n + """, + re.X | re.DOTALL) + +count = 0 +for file in [*glob.glob('arcade/*.py'), *glob.glob('arcade/**/*.py')]: + with open(file, "r") as f: + content = f.read() + pos = 0 + while True: + match = fn_signature_w_docstring_regexp.search(content, pos=pos) + if match: + offset = 0 + match2 = docstring_rtype_regexp.search(match.group('docstring')) + if match2: + # print(match.groupdict() | match2.groupdict()) + # print(match.group('fn_signature') + match.group('docstring')) + count += 1 + if match2: + # Remove rtype annotation from docstring + range = match.start('docstring') + match2.start(), match.start('docstring') + match2.end() + offset -= range[1] - range[0] + content = content[:range[0]] + content[range[1]:] + if match2 and not match.group('rtype_anno'): + print(file, match.group('fn_name')) + insert = f" -> {match2.group('rtype')}" + pos = match.end('fn_signature_before') + content = content[:pos] + insert + content[pos:] + offset += len(insert) + + pos = match.end() + offset + else: + break + with open(file, "w") as f: + f.write(content) +print(count) \ No newline at end of file