コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cubicBezier"></param>
        /// <param name="v"></param>
        /// <param name="threshold"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static BaseShape HitTestCubicBezier(XCubicBezier cubicBezier, Vector2 v, double threshold, double dx, double dy)
        {
            if (RectangleBounds.GetPointBounds(cubicBezier.Point1, threshold, dx, dy).Contains(v))
            {
                return(cubicBezier.Point1);
            }

            if (RectangleBounds.GetPointBounds(cubicBezier.Point2, threshold, dx, dy).Contains(v))
            {
                return(cubicBezier.Point2);
            }

            if (RectangleBounds.GetPointBounds(cubicBezier.Point3, threshold, dx, dy).Contains(v))
            {
                return(cubicBezier.Point3);
            }

            if (RectangleBounds.GetPointBounds(cubicBezier.Point4, threshold, dx, dy).Contains(v))
            {
                return(cubicBezier.Point4);
            }

            if (ConvexHullBounds.Contains(cubicBezier.GetPoints().ToImmutableArray(), v, dx, dy))
            {
                return(cubicBezier);
            }

            return(null);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="quadraticBezier"></param>
        /// <param name="selection"></param>
        /// <param name="selected"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestQadraticBezier(XQuadraticBezier quadraticBezier, Vector2[] selection, ISet <BaseShape> selected, double dx, double dy)
        {
            var points = quadraticBezier.GetPoints().ToImmutableArray();

            if (ConvexHullBounds.Overlap(selection, points, dx, dy))
            {
                if (selected != null)
                {
                    selected.Add(quadraticBezier);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="selection"></param>
        /// <param name="selected"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static bool HitTestPath(XPath path, Vector2[] selection, ISet <BaseShape> selected, double dx, double dy)
        {
            if (path.Geometry != null)
            {
                var points = path.GetPoints().ToImmutableArray();
                if (ConvexHullBounds.Overlap(selection, points, dx, dy))
                {
                    if (selected != null)
                    {
                        selected.Add(path);
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="v"></param>
        /// <param name="threshold"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <returns></returns>
        public static BaseShape HitTestPath(XPath path, Vector2 v, double threshold, double dx, double dy)
        {
            if (path.Geometry != null)
            {
                var points = path.GetPoints().ToImmutableArray();
                foreach (var point in points)
                {
                    if (RectangleBounds.GetPointBounds(point, threshold, dx, dy).Contains(v))
                    {
                        return(point);
                    }
                }

                if (ConvexHullBounds.Contains(points, v, dx, dy))
                {
                    return(path);
                }
            }

            return(null);
        }