use crate::{error::PdfResult, objects::Dictionary, Resolve};
#[derive(Debug)]
pub struct ExponentialInterpolationFunction {
c0: Vec<f32>,
c1: Vec<f32>,
n: f32,
}
impl ExponentialInterpolationFunction {
pub fn from_dict(dict: &mut Dictionary, resolver: &mut dyn Resolve) -> PdfResult<Self> {
let c0 = dict
.get_arr("C0", resolver)?
.map(|arr| {
arr.into_iter()
.map(|obj| resolver.assert_number(obj))
.collect::<PdfResult<Vec<f32>>>()
})
.transpose()?
.unwrap_or_else(|| vec![0.0]);
let c1 = dict
.get_arr("C1", resolver)?
.map(|arr| {
arr.into_iter()
.map(|obj| resolver.assert_number(obj))
.collect::<PdfResult<Vec<f32>>>()
})
.transpose()?
.unwrap_or_else(|| vec![1.0]);
let n = dict.expect_number("N", resolver)?;
Ok(Self { c0, c1, n })
}
}