[librsvg] drawing_ctx::state_get_stop_opacity() - Analogous to ::state_get_stop_color()



commit f5bccefa472d63f56c26d9186d26a2daa7707dda
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed May 31 13:15:01 2017 -0500

    drawing_ctx::state_get_stop_opacity() - Analogous to ::state_get_stop_color()

 rust/src/drawing_ctx.rs |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/rust/src/drawing_ctx.rs b/rust/src/drawing_ctx.rs
index b3754df..eaeb333 100644
--- a/rust/src/drawing_ctx.rs
+++ b/rust/src/drawing_ctx.rs
@@ -66,6 +66,7 @@ extern "C" {
     fn rsvg_state_has_overflow (state: *const RsvgState) -> glib_sys::gboolean;
     fn rsvg_state_get_cond_true (state: *const RsvgState) -> glib_sys::gboolean;
     fn rsvg_state_get_stop_color (state: *const RsvgState) -> *const ColorSpec;
+    fn rsvg_state_get_stop_opacity (state: *const RsvgState) -> *const OpacitySpec;
     fn rsvg_state_get_current_color (state: *const RsvgState) -> u32;
 
     fn rsvg_state_push (draw_ctx: *const RsvgDrawingCtx);
@@ -250,6 +251,18 @@ pub fn state_get_stop_color (state: *const RsvgState) -> Result<Option<Color>, A
     }
 }
 
+pub fn state_get_stop_opacity (state: *const RsvgState) -> Result<Option<Opacity>, AttributeError> {
+    unsafe {
+        let opacity_ptr = rsvg_state_get_stop_opacity (state);
+
+        if opacity_ptr.is_null () {
+            Ok (None)
+        } else {
+            Opacity::from_opacity_spec (&*opacity_ptr).map (|opacity| Some (opacity))
+        }
+    }
+}
+
 pub fn state_get_current_color (state: *const RsvgState) -> u32 {
     unsafe {
         rsvg_state_get_current_color (state)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]