Browse Source

NamedColors<TPixel>.WebSafePalette is now a property backed by thread safe Lazy<TPixel[]>

af/merge-core
Anton Firszov 8 years ago
parent
commit
a9a577c953
  1. 9
      src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs

9
src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs

@ -12,6 +12,11 @@ namespace SixLabors.ImageSharp.PixelFormats
public static class NamedColors<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Thread-safe backing field for <see cref="WebSafePalette"/>.
/// </summary>
private static readonly Lazy<TPixel[]> WebSafePaletteLazy = new Lazy<TPixel[]>(GetWebSafePalette, true);
/// <summary>
/// Represents a <see paramref="TPixel"/> matching the W3C definition that has an hex value of #F0F8FF.
/// </summary>
@ -723,9 +728,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public static readonly TPixel YellowGreen = ColorBuilder<TPixel>.FromRGBA(154, 205, 50, 255);
/// <summary>
/// Represents a <see cref="T:TPixel[]"/> matching the W3C definition of web safe colors.
/// Gets a <see cref="T:TPixel[]"/> matching the W3C definition of web safe colors.
/// </summary>
public static readonly TPixel[] WebSafePalette = GetWebSafePalette();
public static TPixel[] WebSafePalette => WebSafePaletteLazy.Value;
private static TPixel[] GetWebSafePalette()
{

Loading…
Cancel
Save