aboutsummaryrefslogtreecommitdiffstatsci
path: root/Backends/VkvgBackend/src/Pattern.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-11-23 02:23:24 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-11-23 02:23:24 +0100
commitd396c47e492aa7badcfefba41c36c516558fb1ec (patch)
treeb8a6b6f68313aa9ac9bf7bb10c1004df7489e633 /Backends/VkvgBackend/src/Pattern.cs
parentdbb9034d864fc42f92a66b08a0734edc3dc73e8c (diff)
save commit, Drawing2D shared lib
Diffstat (limited to 'Backends/VkvgBackend/src/Pattern.cs')
-rw-r--r--Backends/VkvgBackend/src/Pattern.cs72
1 files changed, 72 insertions, 0 deletions
diff --git a/Backends/VkvgBackend/src/Pattern.cs b/Backends/VkvgBackend/src/Pattern.cs
new file mode 100644
index 00000000..b25e26b2
--- /dev/null
+++ b/Backends/VkvgBackend/src/Pattern.cs
@@ -0,0 +1,72 @@
+// Copyright (c) 2018-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+namespace Crow.Drawing
+{
+ public class Pattern : IDisposable
+ {
+ protected IntPtr handle = IntPtr.Zero;
+
+ #region CTORS & DTOR
+ protected Pattern(IntPtr handle)
+ {
+ this.handle = handle;
+ }
+ public Pattern(float r, float g, float b)
+ {
+ handle = NativeMethods.vkvg_pattern_create_rgb(r, g, b);
+ }
+ public Pattern(float r, float g, float b, float a)
+ {
+ handle = NativeMethods.vkvg_pattern_create_rgba(r, g, b, a);
+ }
+ public Pattern(Surface surf)
+ {
+ handle = NativeMethods.vkvg_pattern_create_for_surface(surf.Handle);
+ }
+
+ ~Pattern()
+ {
+ Dispose(false);
+ }
+ #endregion
+
+ public void AddReference()
+ {
+ NativeMethods.vkvg_pattern_reference(handle);
+ }
+ public uint References() => NativeMethods.vkvg_pattern_get_reference_count(handle);
+
+ public IntPtr Handle => handle;
+
+ public Extend Extend
+ {
+ set { NativeMethods.vkvg_pattern_set_extend(handle, value); }
+ get { return NativeMethods.vkvg_pattern_get_extend(handle); }
+ }
+ public Filter Filter
+ {
+ set { NativeMethods.vkvg_pattern_set_filter(handle, value); }
+ get { return NativeMethods.vkvg_pattern_get_filter(handle); }
+ }
+
+ #region IDisposable implementation
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposing || handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.vkvg_pattern_destroy(handle);
+ handle = IntPtr.Zero;
+ }
+ #endregion
+ }
+} \ No newline at end of file