Example #1
0
        public override void QuadraticBezierTo(Point point1, Point point2, bool isStroked, bool isSmoothJoin)
        {
#if XAMARIN_IOS_UNIFIED || XAMARIN_IOS
            bezierPath.AddQuadCurveToPoint(point2, point1);
#elif XAMARIN_ANDROID
            var physicalPoint1 = LogicalToPhysicalNoRounding(point1);
            var physicalPoint2 = LogicalToPhysicalNoRounding(point2);
            bezierPath.QuadTo((float)physicalPoint1.X, (float)physicalPoint1.Y, (float)physicalPoint2.X, (float)physicalPoint2.Y);
#endif

            _points.Add(point2);
        }
        public override void QuadraticBezierTo(Point point1, Point point2, bool isStroked, bool isSmoothJoin)
        {
#if __IOS__
            bezierPath.AddQuadCurveToPoint(point2, point1);
#elif __MACOS__
            // Convert a Quadratic Curve to cubic curve to draw it.
            // https://stackoverflow.com/a/52569210/1771254
            var startPoint = bezierPath.CurrentPoint;
            var endPoint   = point1;

            var controlPoint1 = new CGPoint(startPoint.X + ((point2.X - startPoint.X) * 2.0 / 3.0), startPoint.Y + (point2.Y - startPoint.Y) * 2.0 / 3.0);
            var controlPoint2 = new CGPoint(endPoint.X + ((point2.X - endPoint.X) * 2.0 / 3.0), endPoint.Y + (point2.Y - endPoint.Y) * 2.0 / 3.0);
            bezierPath.CurveTo(point1, controlPoint1, controlPoint2);
#elif __ANDROID__
            bezierPath.QuadTo((float)point1.X, (float)point1.Y, (float)point2.X, (float)point2.Y);
#elif __SKIA__
            bezierPath.Geometry.QuadTo((float)point1.X, (float)point1.Y, (float)point2.X, (float)point2.Y);
#endif

            _points.Add(point2);
        }