Ejemplo n.º 1
0
        /// <summary>
        /// Returns the estimated position along a path of the given length.
        /// </summary>
        private void GetPointAtLength(PathIterator.ContourType type, float[] coords, float lastX, float lastY, float t, float[] point)
        {
            if (type == PathIterator.ContourType.Line)
            {
                point[0] = lastX + (coords[0] - lastX) * t;
                point[1] = lastY + (coords[1] - lastY) * t;
                // Return here, since we do not need a shape to estimate
                return;
            }

            var curve          = new float[8];
            var lastPointIndex = (GetNumberOfPoints(type) - 1) * 2;

            Array.Copy(coords, 0, curve, 2, coords.Length);
            curve[0] = lastX;
            curve[1] = lastY;
            if (type == PathIterator.ContourType.Bezier)
            {
                CubicCurveSegment(curve, 0f, t);
            }
            else
            {
                QuadCurveSegment(curve, 0f, t);
            }

            point[0] = curve[2 + lastPointIndex];
            point[1] = curve[2 + lastPointIndex + 1];
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the end point of a given segment
        /// </summary>
        /// <param name="type"> the segment type </param>
        /// <param name="coords"> the segment coordinates array </param>
        /// <param name="point"> the return array where the point will be stored </param>
        private static void GetShapeEndPoint(PathIterator.ContourType type, float[] coords, float[] point)
        {
            // start index of the end point for the segment type
            var pointIndex = (GetNumberOfPoints(type) - 1) * 2;

            point[0] = coords[pointIndex];
            point[1] = coords[pointIndex + 1];
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the number of points stored in a coordinates array for the given segment type.
        /// </summary>
        private static int GetNumberOfPoints(PathIterator.ContourType segmentType)
        {
            switch (segmentType)
            {
            case PathIterator.ContourType.Arc:
                return(2);

            case PathIterator.ContourType.Bezier:
                return(3);

            case PathIterator.ContourType.Close:
                return(0);

            default:
                return(1);
            }
        }