#[cfg(feature = "serde")]
use serde::Serialize;
use crate::raw::drawing::st_types::{emu_to_pt, st_percentage_to_float};
use crate::{
processed::drawing::common_types::rectangle_alignment::RectangleAlignmentValues,
raw::drawing::fill::blip_fill::XlsxTile,
};
use super::tile_flip::TileFlipValues;
#[cfg_attr(feature = "serde", derive(Serialize))]
#[derive(Debug, PartialEq, Clone)]
pub struct Tile {
pub alignment: RectangleAlignmentValues,
pub flip: TileFlipValues,
pub horizontal_ratio: f64,
pub vertical_ratio: f64,
pub horizontal_offset: f64,
pub vertical_offset: f64,
}
impl Tile {
pub(crate) fn from_raw(raw: XlsxTile) -> Self {
return Self {
alignment: RectangleAlignmentValues::from_string(raw.alignment),
flip: TileFlipValues::from_string(raw.flip),
horizontal_ratio: st_percentage_to_float(raw.sx.clone().unwrap_or(1 * 1000 * 100)),
vertical_ratio: st_percentage_to_float(raw.sy.clone().unwrap_or(1 * 1000 * 100)),
horizontal_offset: emu_to_pt(raw.tx.clone().unwrap_or(0)),
vertical_offset: emu_to_pt(raw.ty.clone().unwrap_or(0)),
};
}
}