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

Useless complexity #9

Open
vfsfitvnm opened this issue Feb 28, 2021 · 1 comment
Open

Useless complexity #9

vfsfitvnm opened this issue Feb 28, 2021 · 1 comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@vfsfitvnm
Copy link

Hi, shouldn't this method be replaceable by the following simpler and more efficient code?

extension on Color {
  Color withIncrement(int amount) => 
    Color.fromRGBO(
      (this.red + amount).clamp(0, 255), (this.green + amount).clamp(0, 255), (this.blue + amount).clamp(0, 255), 1
    );
}

Or am I missing something?

@MichaelCharles
Copy link
Owner

Yeah, definitely. I'll at least rewrite that function to use the code you supplied, if not actually use an extension method like you suggested.

I'm very much willing to accept a pull request if you submit one. Otherwise I'll refactor it later myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants