Ejemplo n.º 1
0
        internal static BezierPathSegment[] BuildEllipsePath(Vector2 p0, Vector2 p1, float rotation, float rx, float ry, bool largeArc, bool sweep)
        {
            if ((p1 - p0).magnitude < VectorUtils.Epsilon)
            {
                return(new BezierPathSegment[0]);
            }

            Vector2 c;
            float   theta1;
            float   sweepTheta;
            float   adjustedRx;
            float   adjustedRy;

            ComputeEllipseParameters(p0, p1, rotation, rx, ry, largeArc, sweep, out c, out theta1, out sweepTheta, out adjustedRx, out adjustedRy);

            BezierPathSegment[] path;
            if (Mathf.Abs(sweepTheta) <= Mathf.Epsilon)
            {
                // Use a straight line if the sweep angle is tiny
                path = VectorUtils.BezierSegmentToPath(VectorUtils.MakeLine(p0, p1));
            }
            else
            {
                path = VectorUtils.MakeArc(Vector2.zero, theta1, sweepTheta, 1.0f);

                var scaling = new Vector2(adjustedRx, adjustedRy);
                path = VectorUtils.TransformBezierPath(path, c, rotation, scaling);
            }


            return(path);
        }