[librsvg] ViewParams: new struct to hold values required for Length normalization



commit 57504521fbed2fecd02256dc327d69388bdb9f83
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 3 13:38:31 2018 -0500

    ViewParams: new struct to hold values required for Length normalization
    
    We'll decouple Length from DrawingCtx with this.

 rsvg_internals/src/drawing_ctx.rs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 556d1804..ce54ce92 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -39,6 +39,14 @@ use tree::{RsvgTree, Tree};
 use unitinterval::UnitInterval;
 use viewbox::ViewBox;
 
+/// Holds values that are required to normalize `Length` values to a current viewport.
+pub struct ViewParams {
+    pub dpi_x: f64,
+    pub dpi_y: f64,
+    pub view_box_width: f64,
+    pub view_box_height: f64,
+}
+
 pub enum RsvgDrawingCtx {}
 
 pub struct DrawingCtx<'a> {
@@ -171,6 +179,15 @@ impl<'a> DrawingCtx<'a> {
         }
     }
 
+    pub fn get_view_params(&self) -> ViewParams {
+        ViewParams {
+            dpi_x: self.dpi_x,
+            dpi_y: self.dpi_y,
+            view_box_width: self.vb.0.width,
+            view_box_height: self.vb.0.height,
+        }
+    }
+
     pub fn get_dpi(&self) -> (f64, f64) {
         (self.dpi_x, self.dpi_y)
     }


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