Skip to content

The Rect, Pt. II: The Rect-oning and the Vec-oning #2096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
79201fc
add .rect to BasicSprite
DigiDuncan May 26, 2024
97444a8
fix minor linting issues in BasicSprite
DigiDuncan May 26, 2024
91b124b
texture.draw_rect
DigiDuncan May 26, 2024
82cd7a3
rect.distance_from_bounds
DigiDuncan May 26, 2024
514a5aa
add Rect and Vec to top level
DigiDuncan May 26, 2024
40cc453
docstring fixes
DigiDuncan May 28, 2024
41322bc
Remove formatted style at opening of docstring
pushfoo May 28, 2024
4db435c
__contains__ and doc Kwargs
DigiDuncan May 29, 2024
5029220
doc weee
DigiDuncan May 29, 2024
6169edf
start changelog, add Point2 and Point3
DigiDuncan May 29, 2024
130910b
add Point back
DigiDuncan May 29, 2024
bf05ca5
Remove IntRect, FloatRect, RectList
DigiDuncan May 29, 2024
6f5d94c
old Rect -> GUIRect
DigiDuncan May 29, 2024
4507a6b
changelog
DigiDuncan May 29, 2024
698cd9e
accept tuples
DigiDuncan May 29, 2024
0bf0d48
changelog
DigiDuncan May 29, 2024
1a269ed
camera now take tuples if you feel like it
DigiDuncan May 29, 2024
4856a4e
Camera vectified and tests corrected.
DragonMoffon May 29, 2024
7284c73
Added Section.rect
DigiDuncan May 29, 2024
cab8a31
add SpriteSolidColor.from_rect
DigiDuncan May 29, 2024
2a543af
from_rect
DigiDuncan May 29, 2024
62f4a28
__mul__ and __div__
DigiDuncan May 29, 2024
f959613
new doublescore methods
DigiDuncan May 29, 2024
cc89567
Rectifying camera and correcting all issues this causes
DragonMoffon May 29, 2024
092cc09
linting touchups + __truediv__ fix for rect
DragonMoffon May 29, 2024
630c57b
linting continued
DragonMoffon May 29, 2024
02354bd
updated PR.md
DragonMoffon May 29, 2024
8caf504
hey pos is vec!
DragonMoffon May 29, 2024
610ad11
Update from_camera_data docstring
pushfoo May 29, 2024
3cbb1c4
Remove PR.md
DigiDuncan May 29, 2024
415474f
add UV helpers and Window.rect
DigiDuncan May 29, 2024
1fd7a2e
BasicSprite.scale_xy is a Vec2 now
DigiDuncan May 29, 2024
fb39ca4
fix setter for .scale_xy
DigiDuncan May 29, 2024
27d0ba8
make 3.8 happy
DigiDuncan May 29, 2024
b0fb4f5
finish scale_xy Vec2ificiation
DigiDuncan May 29, 2024
dd48d37
oops, forgot to cast to Vec2
DigiDuncan May 29, 2024
ee82cea
Improve some Rect doc
pushfoo May 30, 2024
5f96813
E501 can kick the bucket
DigiDuncan May 30, 2024
b717d64
Fix mypy issues with background_color by moving setter back to where …
pushfoo May 30, 2024
3b0c842
Silence error for an intentional Liskov principle violation on __mul__
pushfoo May 30, 2024
fe72c5a
Attempt to fix pyright issues with generics
pushfoo May 30, 2024
50276ca
Fix ruff linting issue and clean up some imports
pushfoo May 30, 2024
8ecb1e9
Fixed pyright completely
DragonMoffon May 30, 2024
041af63
ruff fix
DragonMoffon May 30, 2024
3240051
Revert generic projector protocol
pushfoo May 31, 2024
57265a7
Add comments explaining uses @alejcas asked about
pushfoo May 31, 2024
eeb4612
Document AnchorPoint more clearly
pushfoo May 31, 2024
1d6d2fc
Move non-obsolete vector-like annotations to vector_like
pushfoo May 31, 2024
79e7da0
sorry push I want this to be green before I go to bed
DigiDuncan May 31, 2024
100897d
Shorten line length a little in RectKwargs
pushfoo May 31, 2024
508dadb
Partial cleanup attempts for rect doc
pushfoo Jun 1, 2024
1c73ebd
Merge pull request #8 from pushfoo/attempt_clean_rect_ii
DragonMoffon Jun 1, 2024
68b595c
more minor doc cleanup
DigiDuncan Jun 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions arcade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def configure_logging(level: Optional[int] = None):

from .camera import Camera2D

from .types.rect import Rect, LRBT, LBWH, XYWH

# Module imports
from arcade import color as color
from arcade import csscolor as csscolor
Expand All @@ -231,6 +233,9 @@ def configure_logging(level: Optional[int] = None):
from arcade import experimental as experimental
from arcade.types import rect

# For ease of access for beginners
from pyglet.math import Vec2, Vec3, Vec4

from .text import (
draw_text,
load_font,
Expand Down Expand Up @@ -261,6 +266,10 @@ def configure_logging(level: Optional[int] = None):
'PymunkException',
'PymunkPhysicsEngine',
'PymunkPhysicsObject',
'Rect',
'LBWH',
'LRBT',
'XYWH',
'Section',
'SectionManager',
'Scene',
Expand All @@ -280,6 +289,9 @@ def configure_logging(level: Optional[int] = None):
'TextureAtlas',
'TileMap',
'VERSION',
'Vec2',
'Vec3',
'Vec4',
'View',
'Window',
'astar_calculate_path',
Expand Down
6 changes: 6 additions & 0 deletions arcade/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from arcade.context import ArcadeContext
from arcade.types import Color, RGBOrA255, RGBANormalized
from arcade import SectionManager
from arcade.types.rect import LBWH, Rect
from arcade.utils import is_raspberry_pi

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -315,6 +316,11 @@ def background_color(self) -> Color:
def background_color(self, value: RGBOrA255):
self._background_color = Color.from_iterable(value)

@property
def rect(self) -> Rect:
"""Return a Rect describing the size of the window."""
return LBWH(0, 0, self.width, self.height)

def run(self) -> None:
"""
Run the main loop.
Expand Down
8 changes: 4 additions & 4 deletions arcade/cache/hit_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import Optional, Union, TYPE_CHECKING
from collections import OrderedDict

from arcade.types import PointList
from arcade.types import Point2List
from arcade.resources import resolve

if TYPE_CHECKING:
Expand All @@ -36,15 +36,15 @@ class HitBoxCache:
VERSION = 1

def __init__(self):
self._entries: OrderedDict[str, PointList] = OrderedDict()
self._entries: OrderedDict[str, Point2List] = OrderedDict()

def __len__(self) -> int:
return len(self._entries)

def __iter__(self):
return iter(self._entries)

def get(self, name_or_texture: Union[str, "Texture"]) -> Optional[PointList]:
def get(self, name_or_texture: Union[str, "Texture"]) -> Optional[Point2List]:
"""
Get the hit box points for a texture with a given hash
and hit box algorithm.
Expand All @@ -68,7 +68,7 @@ def get(self, name_or_texture: Union[str, "Texture"]) -> Optional[PointList]:
else:
raise TypeError(f"Expected str or Texture: {name_or_texture}")

def put(self, name_or_texture: Union[str, "Texture"], points: PointList) -> None:
def put(self, name_or_texture: Union[str, "Texture"], points: Point2List) -> None:
"""
Store hit box points for a texture.

Expand Down
Loading
Loading