-
-
Save abock/bd946d3fe7436bce79c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
namespace MonoMac.CoreGraphics | |
{ | |
public static class CGPathExtensions | |
{ | |
[DllImport (Constants.CoreGraphicsLibrary)] | |
static extern IntPtr CGPathCreateMutableCopy (IntPtr source); | |
[DllImport (Constants.CoreGraphicsLibrary)] | |
static extern void CGPathRelease (IntPtr source); | |
[DllImport (Constants.CoreGraphicsLibrary)] | |
unsafe static extern IntPtr CGPathCreateCopyByStrokingPath ( | |
IntPtr path, | |
CGAffineTransform *transform, | |
float lineWidth, | |
CGLineCap lineCap, | |
CGLineJoin lineJoin, | |
float miterLimit | |
); | |
public unsafe static CGPath CopyByStrokingPath (this CGPath path, CGAffineTransform transform, | |
float lineWidth, CGLineCap lineCap, CGLineJoin lineJoin, float miterLimit) | |
{ | |
var copy = CGPathCreateCopyByStrokingPath (path.Handle, | |
&transform, lineWidth, lineCap, lineJoin, miterLimit); | |
// this will call CGPathRetain, which we don't want | |
var mutable = CGPathCreateMutableCopy (copy); | |
CGPathRelease (mutable); // so immediately release it | |
CGPathRelease (copy); | |
return mutable; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment