public static CSSBackground Parse(string value) { var background = new CSSBackground { Color = CSSColor.Parse(value) }; return(background); }
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; }
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); }