1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // external use usvg::{ self, Color, }; /// Image fit options. #[derive(Clone, Copy, PartialEq, Debug)] pub enum FitTo { /// Keep original size. Original, /// Scale to width. Width(u32), /// Scale to height. Height(u32), /// Zoom by factor. Zoom(f32), } /// Rendering options. pub struct Options { /// `usvg` preprocessor options. pub usvg: usvg::Options, /// Fits the image using specified options. /// /// Does not affect rendering to canvas. pub fit_to: FitTo, /// An image background color. /// /// Sets an image background color. Does not affect rendering to canvas. /// /// `None` equals to transparent. pub background: Option<Color>, } impl Default for Options { fn default() -> Options { Options { usvg: usvg::Options::default(), fit_to: FitTo::Original, background: None, } } }