Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CGMutablePath in Xamarin

I am trying to translate this code for my Xamarin.iOS app:

https://github.com/yourtion/YXWaveView/blob/master/YXWaveView/YXWaveView.swift

On line 179:

let path = CGMutablePath()

I can't find CGMutablePath in Xamarin?

like image 664
Drake Avatar asked Oct 24 '25 19:10

Drake


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);
        }
 ~~~~~
like image 161
SushiHangover Avatar answered Oct 26 '25 08:10

SushiHangover


You can use this:

var path = new CGPath();
like image 33
Umair M Avatar answered Oct 26 '25 08:10

Umair M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!