Exemple #1
0
        public GlobularTextPage()
        {
            Title = "Globular Text";

            canvasView = new SKCanvasView();
            canvasView.PaintSurface += OnCanvasViewPaintSurface;
            Content = canvasView;

            using (SKPaint textPaint = new SKPaint())
            {
                textPaint.Typeface = SKTypeface.FromFamilyName("Times New Roman");
                textPaint.TextSize = 100;

                using (SKPath textPath = textPaint.GetTextPath("HELLO", 0, 0))
                {
                    SKRect textPathBounds;
                    textPath.GetBounds(out textPathBounds);

                    globePath = textPath.CloneWithTransform((SKPoint pt) =>
                    {
                        double longitude = (Math.PI / textPathBounds.Width) * (pt.X - textPathBounds.Left) - Math.PI / 2;
                        double latitude  = (Math.PI / textPathBounds.Height) * (pt.Y - textPathBounds.Top) - Math.PI / 2;

                        longitude *= 0.75;
                        latitude  *= 0.75;

                        float x = (float)(Math.Cos(latitude) * Math.Sin(longitude));
                        float y = (float)Math.Sin(latitude);

                        return(new SKPoint(x, y));
                    });
                }
            }
        }