Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 2
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));
            }
        }