public void Parse(CssReader reader, GradientBuilder builder) { var isRepeating = reader.Read().Trim() == CssToken.RepeatingRadialGradient; var token = reader.ReadNext().Trim(); var internalReader = new CssReader(token, ' '); var(hasShape, shape) = GetShape(internalReader); var(hasStretch, stretch) = GetStretch(internalReader); var(hasRadius, radius) = GeRadius(internalReader, shape); var(hasPos, position) = GetPosition(internalReader); builder.UseBuilder(new RadialGradientBuilder { Center = position, Shape = shape, Stretch = stretch, Radius = radius, IsRepeating = isRepeating }); if (!hasShape && !hasStretch && !hasRadius && !hasPos) { reader.Rollback(); } }
public void Parse(CssReader reader, GradientBuilder builder) { var isRepeating = reader.Read().Trim() == CssToken.RepeatingRadialGradient; var token = reader.ReadNext().Trim(); var internalReader = new CssReader(token, ' '); var flags = None; var(hasShape, shape) = GetShape(internalReader); var(hasSize, size) = GetSize(internalReader); var(hasRadius, radius) = GeRadius(internalReader, shape, ref flags); var(hasPos, position) = GetPosition(internalReader, ref flags); builder.UseBuilder(new RadialGradientBuilder { Center = position, Shape = shape, Size = size, RadiusX = radius.Width, RadiusY = radius.Height, Flags = flags, IsRepeating = isRepeating }); if (!hasShape && !hasSize && !hasRadius && !hasPos) { reader.Rollback(); } }
public void Parse(CssReader reader, GradientBuilder builder) { var repeating = reader.Read().Trim() == CssToken.RepeatingLinearGradient; var direction = reader.ReadNext().Trim(); var angle = 0d; var hasAngle = TryConvertDegreeToAngle(direction, out angle) || TryConvertTurnToAngle(direction, out angle) || TryConvertNamedDirectionToAngle(direction, out angle); builder.UseBuilder(new LinearGradientBuilder { Angle = angle, IsRepeating = repeating }); if (!hasAngle) { reader.Rollback(); } }