use crate::ffi;
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Random(Boxed<ffi::GeglRandom>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gegl_random_get_type(), ptr as *mut _) as *mut ffi::GeglRandom,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gegl_random_get_type(), ptr as *mut _),
type_ => || ffi::gegl_random_get_type(),
}
}
impl Random {
#[doc(alias = "gegl_random_new")]
pub fn new() -> Random {
unsafe { from_glib_full(ffi::gegl_random_new()) }
}
#[doc(alias = "gegl_random_new_with_seed")]
#[doc(alias = "new_with_seed")]
pub fn with_seed(seed: u32) -> Random {
unsafe { from_glib_full(ffi::gegl_random_new_with_seed(seed)) }
}
#[doc(alias = "gegl_random_duplicate")]
#[must_use]
pub fn duplicate(&mut self) -> Option<Random> {
unsafe { from_glib_full(ffi::gegl_random_duplicate(self.to_glib_none_mut().0)) }
}
#[doc(alias = "gegl_random_float")]
pub fn float(&self, x: i32, y: i32, z: i32, n: i32) -> f32 {
unsafe { ffi::gegl_random_float(self.to_glib_none().0, x, y, z, n) }
}
#[doc(alias = "gegl_random_float_range")]
pub fn float_range(&self, x: i32, y: i32, z: i32, n: i32, min: f32, max: f32) -> f32 {
unsafe { ffi::gegl_random_float_range(self.to_glib_none().0, x, y, z, n, min, max) }
}
#[doc(alias = "gegl_random_int")]
pub fn int(&self, x: i32, y: i32, z: i32, n: i32) -> u32 {
unsafe { ffi::gegl_random_int(self.to_glib_none().0, x, y, z, n) }
}
#[doc(alias = "gegl_random_int_range")]
pub fn int_range(&self, x: i32, y: i32, z: i32, n: i32, min: i32, max: i32) -> i32 {
unsafe { ffi::gegl_random_int_range(self.to_glib_none().0, x, y, z, n, min, max) }
}
#[doc(alias = "gegl_random_set_seed")]
pub fn set_seed(&mut self, seed: u32) {
unsafe {
ffi::gegl_random_set_seed(self.to_glib_none_mut().0, seed);
}
}
}
impl Default for Random {
fn default() -> Self {
Self::new()
}
}