コード例 #1
0
ファイル: CSSBackground.cs プロジェクト: Winster332/Quantum
        public static CSSBackground Parse(string value)
        {
            var background = new CSSBackground
            {
                Color = CSSColor.Parse(value)
            };

            return(background);
        }
コード例 #2
0
        public PathStyle(Dictionary <string, string> properties, PathStyle?parent)
        {
            // Fill in the default values according to the default values on https://svgwg.org/svg-next/painting.htm
            // Special handling for paint servers (which now only accept colors)
            FillColor   = CSSColor.Parse(properties.GetOrDefault("fill")) ?? (parent.HasValue ? parent.Value.FillColor : Color.Black);
            StrokeColor = CSSColor.Parse(properties.GetOrDefault("stroke")) ?? parent?.StrokeColor;

            FillRule = CSSEnumPicker <FillRule> .Get(properties.GetOrDefault("fill-rule")) ?? parent?.FillRule ?? FillRule.Nonzero;

            StrokeWidth   = DoubleUtils.TryParse(properties.GetOrDefault("stroke-width")) ?? parent?.StrokeWidth ?? 1;
            StrokeLineCap = CSSEnumPicker <StrokeLineCap> .Get(properties.GetOrDefault("stroke-linecap")) ??
                            parent?.StrokeLineCap ?? StrokeLineCap.Butt;

            StrokeLineJoin = CSSEnumPicker <StrokeLineJoin> .Get(properties.GetOrDefault("stroke-linejoin")) ??
                             parent?.StrokeLineJoin ?? StrokeLineJoin.Miter;

            MiterLimit = DoubleUtils.TryParse(properties.GetOrDefault("stroke-miterlimit")) ?? parent?.StrokeWidth ?? 4;
        }
コード例 #3
0
ファイル: CSSColorTests.cs プロジェクト: Winster332/Quantum
        public void CSSColorParseCombinationTest()
        {
            var colorHex = CSSColor.Parse("FFFFFFCC");

            colorHex.Should().NotBeNull();

            colorHex.A.Should().BeGreaterOrEqualTo(204);
            colorHex.R.Should().BeGreaterOrEqualTo(255);
            colorHex.G.Should().BeGreaterOrEqualTo(255);
            colorHex.B.Should().BeGreaterOrEqualTo(255);

            var colorConst = CSSColor.Parse("white");

            colorConst.Should().NotBeNull();

            colorConst.A.Should().BeGreaterOrEqualTo(255);
            colorConst.R.Should().BeGreaterOrEqualTo(255);
            colorConst.G.Should().BeGreaterOrEqualTo(255);
            colorConst.B.Should().BeGreaterOrEqualTo(255);
        }