Skip to content

Commit 3425bb1

Browse files
Improve color converter
1 parent eff9c81 commit 3425bb1

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/ImageSharp.Web/Commands/Converters/ColorConverter.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -38,13 +38,6 @@ public override object ConvertFrom(CultureInfo culture, string value, Type prope
3838
return default(Color);
3939
}
4040

41-
// Special case. HTML requires LightGrey, but NamedColors has LightGray to conform with System.Drawing
42-
// Check early on.
43-
if (value.Equals("LightGrey", StringComparison.OrdinalIgnoreCase))
44-
{
45-
return Color.LightGray;
46-
}
47-
4841
// Numeric r,g,b - r,g,b,a
4942
char separator = culture.TextInfo.ListSeparator[0];
5043

tests/ImageSharp.Web.Tests/Commands/CommandParserTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Globalization;
7-
using SixLabors.ImageSharp.PixelFormats;
87
using SixLabors.ImageSharp.Processing;
98
using SixLabors.ImageSharp.Web.Commands;
109
using Xunit;
@@ -47,18 +46,18 @@ public class CommandParserTests
4746
{ (decimal)Pi, PiString },
4847
};
4948

50-
public static TheoryData<object, string> EnumValues = new TheoryData<object, string>
49+
public static TheoryData<ResizeMode, string> EnumValues = new TheoryData<ResizeMode, string>
5150
{
5251
{ ResizeMode.Max, "max" },
5352
{ ResizeMode.Crop, "this is not an enum value" }, // Unknown returns default
5453
};
5554

56-
public static TheoryData<object, string> IntegralArrays = new TheoryData<object, string>
55+
public static TheoryData<int[], string> IntegralArrays = new TheoryData<int[], string>
5756
{
5857
{ new[] { 1, 2, 3, 4 }, "1,2,3,4" },
5958
};
6059

61-
public static TheoryData<object, string> RealArrays = new TheoryData<object, string>
60+
public static TheoryData<float[], string> RealArrays = new TheoryData<float[], string>
6261
{
6362
{ new[] { 1.667F, 2.667F, 3.667F, 4.667F }, "1.667,2.667,3.667,4.667" },
6463
};
@@ -73,8 +72,9 @@ public class CommandParserTests
7372
{ new List<float> { 1.667F, 2.667F, 3.667F, 4.667F }, "1.667,2.667,3.667,4.667" },
7473
};
7574

76-
public static TheoryData<object, string> ColorValues = new TheoryData<object, string>
75+
public static TheoryData<Color, string> ColorValues = new TheoryData<Color, string>
7776
{
77+
{ default, string.Empty },
7878
{ Color.White, "255,255,255" },
7979
{ Color.Transparent, "0,0,0,0" },
8080
{ Color.Orange, "orange" },

0 commit comments

Comments
 (0)