ViewParams: new struct to hold values required for Length normalization

We'll decouple Length from DrawingCtx with this.
parent 08663afb
......@@ -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)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment