예제 #1
0
        /// <summary>
        ///     Gets the approximate bounds for this line after it has been transformed by the given <paramref name="transform" />.
        ///     The rectangle returned should equal or contain the actual bounds.
        /// </summary>
        /// <param name="transform">The transform to apply to the line.</param>
        /// <returns></returns>
        public Rectangle GetApproximateBounds(Matrix3x2 transform)
        {
            Vector2 start = Vector2.Transform(Start, transform);
            Vector2 end   = Vector2.Transform(End, transform);

            Vector2 zero = Vector2.Transform(Vector2.Zero, transform);
            Vector2 rad  = Vector2.Transform(Radius, transform);

            rad = Radius * (Vector2.Distance(zero, rad) / Radius.Length());

            return(new Rectangle(start, Vector2.Zero)
                   .Expand(end)
                   .Expand(start + rad)
                   .Expand(end + rad)
                   .Expand(start - rad)
                   .Expand(end - rad));
        }
예제 #2
0
        /// <summary>
        ///     Adds the line to the given <paramref name="path" /> after transforming it by the given
        ///     <paramref name="transform" />.
        /// </summary>
        /// <param name="path">The path to add the line to.</param>
        /// <param name="transform">The transform.</param>
        public void AddToPath(IGraphicsPath path, Matrix3x2 transform)
        {
            Vector2 zero = Vector2.Transform(Vector2.Zero, transform);
            Vector2 rad  = Vector2.Transform(Radius, transform);

            rad = Radius * (Vector2.Distance(zero, rad) / Radius.Length());

            Vector2 angVec = Vector2.Transform(new Vector2(0, 1), Matrix3x2.CreateRotation(Angle) * transform);
            float   ang    = AngleBetween(new Vector2(0, 1), angVec - zero);

            path.AddArc(
                Vector2.Transform(End, transform),
                rad,
                ang,
                Clockwise /* TODO probably need to work this out somehow */,
                IsLarge);
        }