use std::ffi::c_int;
use crate::{ffi, image_type, CreateFailed, Fixed, GradientStop, Point};
image_type! {
#[derive(Debug)]
ConicalGradient
}
impl ConicalGradient<'static> {
pub fn new(
center: impl Into<Point>,
angle: impl Into<Fixed>,
stops: &[GradientStop],
) -> Result<Self, CreateFailed> {
let center = center.into();
let angle = angle.into();
let ptr = unsafe {
ffi::pixman_image_create_conical_gradient(
center.as_ptr(),
angle.into_raw(),
stops.as_ptr() as *const _,
stops.len() as c_int,
)
};
if ptr.is_null() {
Err(CreateFailed)
} else {
Ok(unsafe { Self::from_ptr(ptr) })
}
}
}