Ejemplo n.º 1
0
        public override PointF AddToPath(GraphicsPath graphicsPath, PointF start, SvgPathSegmentList parent)
        {
            var firstControlPoint = FirstControlPoint;

            if (float.IsNaN(firstControlPoint.X) || float.IsNaN(firstControlPoint.Y))
            {
                var prev = parent.IndexOf(this) - 1;
                if (prev >= 0 && parent[prev] is SvgCubicCurveSegment)
                {
                    var prevSecondControlPoint = graphicsPath.PathPoints[graphicsPath.PointCount - 2];
                    firstControlPoint = Reflect(prevSecondControlPoint, start);
                }
                else
                {
                    firstControlPoint = start;
                }
            }
            else
            {
                firstControlPoint = ToAbsolute(firstControlPoint, IsRelative, start);
            }

            var end = ToAbsolute(End, IsRelative, start);

            graphicsPath.AddBezier(start, firstControlPoint, ToAbsolute(SecondControlPoint, IsRelative, start), end);
            return(end);
        }
Ejemplo n.º 2
0
        public override PointF AddToPath(GraphicsPath graphicsPath, PointF start, SvgPathSegmentList parent)
        {
            var controlPoint = ControlPoint;

            if (float.IsNaN(controlPoint.X) || float.IsNaN(controlPoint.Y))
            {
                var prev = parent.IndexOf(this) - 1;
                if (prev >= 0 && parent[prev] is SvgQuadraticCurveSegment)
                {
                    var prevStart             = graphicsPath.PathPoints[graphicsPath.PointCount - 4];
                    var prevFirstControlPoint = graphicsPath.PathPoints[graphicsPath.PointCount - 3];
                    var prevControlPoint      = CalculateControlPoint(prevStart, prevFirstControlPoint);
                    controlPoint = Reflect(prevControlPoint, start);
                }
                else
                {
                    controlPoint = start;
                }
            }
            else
            {
                controlPoint = ToAbsolute(controlPoint, IsRelative, start);
            }

            var end = ToAbsolute(End, IsRelative, start);

            graphicsPath.AddBezier(start, CalculateFirstControlPoint(start, controlPoint), CalculateSecondControlPoint(controlPoint, end), end);
            return(end);
        }