diff --git a/binding/Binding/SKPath.cs b/binding/Binding/SKPath.cs index bff17899..93e23a88 100644 --- a/binding/Binding/SKPath.cs +++ b/binding/Binding/SKPath.cs @@ -80,6 +80,15 @@ namespace SkiaSharp } } + public SKPoint LastPoint + { + get { + SKPoint point; + SkiaApi.sk_path_get_last_point (Handle, out point); + return point; + } + } + public SKPoint GetPoint (int index) { SKPoint point; @@ -99,6 +108,11 @@ namespace SkiaSharp return SkiaApi.sk_path_get_points (Handle, points, max); } + public bool Contains (float x, float y) + { + return SkiaApi.sk_path_contains (Handle, x, y); + } + public void MoveTo (float x, float y) { SkiaApi.sk_path_move_to (Handle, x, y); diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index dce6ac7f..6b747f34 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -379,6 +379,12 @@ namespace SkiaSharp public extern static uint sk_image_get_unique_id(sk_image_t t); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public extern static bool sk_path_contains (sk_path_t cpath, float x, float y); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public extern static bool sk_path_get_last_point (sk_path_t cpath, out SKPoint point); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static sk_path_t sk_path_new(); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] diff --git a/skia b/skia index fa414e4d..66b97f55 160000 --- a/skia +++ b/skia @@ -1 +1 @@ -Subproject commit fa414e4d96c6460161fd750ad13bc50780d0c53a +Subproject commit 66b97f55fe30c3d6b6d9aa10f1dc01ac98ff68b6 diff --git a/tests/Tests/SKPathTest.cs b/tests/Tests/SKPathTest.cs index 782e5dde..72aeced7 100644 --- a/tests/Tests/SKPathTest.cs +++ b/tests/Tests/SKPathTest.cs @@ -37,5 +37,27 @@ namespace SkiaSharp.Tests Assert.AreEqual (new SKPoint (68.6763107f, 56.0058575f), path.Points [1]); } } + + [Test] + public void PathContainsPoint() + { + using (var path = new SKPath ()) { + path.AddRect (SKRect.Create (10, 10, 100, 100), SKPathDirection.Clockwise); + + Assert.IsTrue (path.Contains (30, 30)); + Assert.IsFalse (path.Contains (5, 30)); + } + } + + [Test] + public void GetLastPoint() + { + using (var path = new SKPath ()) { + path.MoveTo (0, 0); + path.LineTo (10, 20); + + Assert.AreEqual (new SKPoint(10, 20), path.LastPoint); + } + } } }