internal LabColorSpace() { Alpha = new ColorChannelDefinition(this, "Alpha", "A"); Lightness = new ColorChannelDefinition(this, "Lightness", "L"); a = new ColorChannelDefinition(this, "a", "a"); b = new ColorChannelDefinition(this, "b", "b"); }
internal xyYColorSpace() { Alpha = new ColorChannelDefinition(this, "Alpha", "A"); x = new ColorChannelDefinition(this, "x", "x"); x = new ColorChannelDefinition(this, "y", "y"); Y = new ColorChannelDefinition(this, "Y", "Y"); }
public RGBColorSpace() { Alpha = new ColorChannelDefinition(this, "Alpha", "A", (v) => v % 255); R = new ColorChannelDefinition(this, "R", "R", (v) => v % 255); G = new ColorChannelDefinition(this, "G", "G", (v) => v % 255); B = new ColorChannelDefinition(this, "B", "B", (v) => v % 255); }
public void IsMatch_ProvidedToken_CorrectMatchResult(string token, bool expectedMatch) { // Arrange var definition = new ColorChannelDefinition(); // Act var isMatch = definition.IsMatch(token); // Assert isMatch.Should().Be(expectedMatch); }
internal XYZColorSpace() { Alpha = new ColorChannelDefinition(this, "Alpha", "A"); // DisplayValue = Value * 100 and up to three fraction digits X = new ColorChannelDefinition(this, "X", "X", (v) => Math.Round(100 * v, 3, MidpointRounding.AwayFromZero)); Y = new ColorChannelDefinition(this, "Y", "Y", (v) => Math.Round(100 * v, 3, MidpointRounding.AwayFromZero)); Z = new ColorChannelDefinition(this, "Z", "Z", (v) => Math.Round(100 * v, 3, MidpointRounding.AwayFromZero)); whitePoint = new XYZColor(this, 1.0, 0.95047, 1.0, 1.088969); }
public void TryConvertPercentToOffset_ConvertingToken_SuccessAndResultConvertedCorrectly(string token, float expectedResult, bool expectedSuccess) { // Arrange var definition = new ColorChannelDefinition(); // Act var success = definition.TryConvertPercentToOffset(token, out var result); // Assert success.Should().Be(expectedSuccess); result.Should().Be(expectedResult); }
public void GetColorString_ReadFromCssReader_CorrectColorStringReturned(string colorInCss) { // Arrange var definition = new ColorChannelDefinition(); var reader = new CssReader(colorInCss); // Act var colorInString = definition.GetColorString(reader); // Assert colorInString.Should().Be(colorInCss); }
public void Parse_HslAndHsla_WithDoubleValues_NoExceptionsThrown(string color) { // Arrange var reader = new CssReader(color); var builder = new GradientBuilder(); var definition = new ColorChannelDefinition(); // Act Action action = () => definition.Parse(reader, builder); // Assert action.Should().NotThrow <Exception>(); }
public void Parse_ValidColor_SingleStopWithColorAndOffset(string color, Color expectedColor, float expectedOffset) { // Arrange var reader = new CssReader(color); var builder = new LinearGradientBuilder(); var definition = new ColorChannelDefinition(); // Act definition.Parse(reader, builder); // Assert var result = builder.Build(); using (new AssertionScope()) { var stops = result.SelectMany(x => x.Stops).ToArray(); stops.Should().HaveCount(1); stops[0].Color.Should().Be(expectedColor); stops[0].Offset.Should().Be(expectedOffset); } }