CGMutablePath in Xamarin

Viewed 429
2 Answers

An ObjC CGMutablePathRef struct (or Swift CGMutablePath class) is wrapped by Xamarin.iOS as a CGPath (CoreGraphics namespace).

var path = new CGPath();

xamarin-macios/src/CoreGraphics/CGPath.cs

public class CGPath : INativeObject, IDisposable {
        internal IntPtr handle;

        [DllImport (Constants.CoreGraphicsLibrary)]
        extern static /* CGMutablePathRef */ IntPtr CGPathCreateMutable ();

        public CGPath ()
        {
            handle = CGPathCreateMutable ();
        }

        [Mac(10,7)][iOS (5,0)]
        public CGPath (CGPath reference, CGAffineTransform transform)
        {
            if (reference == null)
                throw new ArgumentNullException ("reference");
            handle = CGPathCreateMutableCopyByTransformingPath (reference.Handle, ref transform);
        }

        [DllImport (Constants.CoreGraphicsLibrary)]
        extern static /* CGMutablePathRef */ IntPtr CGPathCreateMutableCopy (/* CGPathRef */ IntPtr path);

        public CGPath (CGPath basePath)
        {
            if (basePath == null)
                throw new ArgumentNullException ("basePath");
            handle = CGPathCreateMutableCopy (basePath.handle);
        }
 ~~~~~

You can use this:

var path = new CGPath();
Related