public void Parse(CssReader reader, GradientBuilder builder) { var parts = reader.Read().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var color = (Color)ColorConverter.ConvertFromInvariantString(parts[0]); if (parts.TryConvertOffsets(out var offsets)) { builder.AddStops(color, offsets); } else { builder.AddStop(color); } }
public void Parse(CssReader reader, GradientBuilder builder) { var parts = reader.Read().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var color = GetNamedColor(parts[0]); var offsets = GetOffsets(parts); if (offsets.Any()) { builder.AddStops(color, offsets); } else { builder.AddStop(color); } }
public void Parse(CssReader reader, GradientBuilder builder) { var colorString = GetColorString(reader); var color = (Color)ColorConverter.ConvertFromInvariantString(colorString); var parts = reader.ReadNext().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var offsets = GetOffsets(parts); if (offsets.Any()) { builder.AddStops(color, offsets); } else { builder.AddStop(color); reader.Rollback(); } }