private static CanvasGeometry CreateStarCore(ICanvasResourceCreator resourceCreator, int points, float innerRadius, Matrix3x2 oneMatrix)
        {
            float rotation = TransformerGeometry.StartingRotation;
            float angle    = FanKit.Math.Pi / points;

            Vector2[] array = new Vector2[points * 2];
            for (int i = 0; i < points; i++)
            {
                int index = i * 2;

                // Outer
                Vector2 outer          = TransformerGeometry.GetRotationVector(rotation);
                Vector2 outerTransform = Vector2.Transform(outer, oneMatrix);
                array[index] = outerTransform;
                rotation    += angle;

                // Inner
                Vector2 inner           = TransformerGeometry.GetRotationVector(rotation);
                Vector2 inner2          = inner * innerRadius;
                Vector2 inner2Transform = Vector2.Transform(inner2, oneMatrix);
                array[index + 1] = inner2Transform;
                rotation        += angle;
            }

            return(CanvasGeometry.CreatePolygon(resourceCreator, array));
        }
示例#2
0
        private static CanvasGeometry CreateCookieCore(ICanvasResourceCreator resourceCreator, Matrix3x2 oneMatrix, float innerRadius, float sweepAngle)
        {
            // start tooth
            Vector2 startTooth = new Vector2(1, 0);
            // end tooth
            Vector2 endTooth = TransformerGeometry.GetRotationVector(sweepAngle);

            CanvasPathBuilder pathBuilder   = new CanvasPathBuilder(resourceCreator);
            CanvasArcSize     canvasArcSize = (sweepAngle < System.Math.PI) ? CanvasArcSize.Large : CanvasArcSize.Small;

            {
                // DonutAndCookie
                // start notch
                Vector2 startNotch = startTooth * innerRadius;
                // end notch
                Vector2 endNotch = endTooth * innerRadius;

                // start tooth point
                pathBuilder.BeginFigure(startNotch);
                // start notch point
                pathBuilder.AddArc(endNotch, innerRadius, innerRadius, sweepAngle, CanvasSweepDirection.CounterClockwise, canvasArcSize);
            }

            // end notch point
            pathBuilder.AddLine(endTooth);

            // end tooth point
            pathBuilder.AddArc(startTooth, 1, 1, sweepAngle, CanvasSweepDirection.Clockwise, canvasArcSize);

            pathBuilder.EndFigure(CanvasFigureLoop.Closed);

            return(CanvasGeometry.CreatePath(pathBuilder).Transform(oneMatrix));
        }