Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Switch arcade.math.lerp to use a Protocol bound to a TypeVar#2310

Merged
pushfoo merged 17 commits into
developmentpythonarcade/arcade:developmentfrom
lerpablespythonarcade/arcade:lerpablesCopy head branch name to clipboard
Jul 26, 2024
Merged

Switch arcade.math.lerp to use a Protocol bound to a TypeVar#2310
pushfoo merged 17 commits into
developmentpythonarcade/arcade:developmentfrom
lerpablespythonarcade/arcade:lerpablesCopy head branch name to clipboard

Conversation

@pushfoo

@pushfoo pushfoo commented Jul 25, 2024

Copy link
Copy Markdown
Member

TL;DR: Add HasAddSubMul protocol and update Lerp functions to return Vec* where appropriate

Changes

  • Add HasAddSubMul protocol type + L TypeVar in arcade.math
  • Annotate arcade.math.lerp cleanly to allow arbitarary lerpables
  • Make lerp_2d return Vec2
  • Make lerp_3d return Vec3
  • Docstring updates
  • Cross-references for lerp_angle

Follow-up work

  • Should we have lerp check for an object.lerp method?
  • How do we integrate that into type annotations?

One option for the latter is something like this:

# Assume HasAddSubMul is the same as now

class HasLerp(Protocol[_T, _R]):
    def lerp(other: _T) -> _R:
  • Weigh upstreaming the positional slash for maximum fidelity to math built-ins?

@pushfoo pushfoo marked this pull request as ready for review July 25, 2024 14:33
@pushfoo pushfoo changed the title Lerpables Switch arcade.math.lerp to use a Protocol bound to a TypeVar Jul 25, 2024
@pushfoo

pushfoo commented Jul 25, 2024

Copy link
Copy Markdown
Member Author

As an update to this, it looks like only pyglet vector objects have the lerp method. The matrices do not.

@pushfoo pushfoo merged commit 7d9a26d into development Jul 26, 2024
@einarf einarf deleted the lerpables branch July 28, 2024 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.