Ejemplo n.º 1
0
        /// <summary>
        /// Determine if this point hits the object
        /// </summary>
        /// <param name="hit"></param>
        /// <returns></returns>
        public override bool HitTest(PointF hit)
        {
            PointF center    = Center;
            float  radius2   = GraphUtils.Square(Boundary.Width / 2);
            float  distance2 = GraphUtils.Square(hit.X - center.X) + GraphUtils.Square(hit.Y - center.Y);

            return(distance2 < radius2);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Clip the line destination to be outside of the shape if possible
        /// </summary>
        /// <param name="sourcePoint">The source point of the line</param>
        /// <returns>The clipped line position</returns>
        internal override PointF ClipLine(PointF sourcePoint)
        {
            float relX      = Center.X - sourcePoint.X;
            float relY      = Center.Y - sourcePoint.Y;
            float length    = (float)Math.Sqrt(GraphUtils.Square(relX) + GraphUtils.Square(relY));
            float newLength = length - Boundary.Width / 2.0f;

            // If we have a length which is less that 0 then return just the center point
            if (newLength < 0)
            {
                return(Center);
            }

            return(new PointF(sourcePoint.X + ((relX * newLength) / length), sourcePoint.Y + ((relY * newLength) / length)));
        }