Skip to content
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

[WIP] Refactor colors #718

Draft
wants to merge 17 commits into
base: canon
Choose a base branch
from
Draft

[WIP] Refactor colors #718

wants to merge 17 commits into from

Conversation

adamaaronson
Copy link

@adamaaronson adamaaronson commented May 20, 2024

🚨 This is a breaking change, affecting the parameters when defining shapes and setting a scene's background color. 🚨

Addresses issue #449.

Done:

  • Created colors module to represent RGB colors
  • Refactored Shape colors, Scene background color, and Text color to use the new Color class
  • Fixed example code and test code to use the new Color class
  • Write tests for colors

Next steps:

  • Add more ways to define colors (by hex? by name?)

@adamaaronson adamaaronson requested a review from a team as a code owner May 20, 2024 19:53
@AstraLuma AstraLuma marked this pull request as draft May 20, 2024 20:15
ppb/colors.py Outdated
import colorsys

@dataclass()
class Color():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to call this RGB instead?

ppb/colors.py Outdated
return (self.red, self.green, self.blue)

@staticmethod
def from_hsv(hue: float, saturation: float, value: float):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have HSV().to_rgb()?

@pathunstrom your thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concerned about that approach - I think there should only be one class for color so that it is intuitive to users that that’s the class they should plug in whenever they need to use a color. Don’t want people to accidentally use an HSV color when the class is expecting an RGB color, for example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to refactor it into an abstract base class Color, with RGBColor and HSVColor subclasses that all have a to_rgb() method that should generally be abstracted away from the user. Let me know what you think!

@adamaaronson adamaaronson requested a review from AstraLuma May 21, 2024 15:46
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