clay_containers icon indicating copy to clipboard operation
clay_containers copied to clipboard

Useless complexity

Open vfsfitvnm opened this issue 3 years ago • 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?

vfsfitvnm avatar Feb 28 '21 18:02 vfsfitvnm

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.

MichaelCharles avatar Mar 10 '21 02:03 MichaelCharles