コード例 #1
0
        /// <summary>
        /// Create a new arrow geometry.
        /// </summary>
        /// <param name="resourceCreator"> The resource - creator. </param>
        /// <param name="transformer"> The source transformer. </param>
        /// <param name="matrix"> The matrix. </param>
        /// <param name="isAbsolute"> Is absolute? </param>
        /// <param name="width"> The absolute width. </param>
        /// <param name="value"> The relative value. </param>
        /// <param name="leftTail"> The left - tail. </param>
        /// <param name="rightTail"> The right - tail. </param>
        /// <returns> The product geometry. </returns>
        public static CanvasGeometry CreateArrow(ICanvasResourceCreator resourceCreator, ITransformerLTRB transformer, Matrix3x2 matrix, bool isAbsolute = false, float width = 10, float value = 0.5f, GeometryArrowTailType leftTail = GeometryArrowTailType.None, GeometryArrowTailType rightTail = GeometryArrowTailType.Arrow)
        {
            Vector2 center      = Vector2.Transform(transformer.Center, matrix);
            Vector2 centerLeft  = Vector2.Transform(transformer.CenterLeft, matrix);
            Vector2 centerRight = Vector2.Transform(transformer.CenterRight, matrix);

            // horizontal
            Vector2 horizontal       = transformer.Horizontal;
            float   horizontalLength = horizontal.Length();
            // vertical
            Vector2 vertical       = transformer.Vertical;
            float   verticalLength = vertical.Length();

            Vector2 widthVector = TransformerGeometry.GetArrowWidthVector(isAbsolute, width, value, vertical, verticalLength);

            Vector2 focusVector         = TransformerGeometry.GetArrowFocusVector(verticalLength, horizontalLength, horizontal);
            Vector2 leftFocusTransform  = Vector2.Transform(transformer.CenterLeft + focusVector, matrix);
            Vector2 rightFocusTransform = Vector2.Transform(transformer.CenterRight - focusVector, matrix);

            return(TransformerGeometry.CreateArrowCore
                   (
                       resourceCreator,
                       Vector2.Transform(widthVector + transformer.Center, matrix) - center,

                       // Left
                       centerLeft,
                       Vector2.Transform(transformer.LeftBottom, matrix),

                       Vector2.Transform(transformer.LeftTop, matrix),
                       (leftFocusTransform - centerLeft),
                       leftFocusTransform,

                       // Right
                       centerRight,
                       Vector2.Transform(transformer.RightBottom, matrix),

                       Vector2.Transform(transformer.RightTop, matrix),
                       (rightFocusTransform - centerRight),
                       rightFocusTransform,

                       leftTail, rightTail
                   ));
        }