MichaelCharles/clay_containers

Useless complexity

vfsfitvnm opened this issue · 1 comments

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?

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.