Exemple #1
0
        private static CanvasGeometry CreateHeartCore(ICanvasResourceCreator resourceCreator, float spread, Matrix3x2 oneMatrix)
        {
            Vector2 bottom = new Vector2(0, 1);

            Vector2 leftBottom  = new Vector2(-0.84f, 0.178f);
            Vector2 leftBottom2 = leftBottom + new Vector2(-0.2f, -0.2f);

            Vector2 leftTop  = new Vector2(-0.84f, -0.6f);
            Vector2 leftTop1 = leftTop + new Vector2(-0.2f, 0.2f);
            Vector2 leftTop2 = leftTop + new Vector2(0.2f, -0.2f);

            Vector2 top1      = new Vector2(-0.2f, -0.8f);
            Vector2 topSpread = TransformerGeometry.HeartTopSpread(spread);
            Vector2 top2      = new Vector2(0.2f, -0.8f);

            Vector2 rightTop  = new Vector2(0.84f, -0.6f);
            Vector2 rightTop1 = rightTop + new Vector2(-0.2f, -0.2f);
            Vector2 rightTop2 = rightTop + new Vector2(0.2f, 0.2f);

            Vector2 rightBottom  = new Vector2(0.84f, 0.178f);
            Vector2 rightBottom1 = rightBottom + new Vector2(0.2f, -0.2f);


            // Path
            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(resourceCreator);

            {
                pathBuilder.BeginFigure(bottom);
                pathBuilder.AddLine(leftBottom);

                pathBuilder.AddCubicBezier(leftBottom2, leftTop1, leftTop);

                pathBuilder.AddCubicBezier(leftTop2, top1, topSpread);
                pathBuilder.AddCubicBezier(top2, rightTop1, rightTop);

                pathBuilder.AddCubicBezier(rightTop2, rightBottom1, rightBottom);
                pathBuilder.EndFigure(CanvasFigureLoop.Closed);
            }

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