Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
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