Esempio n. 1
0
        /// <summary>
        /// Create a new capsule geometry.
        /// </summary>
        /// <param name="resourceCreator"> The resource - creator. </param>
        /// <param name="transformer"> The ITransformer - LTRB. </param>
        /// <returns> The product geometry. </returns>
        public static CanvasGeometry CreateCapsule(ICanvasResourceCreator resourceCreator, ITransformerLTRB transformer)
        {
            Vector2 centerLeft   = transformer.CenterLeft;
            Vector2 centerTop    = transformer.CenterTop;
            Vector2 centerRight  = transformer.CenterRight;
            Vector2 centerBottom = transformer.CenterBottom;

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

            if (horizontalLength < verticalLength)
            {
                return(TransformerGeometry.CreateEllipse(resourceCreator, transformer));
            }

            return(TransformerGeometry.CreateCapsuleCore(resourceCreator,
                                                         verticalLength,
                                                         horizontalUnit,

                                                         centerTop,
                                                         centerLeft,
                                                         centerRight,
                                                         centerBottom,

                                                         transformer.LeftTop,
                                                         transformer.RightTop,
                                                         transformer.RightBottom,
                                                         transformer.LeftBottom
                                                         ));
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new cookie geometry.
        /// </summary>
        /// <param name="resourceCreator"> The resource-creator. </param>
        /// <param name="transformer"> The source transformer. </param>
        /// <param name="innerRadius"> The inner-radius. </param>
        /// <param name="sweepAngle"> The sweep-angle. </param>
        /// <returns> The product geometry. </returns>
        public static CanvasGeometry CreateCookie(ICanvasResourceCreator resourceCreator, ITransformerLTRB transformer, Matrix3x2 matrix, float innerRadius, float sweepAngle)
        {
            bool zeroInnerRadius = innerRadius == 0;
            bool zeroSweepAngle  = sweepAngle == 0;

            if (zeroSweepAngle)
            {
                CanvasGeometry ellipse = TransformerGeometry.CreateEllipse(resourceCreator, transformer, matrix);

                if (zeroInnerRadius)
                {
                    return(ellipse);
                }
                else
                {
                    Vector2 center = Vector2.Transform(transformer.Center, matrix);

                    return(TransformerGeometry.CreateDountCore(ellipse, innerRadius, center));
                }
            }
            else
            {
                Matrix3x2 oneMatrix  = Transformer.FindHomography(Transformer.One, transformer);
                Matrix3x2 oneMatrix2 = oneMatrix * matrix;

                if (zeroInnerRadius)
                {
                    return(TransformerGeometry.CreatePieCore(resourceCreator, oneMatrix2, sweepAngle));
                }
                else
                {
                    return(TransformerGeometry.CreateCookieCore(resourceCreator, oneMatrix2, innerRadius, sweepAngle));
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new pie geometry.
        /// </summary>
        /// <param name="resourceCreator"> The resource-creator. </param>
        /// <param name="sweepAngle"> The sweep-angle. </param>
        /// <returns> The product geometry. </returns>
        public static CanvasGeometry CreatePie(ICanvasResourceCreator resourceCreator, ITransformerLTRB transformer, float sweepAngle)
        {
            bool zeroSweepAngle = sweepAngle == 0;

            if (zeroSweepAngle)
            {
                return(TransformerGeometry.CreateEllipse(resourceCreator, transformer));
            }
            else
            {
                Matrix3x2 oneMatrix = Transformer.FindHomography(Transformer.One, transformer);

                return(TransformerGeometry.CreatePieCore(resourceCreator, oneMatrix, sweepAngle));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Create a new dount geometry.
        /// </summary>
        /// <param name="resourceCreator"> The resource-creator. </param>
        /// <param name="transformer"> The source transformer. </param>
        /// <param name="matrix"> The matrix. </param>
        /// <param name="holeRadius"> The hole-radius. </param>
        /// <returns> The product geometry. </returns>
        public static CanvasGeometry CreateDount(ICanvasResourceCreator resourceCreator, ITransformerLTRB transformer, Matrix3x2 matrix, float holeRadius)
        {
            bool           zeroHoleRadius = holeRadius == 0;
            CanvasGeometry outter         = TransformerGeometry.CreateEllipse(resourceCreator, transformer, matrix);

            if (zeroHoleRadius)
            {
                return(outter);
            }
            else
            {
                Vector2 center = Vector2.Transform(transformer.Center, matrix);

                return(TransformerGeometry.CreateDountCore(outter, holeRadius, center));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Create a new capsule geometry.
        /// </summary>
        /// <param name="resourceCreator"> The resource - creator. </param>
        /// <param name="transformerLTRB"> The ITransformer - LTRB. </param>
        /// <param name="matrix"> The matrix. </param>
        /// <returns> The product geometry. </returns>
        public static CanvasGeometry CreateCapsule(ICanvasResourceCreator resourceCreator, ITransformerLTRB transformer, Matrix3x2 matrix)
        {
            Vector2 leftTop     = Vector2.Transform(transformer.LeftTop, matrix);
            Vector2 rightTop    = Vector2.Transform(transformer.RightTop, matrix);
            Vector2 rightBottom = Vector2.Transform(transformer.RightBottom, matrix);
            Vector2 leftBottom  = Vector2.Transform(transformer.LeftBottom, matrix);

            Vector2 centerLeft   = Vector2.Transform(transformer.CenterLeft, matrix);
            Vector2 centerTop    = Vector2.Transform(transformer.CenterTop, matrix);
            Vector2 centerRight  = Vector2.Transform(transformer.CenterRight, matrix);
            Vector2 centerBottom = Vector2.Transform(transformer.CenterBottom, matrix);

            // Horizontal
            Vector2 horizontal       = (centerRight - centerLeft);
            float   horizontalLength = horizontal.Length();
            Vector2 horizontalUnit   = horizontal / horizontalLength;
            // Vertical
            Vector2 vertical       = (centerBottom - centerTop);
            float   verticalLength = vertical.Length();

            if (horizontalLength < verticalLength)
            {
                return(TransformerGeometry.CreateEllipse(resourceCreator, transformer, matrix));
            }

            return(TransformerGeometry.CreateCapsuleCore(resourceCreator,
                                                         verticalLength,
                                                         horizontalUnit,

                                                         centerTop,
                                                         centerLeft,
                                                         centerRight,
                                                         centerBottom,

                                                         leftTop,
                                                         rightTop,
                                                         rightBottom,
                                                         leftBottom));
        }
 /// <summary>
 /// Create a new ellipse geometry.
 /// </summary>
 /// <param name="resourceCreator"> The resource-creator. </param>
 /// <param name="transformerLTRB"> The ITransformer-LTRB. </param>
 /// <param name="matrix"> The matrix. </param>
 /// <returns> The product geometry. </returns>
 public static CanvasGeometry CreateEllipse(ICanvasResourceCreator resourceCreator, ITransformerLTRB transformerLTRB, Matrix3x2 matrix) => TransformerGeometry.CreateEllipse(resourceCreator, transformerLTRB.CenterLeft, transformerLTRB.CenterTop, transformerLTRB.CenterRight, transformerLTRB.CenterBottom, matrix);
Esempio n. 7
0
 /// <summary>
 /// Turn to geometry.
 /// </summary>
 /// <param name="resourceCreator"> The resource-creator. </param>
 /// <param name="matrix"> The matrix. </param>
 /// <returns></returns>
 public CanvasGeometry ToEllipse(ICanvasResourceCreator resourceCreator, Matrix3x2 matrix) => TransformerGeometry.CreateEllipse(resourceCreator, this, matrix);
Esempio n. 8
0
 /// <summary>
 /// Turn to geometry.
 /// </summary>
 /// <param name="resourceCreator"> The resource-creator. </param>
 /// <returns></returns>
 public CanvasGeometry ToEllipse(ICanvasResourceCreator resourceCreator) => TransformerGeometry.CreateEllipse(resourceCreator, this);