Beispiel #1
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));
                }
            }
        }