Extension method library for actions on System.Dra

2019-04-10 05:23发布

问题:

Has anyone written a nice extension method 'library' for System.Drawing.Color.

Would be nice to say :

 Color.Red.AdjustBrightness(.5)
 Color.Red.AdjustAlpha(.5)
 Color.Red.ToHSV()

or something like that.

Alpha is easy, but others become time consuming because you have to go off and fine all the right mathematical equations for HSV and HSB and all that fun stuff.

Hoping someone else had done the work already :-) Microsoft doesn't seem to want to do it for me.

回答1:

CodeProject has some code for an HSBColor class. It doesn't include extension methods, but they would be very straightforward to write once you have the HSBColor class and its associated conversion code available.