Skip to content

Allow SpriteList.draw_hit_boxes to take RGB colors #2577

Open
@pushfoo

Description

Enhancement request:

What should be added/changed?

Allow SpriteList.draw_hit_boxes to take RGB colors.

What would it help with?

This splits part of #2066 off:

  • for NBA2ker on Discord as a first-time contribution
  • a test of GitHub's new sub-issue feature within Arcade

Proposed implementation:

In this file at this location:

def draw_hit_boxes(self, color: RGBA255 = (0, 0, 0, 255), line_thickness: float = 1.0) -> None:
"""
Draw all the hit boxes in this list.
.. warning:: This method is slow and should only be used for debugging.
Args:
color: The color of the hit boxes
line_thickness: The thickness of the lines
"""
# NOTE: Find a way to efficiently draw this
for sprite in self.sprite_list:
sprite.draw_hit_box(color, line_thickness)

  • Change the annotation for color:
    • Add an import for RGBorA255 from arcade.types to this line
      from arcade.types import RGBA255, Color, RGBANormalized, RGBOrANormalized
    • Change the annotation for color to RGBAorA255
  • Convert and store the color argument with a line like converted_color = Color.from_iterable(color)
    • Put it before the for loop (we don't want to re-convert it each time!)
  • Pass converted_color instead of color in sprite.draw_hit_box(color, line_thickness)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions