Date | 2021-12-16 (1,065 days ago) |
---|---|
Downloads | 6,979 downloads |
NuGet | View on NuGet |
GitHub | View on GitHub |
Target Frameworks | .NET Standard 1.1 .NET Standard 1.3 .NET 4.5 .NET 4.6 .NET 4.7 |
#installation
">Installation#changelog
">ChangelogAdded more conversion logic to the ColorUtils
class (see 9031c57
, fd4fde5
, f0086b0
)
This adds more logic for converting back and forth between the supported color models.
Added support for the HSV color model (see 0f86d11
)
This release adds support for the HSV color model, which works in a similar way to HSL, but differs with the Value component opposed to the Lightness component of HSL.
Introduced new extension methods for various color operations (see 45855cb
)
The ColorExtensions
class now contains Saturate
, Desaturate
, Darken
, Lighten
, Invert
and Grayscale
extension methods for doing operations on IColor
instances.
Introduced new ColorUtils.HexToRgb
utility methods (see #2
, c1c558f
, 7d41437
)
The methods either allow converting a HEX string value into an instance of RgbColor
or into corresponding red
, green
and blue
components - thanks to a PR from @hfloyd.
Copied logic from ColorHelpers
class into the ColorUtils
class, and marked the ColorHelpers
class as obsolete (see #3
, 7d41437
and 09cf9db
)
Being a class with static utility methods, the class should be called ColorUtils
instead of ColorHelpers
to matching the name in our other packages. The ColorHelpers
class is still kept for backwards compatibility, but now marked as obsolete.
Introduced new WcagUtils
to replace the WcagHelpes
class (see 6a4c321
)
Being a class with static utility methods, the class should be called WcagUtils
instead of WcagHelpes
to matching the name in our other packages. The WcagHelpes
class is still kept for backwards compatibility, but now marked as obsolete.
Introduced ColorUtils.Clamp
methods (see ad52a29
and 240c528
)
The Clamp
methods are used internally throughout the package to ensure specified values are within the allowed ranges. Eg. for the RGB color model, the red
, green
and blue
components range from 0
to 255
. If a value lower than 0
is specified, the value is "clamped" to 0
, and if a value higher than 255
is specified, the value is clamped to 255
- essentially a combination of the Math.Min
and Math.Max
methods..
Introduced new ColorExtensions.Spin
extension method (see a2534be
)
When using the HSL color model, the hue
component is specified as an angle on a circle, and the Spin
method can be used to increate or decrease the angle to get a different color, but with the same saturation
and lightness
values.
Added support for alpha values (see 4a0260a
and 9720a8b
)
With this release, the IColor
and the different color models now support an alpha component indicating the transparency of the color, The value ranges from 0
(fully transparent) to 1
(fully opaque).
Introduced new HexFormat
enum class and ToHex
method overload to support both RGB and RGBA (see 9720a8b
)
By default the parameterless ToHex
method returns a HEX value in the format of #RRGGBB
for fully opaque colors, and in the format of #RRGGBBAA
for non-opaque colors, which calling the new overload with HexFormat.Auto
. If either of the two formats is always preferred, HexFormat.Rgb
can be used to force the format to be #RRGGBB
, and HexFormat.Rgba
can be used to force the format to be #RRGGBBAA
.
Introduced new ColorUtils.GetGradientColors
and ColorUtils.GetGradientColorsAsHex
methods (see #4
, f8b613d
, 435e7df
, 3cac602
and 1f259f3
)
Thanks to another PR from @hfloyd, the ColorUtils.GetGradientColors
method allows generating a collection of IColor
instances representing a gradient starting from startColor
to endColor
. The GetGradientColorsAsHex
allows doing the same, but with HEX string values as both input and output.
Added support for HEX alpha values to the ColorUtils.TryParse method (see d9ad869
)
As part of adding alpha level support, the ColorUtils.TryParse
method now also supports the #RRGGBBAA
format.
Introduced new ToCmy
, ToCmyk
, ToHsl
, ToHsv
and ToRgb
extension methods for converting a collection of IColor
to a specific color model (see dd2a753
)
The new extension methods allows converting multiple colors to a given color model. Eg. the ToRgb
extension method converts a collection of IColor
into a corresponding collection of RgbColor
.