Пример #1
0
        public void MozExamples()
        {
            LinearGradient.Parse("linear-gradient(#e66465, #9198e5)");
            // LinearGradient.Parse("linear-gradient(0.25turn, #3f87a6, #ebf8e1, #f69d3c);");

            LinearGradient.Parse("linear-gradient(to left, #333, #333 50%, #eee 75%, #333 75%)");

            // https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient
        }
Пример #2
0
        public void A()
        {
            var gradient = LinearGradient.Parse("linear-gradient(0deg, rgb(153, 116, 186) 0%, rgb(194, 234, 9) 20%, rgb(0, 203, 227) 80%, rgb(47, 84, 176) 100%)");

            Assert.Equal(new Rgba32(153, 116, 186), gradient.Stops[0].Color);
            Assert.Equal(new Rgba32(194, 234, 9), gradient.Stops[1].Color);

            Assert.Equal(4, gradient.Stops.Length);
        }
Пример #3
0
        public void ParseDefault()
        {
            var result = LinearGradient.Parse("linear-gradient(#000, transparent 50%, #fff)");

            Assert.Null(result.Angle);
            Assert.Equal(LinearGradientDirection.None, result.Direction);

            Assert.Equal("000000ff", result.Stops[0].Color.ToHex8());
            Assert.Equal("00000000", result.Stops[1].Color.ToHex8());
            Assert.Equal("ffffffff", result.Stops[2].Color.ToHex8());
        }
Пример #4
0
        public void ParseDirectional()
        {
            var result = LinearGradient.Parse("to top, #000, transparent 50%, #fff");

            Assert.Null(result.Angle);
            Assert.Equal(LinearGradientDirection.Top, result.Direction);

            Assert.Equal("000000ff", result.Stops[0].Color.ToHex8());
            Assert.Equal("00000000", result.Stops[1].Color.ToHex8());
            Assert.Equal("ffffffff", result.Stops[2].Color.ToHex8());
        }
Пример #5
0
        public void ParseLegacySyntaxWithoutTo()
        {
            var result = LinearGradient.Parse("top left, #000, #00000000 50%, #fff");

            Assert.Null(result.Angle);
            Assert.Equal(LinearGradientDirection.TopLeft, result.Direction);


            Assert.Equal("000000ff", result.Stops[0].Color.ToHex8());
            Assert.Equal("00000000", result.Stops[1].Color.ToHex8());
            Assert.Equal("ffffffff", result.Stops[2].Color.ToHex8());
        }
Пример #6
0
        public void ParseFunctionSyntax()
        {
            var result = LinearGradient.Parse("linear-gradient(top left, #000, transparent 50%, #fff)");

            Assert.Null(result.Angle);
            Assert.Equal(LinearGradientDirection.TopLeft, result.Direction);


            Assert.Equal("000000ff", result.Stops[0].Color.ToHex8());
            Assert.Equal("00000000", result.Stops[1].Color.ToHex8());
            Assert.Equal("ffffffff", result.Stops[2].Color.ToHex8());
        }
Пример #7
0
        public void ParseNamedColors()
        {
            var result = LinearGradient.Parse("linear-gradient(135deg, orange, orange 60%, cyan)");

            Assert.Equal(135d, result.Angle);

            Assert.Equal("ffa500ff", result.Stops[0].Color.ToHex8());
            Assert.Equal("ffa500ff", result.Stops[1].Color.ToHex8());
            Assert.Equal("00ffffff", result.Stops[2].Color.ToHex8());

            Assert.Equal("linear-gradient(135deg, #ffa500, #ffa500 60%, #00ffff)", result.ToString());
        }
Пример #8
0
        public void ParseAngle()
        {
            var result = LinearGradient.Parse("30deg, #006, #00a 90%, #0000af 100%");

            Assert.Equal(3, result.Stops.Length);

            Assert.Equal("000066", result.Stops[0].Color.ToHex6());
            Assert.Equal("0000aa", result.Stops[1].Color.ToHex6());
            Assert.Equal("0000af", result.Stops[2].Color.ToHex6());

            Assert.Equal(30, result.Angle);
        }
Пример #9
0
 public void ThrowsOnInvalidInput()
 {
     Assert.Throws <IndexOutOfRangeException>(() => LinearGradient.Parse(",,,,,,"));
     Assert.Throws <Exception>(() => LinearGradient.Parse("linear-gradientt(#000)"));
 }