有可能创建一个贝塞尔曲线半圆Xamarin Forms SkiaSharp

时间:2019-11-26 18:40:59

标签: xamarin xamarin.forms skiasharp

嗨,我正在尝试重现这样的东西

demo

我遵循此Issue中的回复,但是无法接近图片中的内容。

编辑:我添加了到目前为止所做的事情,如您在图像中看到的那样,当曲线结束时我无法获得完美的圆角。

work


        private void SKCanvasView_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
        {
            SKSurface surface = e.Surface;
            SKCanvas canvas = surface.Canvas;
            canvas.Clear(SKColors.White);

            float canvasWidth = canvas.LocalClipBounds.Width;
            float canvasHeight = canvas.LocalClipBounds.Height;

            using (SKPath bezierPath = new SKPath())
            {
                //Start at bottom
                bezierPath.MoveTo(0, canvasHeight);

                bezierPath.LineTo(0, canvasHeight * 0.6f);

                bezierPath.LineTo(canvasWidth * 0.2f, canvasHeight * 0.6f);

                bezierPath.CubicTo(canvasWidth * 0.4f, canvasHeight * 0.6f,
                                   canvasWidth * 0.5f, canvasHeight * 0f,
                                   canvasWidth * 0.8f, canvasHeight * 0.6f);

                bezierPath.LineTo(canvasWidth, canvasHeight * 0.6f);
                bezierPath.LineTo(canvasWidth, canvasHeight);

                bezierPath.Close();

                canvas.DrawPath(bezierPath, _paint);
            }
        }

0 个答案:

没有答案