graphene-rs-0.19.2/.cargo_vcs_info.json0000644000000001460000000000100133410ustar { "git": { "sha1": "23c5599424cc75ec66618891c915d9f490f6e4c2" }, "path_in_vcs": "graphene" }graphene-rs-0.19.2/COPYRIGHT000064400000000000000000000012131046102023000134200ustar 00000000000000The gtk-rs Project is licensed under the MIT license, see the LICENSE file or . Copyrights in the gtk-rs Project project are retained by their contributors. No copyright assignment is required to contribute to the gtk-rs Project project. For full authorship information, see the version control history. This project provides interoperability with various GNOME libraries but doesn't distribute any parts of them. Distributing compiled libraries and executables that link to those libraries may be subject to terms of the GNU LGPL or other licenses. For more information check the license of each GNOME library. graphene-rs-0.19.2/Cargo.toml0000644000000025630000000000100113440ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.70" name = "graphene-rs" version = "0.19.2" authors = ["The gtk-rs Project Developers"] exclude = ["gir-files/*"] description = "Rust bindings for the Graphene library" homepage = "https://gtk-rs.org/" documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/graphene/" readme = "README.md" keywords = [ "graphene", "graphene-rs", "gtk-rs", "gnome", "GUI", ] license = "MIT" repository = "https://github.com/gtk-rs/gtk-rs-core" [package.metadata.docs.rs] all-features = true rustc-args = [ "--cfg", "docsrs", ] rustdoc-args = [ "--cfg", "docsrs", "--generate-link-to-definition", ] [lib] name = "graphene" [dependencies.ffi] version = "0.19" package = "graphene-sys" [dependencies.glib] version = "0.19" [dependencies.libc] version = "0.2" [dev-dependencies.gir-format-check] version = "^0.1" [features] v1_12 = ["ffi/v1_12"] graphene-rs-0.19.2/Cargo.toml.orig000064400000000000000000000015201046102023000150150ustar 00000000000000[package] name = "graphene-rs" keywords = ["graphene", "graphene-rs", "gtk-rs", "gnome", "GUI"] readme = "README.md" documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/graphene/" description = "Rust bindings for the Graphene library" authors.workspace = true edition.workspace = true exclude.workspace = true homepage.workspace = true license.workspace = true repository.workspace = true rust-version.workspace = true version.workspace = true [lib] name = "graphene" [features] v1_12 = ["ffi/v1_12"] [dependencies] ffi = { package = "graphene-sys", path = "sys", version = "0.19" } libc.workspace = true glib.workspace = true [dev-dependencies] gir-format-check.workspace = true [package.metadata.docs.rs] all-features = true rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] graphene-rs-0.19.2/Gir.toml000064400000000000000000000314371046102023000135560ustar 00000000000000[options] girs_directories = ["../gir-files"] library = "Graphene" version = "1.0" min_cfg_version = "1.10" target_path = "." work_mode = "normal" generate_safety_asserts = true single_version_file = true deprecate_by_min_version = true trust_return_value_nullability = true generate = [ "Graphene.EulerOrder", "Graphene.RayIntersectionKind", ] [[object]] name = "Graphene.*" status = "generate" [[object.constant]] name = "SIMD_S" ignore = true [[object]] name = "Graphene.Box" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_box" ignore = true # Copy like constructor [[object.function]] name = "init" manual = true # manual proper constructor rename = "new" [[object.function]] name = "init_from_points" manual = true # manual proper constructor rename = "from_points" [[object.function]] name = "init_from_vec3" manual = true # manual proper constructor rename = "from_vec3" [[object.function]] name = "init_from_vectors" manual = true # manual proper constructor rename = "from_vectors" [[object.function]] name = "get_vertices" # float array manual = true [[object]] name = "Graphene.Euler" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_euler" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_matrix" rename = "from_matrix" manual = true # manual proper constructor [[object.function]] name = "init_from_quaternion" rename = "from_quaternion" manual = true # manual proper constructor [[object.function]] name = "init_from_radians" rename = "from_radians" manual = true # manual proper constructor [[object.function]] name = "init_from_vec3" rename = "from_vec3" manual = true # manual proper constructor [[object.function]] name = "init_with_order" rename = "with_order" manual = true # manual proper constructor [[object]] name = "Graphene.Frustum" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_frustum" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_matrix" rename = "from_matrix" manual = true # manual proper constructor [[object.function]] name = "get_planes" # float array manual = true [[object]] name = "Graphene.Matrix" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_matrix" ignore = true # Copy like constructor [[object.function]] name = "init_from_2d" rename = "from_2d" manual = true # manual proper constructor [[object.function]] name = "init_from_float" rename = "from_float" manual = true # manual proper constructor [[object.function]] name = "init_from_vec4" rename = "from_vec4" manual = true # manual proper constructor [[object.function]] name = "init_frustum" rename = "new_frustum" manual = true # manual proper constructor [[object.function]] name = "init_identity" rename = "new_identity" manual = true # manual proper constructor [[object.function]] name = "init_look_at" rename = "new_look_at" manual = true # manual proper constructor [[object.function]] name = "init_ortho" rename = "new_ortho" manual = true # manual proper constructor [[object.function]] name = "init_perspective" rename = "new_perspective" manual = true # manual proper constructor [[object.function]] name = "init_rotate" rename = "new_rotate" manual = true # manual proper constructor [[object.function]] name = "init_scale" rename = "new_scale" manual = true # manual proper constructor [[object.function]] name = "init_skew" rename = "new_skew" manual = true # manual proper constructor [[object.function]] name = "init_translate" rename = "new_translate" manual = true # manual proper constructor [[object.function]] name = "to_float" # float array manual = true [[object]] name = "Graphene.Plane" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_plane" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_point" rename = "from_point" manual = true # manual proper constructor [[object.function]] name = "init_from_points" rename = "from_points" manual = true # manual proper constructor [[object.function]] name = "init_from_vec4" rename = "from_vec4" manual = true # manual proper constructor [[object]] name = "Graphene.Point" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_point" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_vec2" rename = "from_vec2" manual = true # manual proper constructor [[object]] name = "Graphene.Point3D" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_point" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_vec3" rename = "from_vec3" manual = true # manual proper constructor [[object]] name = "Graphene.Quad" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_rect" rename = "from_rect" manual = true # manual proper constructor [[object.function]] name = "init_from_points" rename = "from_points" manual = true # manual proper constructor [[object.function]] name = "get_point" # needs bounds check manual = true [[object]] name = "Graphene.Quaternion" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_quaternion" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_angle_vec3" rename = "from_angle_vec3" manual = true # manual proper constructor [[object.function]] name = "init_from_angles" rename = "from_angles" manual = true # manual proper constructor [[object.function]] name = "init_from_euler" rename = "from_euler" manual = true # manual proper constructor [[object.function]] name = "init_from_matrix" rename = "from_matrix" manual = true # manual proper constructor [[object.function]] name = "init_from_radians" rename = "from_radians" manual = true # manual proper constructor [[object.function]] name = "init_from_vec4" rename = "from_vec4" manual = true # manual proper constructor [[object.function]] name = "init_identity" rename = "new_identity" manual = true # manual proper constructor [[object]] name = "Graphene.Ray" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_ray" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_vec3" rename = "from_vec3" manual = true # manual proper constructor [[object]] name = "Graphene.Rect" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_rect" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "get_vertices" # float array manual = true [[object.function]] name = "inset" [object.function.return] type = "none" [[object.function]] name = "normalize" [object.function.return] type = "none" [[object.function]] name = "offset" [object.function.return] type = "none" [[object]] # missing memory management functions name = "Graphene.Simd4F" status = "ignore" [[object]] # missing memory management functions name = "Graphene.Simd4X4F" status = "ignore" [[object]] name = "Graphene.Size" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_size" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object]] name = "Graphene.Sphere" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_points" rename = "from_points" manual = true # manual proper constructor [[object.function]] name = "init_from_vectors" rename = "from_vectors" manual = true # manual proper constructor [[object]] name = "Graphene.Triangle" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_float" rename = "from_float" manual = true # manual proper constructor [[object.function]] name = "init_from_point3d" rename = "from_point3d" manual = true # manual proper constructor [[object.function]] name = "init_from_vec3" rename = "from_vec3" manual = true # manual proper constructor [[object]] name = "Graphene.Vec2" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_vec2" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_float" rename = "from_float" manual = true # manual proper constructor [[object.function]] name = "to_float" # float array manual = true [[object]] name = "Graphene.Vec3" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_vec3" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_float" rename = "from_float" manual = true # manual proper constructor [[object.function]] name = "to_float" # float array manual = true [[object]] name = "Graphene.Vec4" status = "generate" boxed_inline = true [[object.function]] # contents undefined name = "alloc" ignore = true [[object.function]] name = "init_from_vec4" ignore = true # Copy like constructor [[object.function]] name = "init" rename = "new" manual = true # manual proper constructor [[object.function]] name = "init_from_vec2" rename = "from_vec2" manual = true # manual proper constructor [[object.function]] name = "init_from_vec3" rename = "from_vec3" manual = true # manual proper constructor [[object.function]] name = "init_from_float" rename = "from_float" manual = true # manual proper constructor [[object.function]] name = "to_float" # float array manual = true graphene-rs-0.19.2/LICENSE000064400000000000000000000020001046102023000131250ustar 00000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. graphene-rs-0.19.2/README.md000064400000000000000000000024641046102023000134150ustar 00000000000000# Rust Graphene bindings __Rust__ bindings and wrappers for [__Graphene__](https://github.com/ebassi/graphene), part of [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core). Graphene __1.10__ is the lowest supported version for the underlying library. ## Minimum supported Rust version Currently, the minimum supported Rust version is `1.70.0`. ## Documentation * [Rust API - Stable](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/graphene/) * [Rust API - Development](https://gtk-rs.org/gtk-rs-core/git/docs/graphene) * [C API](https://ebassi.github.io/graphene/docs/) * [GTK Installation instructions](https://www.gtk.org/docs/installations/) ## Using We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), as [demonstrated here](https://gtk-rs.org/#using). If you want to track the bleeding edge, use the git dependency instead: ```toml [dependencies] graphene = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "graphene" } ``` Avoid mixing versioned and git crates like this: ```toml # This will not compile [dependencies] graphene = "0.13" graphene = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "graphene" } ``` ### See Also * [glib](https://crates.io/crates/glib) ## License __graphene__ is available under the MIT License, please refer to it. graphene-rs-0.19.2/src/auto/box_.rs000064400000000000000000000147041046102023000151720ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Point3D, Sphere, Vec3}; use glib::translate::*; glib::wrapper! { pub struct Box(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_box_get_type(), ptr as *mut _) as *mut ffi::graphene_box_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_box_get_type(), ptr as *mut _), type_ => || ffi::graphene_box_get_type(), } } impl Box { #[doc(alias = "graphene_box_contains_box")] pub fn contains_box(&self, b: &Box) -> bool { unsafe { ffi::graphene_box_contains_box(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_box_contains_point")] pub fn contains_point(&self, point: &Point3D) -> bool { unsafe { ffi::graphene_box_contains_point(self.to_glib_none().0, point.to_glib_none().0) } } #[doc(alias = "graphene_box_equal")] fn equal(&self, b: &Box) -> bool { unsafe { ffi::graphene_box_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_box_expand")] #[must_use] pub fn expand(&self, point: &Point3D) -> Box { unsafe { let mut res = Box::uninitialized(); ffi::graphene_box_expand( self.to_glib_none().0, point.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_box_expand_scalar")] #[must_use] pub fn expand_scalar(&self, scalar: f32) -> Box { unsafe { let mut res = Box::uninitialized(); ffi::graphene_box_expand_scalar( self.to_glib_none().0, scalar, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_box_expand_vec3")] #[must_use] pub fn expand_vec3(&self, vec: &Vec3) -> Box { unsafe { let mut res = Box::uninitialized(); ffi::graphene_box_expand_vec3( self.to_glib_none().0, vec.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_box_get_bounding_sphere")] #[doc(alias = "get_bounding_sphere")] pub fn bounding_sphere(&self) -> Sphere { unsafe { let mut sphere = Sphere::uninitialized(); ffi::graphene_box_get_bounding_sphere( self.to_glib_none().0, sphere.to_glib_none_mut().0, ); sphere } } #[doc(alias = "graphene_box_get_center")] #[doc(alias = "get_center")] pub fn center(&self) -> Point3D { unsafe { let mut center = Point3D::uninitialized(); ffi::graphene_box_get_center(self.to_glib_none().0, center.to_glib_none_mut().0); center } } #[doc(alias = "graphene_box_get_depth")] #[doc(alias = "get_depth")] pub fn depth(&self) -> f32 { unsafe { ffi::graphene_box_get_depth(self.to_glib_none().0) } } #[doc(alias = "graphene_box_get_height")] #[doc(alias = "get_height")] pub fn height(&self) -> f32 { unsafe { ffi::graphene_box_get_height(self.to_glib_none().0) } } #[doc(alias = "graphene_box_get_max")] #[doc(alias = "get_max")] pub fn max(&self) -> Point3D { unsafe { let mut max = Point3D::uninitialized(); ffi::graphene_box_get_max(self.to_glib_none().0, max.to_glib_none_mut().0); max } } #[doc(alias = "graphene_box_get_min")] #[doc(alias = "get_min")] pub fn min(&self) -> Point3D { unsafe { let mut min = Point3D::uninitialized(); ffi::graphene_box_get_min(self.to_glib_none().0, min.to_glib_none_mut().0); min } } #[doc(alias = "graphene_box_get_size")] #[doc(alias = "get_size")] pub fn size(&self) -> Vec3 { unsafe { let mut size = Vec3::uninitialized(); ffi::graphene_box_get_size(self.to_glib_none().0, size.to_glib_none_mut().0); size } } #[doc(alias = "graphene_box_get_width")] #[doc(alias = "get_width")] pub fn width(&self) -> f32 { unsafe { ffi::graphene_box_get_width(self.to_glib_none().0) } } #[doc(alias = "graphene_box_intersection")] pub fn intersection(&self, b: &Box) -> Option { unsafe { let mut res = Box::uninitialized(); let ret = ffi::graphene_box_intersection( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); if ret { Some(res) } else { None } } } #[doc(alias = "graphene_box_union")] #[must_use] pub fn union(&self, b: &Box) -> Box { unsafe { let mut res = Box::uninitialized(); ffi::graphene_box_union( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_box_empty")] pub fn empty() -> Box { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_box_empty()) } } #[doc(alias = "graphene_box_infinite")] pub fn infinite() -> Box { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_box_infinite()) } } #[doc(alias = "graphene_box_minus_one")] pub fn minus_one() -> Box { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_box_minus_one()) } } #[doc(alias = "graphene_box_one")] pub fn one() -> Box { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_box_one()) } } #[doc(alias = "graphene_box_one_minus_one")] pub fn one_minus_one() -> Box { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_box_one_minus_one()) } } #[doc(alias = "graphene_box_zero")] pub fn zero() -> Box { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_box_zero()) } } } impl PartialEq for Box { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Box {} graphene-rs-0.19.2/src/auto/enums.rs000064400000000000000000000167531046102023000154000ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::translate::*; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "graphene_euler_order_t")] pub enum EulerOrder { #[doc(alias = "GRAPHENE_EULER_ORDER_DEFAULT")] Default, #[doc(alias = "GRAPHENE_EULER_ORDER_XYZ")] Xyz, #[doc(alias = "GRAPHENE_EULER_ORDER_YZX")] Yzx, #[doc(alias = "GRAPHENE_EULER_ORDER_ZXY")] Zxy, #[doc(alias = "GRAPHENE_EULER_ORDER_XZY")] Xzy, #[doc(alias = "GRAPHENE_EULER_ORDER_YXZ")] Yxz, #[doc(alias = "GRAPHENE_EULER_ORDER_ZYX")] Zyx, #[doc(alias = "GRAPHENE_EULER_ORDER_SXYZ")] Sxyz, #[doc(alias = "GRAPHENE_EULER_ORDER_SXYX")] Sxyx, #[doc(alias = "GRAPHENE_EULER_ORDER_SXZY")] Sxzy, #[doc(alias = "GRAPHENE_EULER_ORDER_SXZX")] Sxzx, #[doc(alias = "GRAPHENE_EULER_ORDER_SYZX")] Syzx, #[doc(alias = "GRAPHENE_EULER_ORDER_SYZY")] Syzy, #[doc(alias = "GRAPHENE_EULER_ORDER_SYXZ")] Syxz, #[doc(alias = "GRAPHENE_EULER_ORDER_SYXY")] Syxy, #[doc(alias = "GRAPHENE_EULER_ORDER_SZXY")] Szxy, #[doc(alias = "GRAPHENE_EULER_ORDER_SZXZ")] Szxz, #[doc(alias = "GRAPHENE_EULER_ORDER_SZYX")] Szyx, #[doc(alias = "GRAPHENE_EULER_ORDER_SZYZ")] Szyz, #[doc(alias = "GRAPHENE_EULER_ORDER_RZYX")] Rzyx, #[doc(alias = "GRAPHENE_EULER_ORDER_RXYX")] Rxyx, #[doc(alias = "GRAPHENE_EULER_ORDER_RYZX")] Ryzx, #[doc(alias = "GRAPHENE_EULER_ORDER_RXZX")] Rxzx, #[doc(alias = "GRAPHENE_EULER_ORDER_RXZY")] Rxzy, #[doc(alias = "GRAPHENE_EULER_ORDER_RYZY")] Ryzy, #[doc(alias = "GRAPHENE_EULER_ORDER_RZXY")] Rzxy, #[doc(alias = "GRAPHENE_EULER_ORDER_RYXY")] Ryxy, #[doc(alias = "GRAPHENE_EULER_ORDER_RYXZ")] Ryxz, #[doc(alias = "GRAPHENE_EULER_ORDER_RZXZ")] Rzxz, #[doc(alias = "GRAPHENE_EULER_ORDER_RXYZ")] Rxyz, #[doc(alias = "GRAPHENE_EULER_ORDER_RZYZ")] Rzyz, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for EulerOrder { type GlibType = ffi::graphene_euler_order_t; fn into_glib(self) -> ffi::graphene_euler_order_t { match self { Self::Default => ffi::GRAPHENE_EULER_ORDER_DEFAULT, Self::Xyz => ffi::GRAPHENE_EULER_ORDER_XYZ, Self::Yzx => ffi::GRAPHENE_EULER_ORDER_YZX, Self::Zxy => ffi::GRAPHENE_EULER_ORDER_ZXY, Self::Xzy => ffi::GRAPHENE_EULER_ORDER_XZY, Self::Yxz => ffi::GRAPHENE_EULER_ORDER_YXZ, Self::Zyx => ffi::GRAPHENE_EULER_ORDER_ZYX, Self::Sxyz => ffi::GRAPHENE_EULER_ORDER_SXYZ, Self::Sxyx => ffi::GRAPHENE_EULER_ORDER_SXYX, Self::Sxzy => ffi::GRAPHENE_EULER_ORDER_SXZY, Self::Sxzx => ffi::GRAPHENE_EULER_ORDER_SXZX, Self::Syzx => ffi::GRAPHENE_EULER_ORDER_SYZX, Self::Syzy => ffi::GRAPHENE_EULER_ORDER_SYZY, Self::Syxz => ffi::GRAPHENE_EULER_ORDER_SYXZ, Self::Syxy => ffi::GRAPHENE_EULER_ORDER_SYXY, Self::Szxy => ffi::GRAPHENE_EULER_ORDER_SZXY, Self::Szxz => ffi::GRAPHENE_EULER_ORDER_SZXZ, Self::Szyx => ffi::GRAPHENE_EULER_ORDER_SZYX, Self::Szyz => ffi::GRAPHENE_EULER_ORDER_SZYZ, Self::Rzyx => ffi::GRAPHENE_EULER_ORDER_RZYX, Self::Rxyx => ffi::GRAPHENE_EULER_ORDER_RXYX, Self::Ryzx => ffi::GRAPHENE_EULER_ORDER_RYZX, Self::Rxzx => ffi::GRAPHENE_EULER_ORDER_RXZX, Self::Rxzy => ffi::GRAPHENE_EULER_ORDER_RXZY, Self::Ryzy => ffi::GRAPHENE_EULER_ORDER_RYZY, Self::Rzxy => ffi::GRAPHENE_EULER_ORDER_RZXY, Self::Ryxy => ffi::GRAPHENE_EULER_ORDER_RYXY, Self::Ryxz => ffi::GRAPHENE_EULER_ORDER_RYXZ, Self::Rzxz => ffi::GRAPHENE_EULER_ORDER_RZXZ, Self::Rxyz => ffi::GRAPHENE_EULER_ORDER_RXYZ, Self::Rzyz => ffi::GRAPHENE_EULER_ORDER_RZYZ, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for EulerOrder { unsafe fn from_glib(value: ffi::graphene_euler_order_t) -> Self { skip_assert_initialized!(); match value { ffi::GRAPHENE_EULER_ORDER_DEFAULT => Self::Default, ffi::GRAPHENE_EULER_ORDER_XYZ => Self::Xyz, ffi::GRAPHENE_EULER_ORDER_YZX => Self::Yzx, ffi::GRAPHENE_EULER_ORDER_ZXY => Self::Zxy, ffi::GRAPHENE_EULER_ORDER_XZY => Self::Xzy, ffi::GRAPHENE_EULER_ORDER_YXZ => Self::Yxz, ffi::GRAPHENE_EULER_ORDER_ZYX => Self::Zyx, ffi::GRAPHENE_EULER_ORDER_SXYZ => Self::Sxyz, ffi::GRAPHENE_EULER_ORDER_SXYX => Self::Sxyx, ffi::GRAPHENE_EULER_ORDER_SXZY => Self::Sxzy, ffi::GRAPHENE_EULER_ORDER_SXZX => Self::Sxzx, ffi::GRAPHENE_EULER_ORDER_SYZX => Self::Syzx, ffi::GRAPHENE_EULER_ORDER_SYZY => Self::Syzy, ffi::GRAPHENE_EULER_ORDER_SYXZ => Self::Syxz, ffi::GRAPHENE_EULER_ORDER_SYXY => Self::Syxy, ffi::GRAPHENE_EULER_ORDER_SZXY => Self::Szxy, ffi::GRAPHENE_EULER_ORDER_SZXZ => Self::Szxz, ffi::GRAPHENE_EULER_ORDER_SZYX => Self::Szyx, ffi::GRAPHENE_EULER_ORDER_SZYZ => Self::Szyz, ffi::GRAPHENE_EULER_ORDER_RZYX => Self::Rzyx, ffi::GRAPHENE_EULER_ORDER_RXYX => Self::Rxyx, ffi::GRAPHENE_EULER_ORDER_RYZX => Self::Ryzx, ffi::GRAPHENE_EULER_ORDER_RXZX => Self::Rxzx, ffi::GRAPHENE_EULER_ORDER_RXZY => Self::Rxzy, ffi::GRAPHENE_EULER_ORDER_RYZY => Self::Ryzy, ffi::GRAPHENE_EULER_ORDER_RZXY => Self::Rzxy, ffi::GRAPHENE_EULER_ORDER_RYXY => Self::Ryxy, ffi::GRAPHENE_EULER_ORDER_RYXZ => Self::Ryxz, ffi::GRAPHENE_EULER_ORDER_RZXZ => Self::Rzxz, ffi::GRAPHENE_EULER_ORDER_RXYZ => Self::Rxyz, ffi::GRAPHENE_EULER_ORDER_RZYZ => Self::Rzyz, value => Self::__Unknown(value), } } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "graphene_ray_intersection_kind_t")] pub enum RayIntersectionKind { #[doc(alias = "GRAPHENE_RAY_INTERSECTION_KIND_NONE")] None, #[doc(alias = "GRAPHENE_RAY_INTERSECTION_KIND_ENTER")] Enter, #[doc(alias = "GRAPHENE_RAY_INTERSECTION_KIND_LEAVE")] Leave, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for RayIntersectionKind { type GlibType = ffi::graphene_ray_intersection_kind_t; #[inline] fn into_glib(self) -> ffi::graphene_ray_intersection_kind_t { match self { Self::None => ffi::GRAPHENE_RAY_INTERSECTION_KIND_NONE, Self::Enter => ffi::GRAPHENE_RAY_INTERSECTION_KIND_ENTER, Self::Leave => ffi::GRAPHENE_RAY_INTERSECTION_KIND_LEAVE, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for RayIntersectionKind { #[inline] unsafe fn from_glib(value: ffi::graphene_ray_intersection_kind_t) -> Self { skip_assert_initialized!(); match value { ffi::GRAPHENE_RAY_INTERSECTION_KIND_NONE => Self::None, ffi::GRAPHENE_RAY_INTERSECTION_KIND_ENTER => Self::Enter, ffi::GRAPHENE_RAY_INTERSECTION_KIND_LEAVE => Self::Leave, value => Self::__Unknown(value), } } } graphene-rs-0.19.2/src/auto/euler.rs000064400000000000000000000066221046102023000153570ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{EulerOrder, Matrix, Quaternion, Vec3}; use glib::translate::*; glib::wrapper! { pub struct Euler(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_euler_get_type(), ptr as *mut _) as *mut ffi::graphene_euler_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_euler_get_type(), ptr as *mut _), type_ => || ffi::graphene_euler_get_type(), } } impl Euler { #[doc(alias = "graphene_euler_equal")] fn equal(&self, b: &Euler) -> bool { unsafe { ffi::graphene_euler_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_euler_get_alpha")] #[doc(alias = "get_alpha")] pub fn alpha(&self) -> f32 { unsafe { ffi::graphene_euler_get_alpha(self.to_glib_none().0) } } #[doc(alias = "graphene_euler_get_beta")] #[doc(alias = "get_beta")] pub fn beta(&self) -> f32 { unsafe { ffi::graphene_euler_get_beta(self.to_glib_none().0) } } #[doc(alias = "graphene_euler_get_gamma")] #[doc(alias = "get_gamma")] pub fn gamma(&self) -> f32 { unsafe { ffi::graphene_euler_get_gamma(self.to_glib_none().0) } } #[doc(alias = "graphene_euler_get_order")] #[doc(alias = "get_order")] pub fn order(&self) -> EulerOrder { unsafe { from_glib(ffi::graphene_euler_get_order(self.to_glib_none().0)) } } #[doc(alias = "graphene_euler_get_x")] #[doc(alias = "get_x")] pub fn x(&self) -> f32 { unsafe { ffi::graphene_euler_get_x(self.to_glib_none().0) } } #[doc(alias = "graphene_euler_get_y")] #[doc(alias = "get_y")] pub fn y(&self) -> f32 { unsafe { ffi::graphene_euler_get_y(self.to_glib_none().0) } } #[doc(alias = "graphene_euler_get_z")] #[doc(alias = "get_z")] pub fn z(&self) -> f32 { unsafe { ffi::graphene_euler_get_z(self.to_glib_none().0) } } #[doc(alias = "graphene_euler_reorder")] #[must_use] pub fn reorder(&self, order: EulerOrder) -> Euler { unsafe { let mut res = Euler::uninitialized(); ffi::graphene_euler_reorder( self.to_glib_none().0, order.into_glib(), res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_euler_to_matrix")] pub fn to_matrix(&self) -> Matrix { unsafe { let mut res = Matrix::uninitialized(); ffi::graphene_euler_to_matrix(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_euler_to_quaternion")] pub fn to_quaternion(&self) -> Quaternion { unsafe { let mut res = Quaternion::uninitialized(); ffi::graphene_euler_to_quaternion(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_euler_to_vec3")] pub fn to_vec3(&self) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_euler_to_vec3(self.to_glib_none().0, res.to_glib_none_mut().0); res } } } impl PartialEq for Euler { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Euler {} graphene-rs-0.19.2/src/auto/frustum.rs000064400000000000000000000032141046102023000157420ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Box, Point3D, Sphere}; use glib::translate::*; glib::wrapper! { pub struct Frustum(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_frustum_get_type(), ptr as *mut _) as *mut ffi::graphene_frustum_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_frustum_get_type(), ptr as *mut _), type_ => || ffi::graphene_frustum_get_type(), } } impl Frustum { #[doc(alias = "graphene_frustum_contains_point")] pub fn contains_point(&self, point: &Point3D) -> bool { unsafe { ffi::graphene_frustum_contains_point(self.to_glib_none().0, point.to_glib_none().0) } } #[doc(alias = "graphene_frustum_equal")] fn equal(&self, b: &Frustum) -> bool { unsafe { ffi::graphene_frustum_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_frustum_intersects_box")] pub fn intersects_box(&self, box_: &Box) -> bool { unsafe { ffi::graphene_frustum_intersects_box(self.to_glib_none().0, box_.to_glib_none().0) } } #[doc(alias = "graphene_frustum_intersects_sphere")] pub fn intersects_sphere(&self, sphere: &Sphere) -> bool { unsafe { ffi::graphene_frustum_intersects_sphere(self.to_glib_none().0, sphere.to_glib_none().0) } } } impl PartialEq for Frustum { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Frustum {} graphene-rs-0.19.2/src/auto/matrix.rs000064400000000000000000000412351046102023000155460ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Box, Euler, Point, Point3D, Quad, Quaternion, Ray, Rect, Sphere, Vec3, Vec4}; use glib::translate::*; glib::wrapper! { pub struct Matrix(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_matrix_get_type(), ptr as *mut _) as *mut ffi::graphene_matrix_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_matrix_get_type(), ptr as *mut _), type_ => || ffi::graphene_matrix_get_type(), } } impl Matrix { #[doc(alias = "graphene_matrix_decompose")] pub fn decompose(&self) -> Option<(Vec3, Vec3, Quaternion, Vec3, Vec4)> { unsafe { let mut translate = Vec3::uninitialized(); let mut scale = Vec3::uninitialized(); let mut rotate = Quaternion::uninitialized(); let mut shear = Vec3::uninitialized(); let mut perspective = Vec4::uninitialized(); let ret = ffi::graphene_matrix_decompose( self.to_glib_none().0, translate.to_glib_none_mut().0, scale.to_glib_none_mut().0, rotate.to_glib_none_mut().0, shear.to_glib_none_mut().0, perspective.to_glib_none_mut().0, ); if ret { Some((translate, scale, rotate, shear, perspective)) } else { None } } } #[doc(alias = "graphene_matrix_determinant")] pub fn determinant(&self) -> f32 { unsafe { ffi::graphene_matrix_determinant(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_equal")] fn equal(&self, b: &Matrix) -> bool { unsafe { ffi::graphene_matrix_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_matrix_equal_fast")] pub fn equal_fast(&self, b: &Matrix) -> bool { unsafe { ffi::graphene_matrix_equal_fast(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_matrix_get_row")] #[doc(alias = "get_row")] pub fn row(&self, index_: u32) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_matrix_get_row(self.to_glib_none().0, index_, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_matrix_get_value")] #[doc(alias = "get_value")] pub fn value(&self, row: u32, col: u32) -> f32 { unsafe { ffi::graphene_matrix_get_value(self.to_glib_none().0, row, col) } } #[doc(alias = "graphene_matrix_get_x_scale")] #[doc(alias = "get_x_scale")] pub fn x_scale(&self) -> f32 { unsafe { ffi::graphene_matrix_get_x_scale(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_get_x_translation")] #[doc(alias = "get_x_translation")] pub fn x_translation(&self) -> f32 { unsafe { ffi::graphene_matrix_get_x_translation(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_get_y_scale")] #[doc(alias = "get_y_scale")] pub fn y_scale(&self) -> f32 { unsafe { ffi::graphene_matrix_get_y_scale(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_get_y_translation")] #[doc(alias = "get_y_translation")] pub fn y_translation(&self) -> f32 { unsafe { ffi::graphene_matrix_get_y_translation(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_get_z_scale")] #[doc(alias = "get_z_scale")] pub fn z_scale(&self) -> f32 { unsafe { ffi::graphene_matrix_get_z_scale(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_get_z_translation")] #[doc(alias = "get_z_translation")] pub fn z_translation(&self) -> f32 { unsafe { ffi::graphene_matrix_get_z_translation(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_interpolate")] #[must_use] pub fn interpolate(&self, b: &Matrix, factor: f64) -> Matrix { unsafe { let mut res = Matrix::uninitialized(); ffi::graphene_matrix_interpolate( self.to_glib_none().0, b.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_inverse")] pub fn inverse(&self) -> Option { unsafe { let mut res = Matrix::uninitialized(); let ret = ffi::graphene_matrix_inverse(self.to_glib_none().0, res.to_glib_none_mut().0); if ret { Some(res) } else { None } } } #[doc(alias = "graphene_matrix_is_2d")] pub fn is_2d(&self) -> bool { unsafe { ffi::graphene_matrix_is_2d(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_is_backface_visible")] pub fn is_backface_visible(&self) -> bool { unsafe { ffi::graphene_matrix_is_backface_visible(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_is_identity")] pub fn is_identity(&self) -> bool { unsafe { ffi::graphene_matrix_is_identity(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_is_singular")] pub fn is_singular(&self) -> bool { unsafe { ffi::graphene_matrix_is_singular(self.to_glib_none().0) } } #[doc(alias = "graphene_matrix_multiply")] #[must_use] pub fn multiply(&self, b: &Matrix) -> Matrix { unsafe { let mut res = Matrix::uninitialized(); ffi::graphene_matrix_multiply( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_near")] pub fn near(&self, b: &Matrix, epsilon: f32) -> bool { unsafe { ffi::graphene_matrix_near(self.to_glib_none().0, b.to_glib_none().0, epsilon) } } #[doc(alias = "graphene_matrix_normalize")] #[must_use] pub fn normalize(&self) -> Matrix { unsafe { let mut res = Matrix::uninitialized(); ffi::graphene_matrix_normalize(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_matrix_perspective")] #[must_use] pub fn perspective(&self, depth: f32) -> Matrix { unsafe { let mut res = Matrix::uninitialized(); ffi::graphene_matrix_perspective( self.to_glib_none().0, depth, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_print")] pub fn print(&self) { unsafe { ffi::graphene_matrix_print(self.to_glib_none().0); } } #[doc(alias = "graphene_matrix_project_point")] pub fn project_point(&self, p: &Point) -> Point { unsafe { let mut res = Point::uninitialized(); ffi::graphene_matrix_project_point( self.to_glib_none().0, p.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_project_rect")] pub fn project_rect(&self, r: &Rect) -> Quad { unsafe { let mut res = Quad::uninitialized(); ffi::graphene_matrix_project_rect( self.to_glib_none().0, r.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_project_rect_bounds")] pub fn project_rect_bounds(&self, r: &Rect) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_matrix_project_rect_bounds( self.to_glib_none().0, r.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_rotate")] pub fn rotate(&mut self, angle: f32, axis: &Vec3) { unsafe { ffi::graphene_matrix_rotate(self.to_glib_none_mut().0, angle, axis.to_glib_none().0); } } #[doc(alias = "graphene_matrix_rotate_euler")] pub fn rotate_euler(&mut self, e: &Euler) { unsafe { ffi::graphene_matrix_rotate_euler(self.to_glib_none_mut().0, e.to_glib_none().0); } } #[doc(alias = "graphene_matrix_rotate_quaternion")] pub fn rotate_quaternion(&mut self, q: &Quaternion) { unsafe { ffi::graphene_matrix_rotate_quaternion(self.to_glib_none_mut().0, q.to_glib_none().0); } } #[doc(alias = "graphene_matrix_rotate_x")] pub fn rotate_x(&mut self, angle: f32) { unsafe { ffi::graphene_matrix_rotate_x(self.to_glib_none_mut().0, angle); } } #[doc(alias = "graphene_matrix_rotate_y")] pub fn rotate_y(&mut self, angle: f32) { unsafe { ffi::graphene_matrix_rotate_y(self.to_glib_none_mut().0, angle); } } #[doc(alias = "graphene_matrix_rotate_z")] pub fn rotate_z(&mut self, angle: f32) { unsafe { ffi::graphene_matrix_rotate_z(self.to_glib_none_mut().0, angle); } } #[doc(alias = "graphene_matrix_scale")] pub fn scale(&mut self, factor_x: f32, factor_y: f32, factor_z: f32) { unsafe { ffi::graphene_matrix_scale(self.to_glib_none_mut().0, factor_x, factor_y, factor_z); } } #[doc(alias = "graphene_matrix_skew_xy")] pub fn skew_xy(&mut self, factor: f32) { unsafe { ffi::graphene_matrix_skew_xy(self.to_glib_none_mut().0, factor); } } #[doc(alias = "graphene_matrix_skew_xz")] pub fn skew_xz(&mut self, factor: f32) { unsafe { ffi::graphene_matrix_skew_xz(self.to_glib_none_mut().0, factor); } } #[doc(alias = "graphene_matrix_skew_yz")] pub fn skew_yz(&mut self, factor: f32) { unsafe { ffi::graphene_matrix_skew_yz(self.to_glib_none_mut().0, factor); } } #[doc(alias = "graphene_matrix_to_2d")] pub fn to_2d(&self) -> Option<(f64, f64, f64, f64, f64, f64)> { unsafe { let mut xx = std::mem::MaybeUninit::uninit(); let mut yx = std::mem::MaybeUninit::uninit(); let mut xy = std::mem::MaybeUninit::uninit(); let mut yy = std::mem::MaybeUninit::uninit(); let mut x_0 = std::mem::MaybeUninit::uninit(); let mut y_0 = std::mem::MaybeUninit::uninit(); let ret = ffi::graphene_matrix_to_2d( self.to_glib_none().0, xx.as_mut_ptr(), yx.as_mut_ptr(), xy.as_mut_ptr(), yy.as_mut_ptr(), x_0.as_mut_ptr(), y_0.as_mut_ptr(), ); if ret { Some(( xx.assume_init(), yx.assume_init(), xy.assume_init(), yy.assume_init(), x_0.assume_init(), y_0.assume_init(), )) } else { None } } } #[doc(alias = "graphene_matrix_transform_bounds")] pub fn transform_bounds(&self, r: &Rect) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_matrix_transform_bounds( self.to_glib_none().0, r.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_transform_box")] pub fn transform_box(&self, b: &Box) -> Box { unsafe { let mut res = Box::uninitialized(); ffi::graphene_matrix_transform_box( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_transform_point")] pub fn transform_point(&self, p: &Point) -> Point { unsafe { let mut res = Point::uninitialized(); ffi::graphene_matrix_transform_point( self.to_glib_none().0, p.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_transform_point3d")] pub fn transform_point3d(&self, p: &Point3D) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_matrix_transform_point3d( self.to_glib_none().0, p.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_transform_ray")] pub fn transform_ray(&self, r: &Ray) -> Ray { unsafe { let mut res = Ray::uninitialized(); ffi::graphene_matrix_transform_ray( self.to_glib_none().0, r.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_transform_rect")] pub fn transform_rect(&self, r: &Rect) -> Quad { unsafe { let mut res = Quad::uninitialized(); ffi::graphene_matrix_transform_rect( self.to_glib_none().0, r.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_transform_sphere")] pub fn transform_sphere(&self, s: &Sphere) -> Sphere { unsafe { let mut res = Sphere::uninitialized(); ffi::graphene_matrix_transform_sphere( self.to_glib_none().0, s.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_transform_vec3")] pub fn transform_vec3(&self, v: &Vec3) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_matrix_transform_vec3( self.to_glib_none().0, v.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_transform_vec4")] pub fn transform_vec4(&self, v: &Vec4) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_matrix_transform_vec4( self.to_glib_none().0, v.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_translate")] pub fn translate(&mut self, pos: &Point3D) { unsafe { ffi::graphene_matrix_translate(self.to_glib_none_mut().0, pos.to_glib_none().0); } } #[doc(alias = "graphene_matrix_transpose")] #[must_use] pub fn transpose(&self) -> Matrix { unsafe { let mut res = Matrix::uninitialized(); ffi::graphene_matrix_transpose(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_matrix_unproject_point3d")] pub fn unproject_point3d(&self, modelview: &Matrix, point: &Point3D) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_matrix_unproject_point3d( self.to_glib_none().0, modelview.to_glib_none().0, point.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_untransform_bounds")] pub fn untransform_bounds(&self, r: &Rect, bounds: &Rect) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_matrix_untransform_bounds( self.to_glib_none().0, r.to_glib_none().0, bounds.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_matrix_untransform_point")] pub fn untransform_point(&self, p: &Point, bounds: &Rect) -> Option { unsafe { let mut res = Point::uninitialized(); let ret = ffi::graphene_matrix_untransform_point( self.to_glib_none().0, p.to_glib_none().0, bounds.to_glib_none().0, res.to_glib_none_mut().0, ); if ret { Some(res) } else { None } } } } impl PartialEq for Matrix { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Matrix {} graphene-rs-0.19.2/src/auto/mod.rs000064400000000000000000000016301046102023000150140ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT mod box_; pub use self::box_::Box; mod euler; pub use self::euler::Euler; mod frustum; pub use self::frustum::Frustum; mod matrix; pub use self::matrix::Matrix; mod plane; pub use self::plane::Plane; mod point; pub use self::point::Point; mod point3_d; pub use self::point3_d::Point3D; mod quad; pub use self::quad::Quad; mod quaternion; pub use self::quaternion::Quaternion; mod ray; pub use self::ray::Ray; mod rect; pub use self::rect::Rect; mod size; pub use self::size::Size; mod sphere; pub use self::sphere::Sphere; mod triangle; pub use self::triangle::Triangle; mod vec2; pub use self::vec2::Vec2; mod vec3; pub use self::vec3::Vec3; mod vec4; pub use self::vec4::Vec4; mod enums; pub use self::enums::EulerOrder; pub use self::enums::RayIntersectionKind; graphene-rs-0.19.2/src/auto/plane.rs000064400000000000000000000052101046102023000153320ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Matrix, Point3D, Vec3}; use glib::translate::*; glib::wrapper! { pub struct Plane(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_plane_get_type(), ptr as *mut _) as *mut ffi::graphene_plane_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_plane_get_type(), ptr as *mut _), type_ => || ffi::graphene_plane_get_type(), } } impl Plane { #[doc(alias = "graphene_plane_distance")] pub fn distance(&self, point: &Point3D) -> f32 { unsafe { ffi::graphene_plane_distance(self.to_glib_none().0, point.to_glib_none().0) } } #[doc(alias = "graphene_plane_equal")] fn equal(&self, b: &Plane) -> bool { unsafe { ffi::graphene_plane_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_plane_get_constant")] #[doc(alias = "get_constant")] pub fn constant(&self) -> f32 { unsafe { ffi::graphene_plane_get_constant(self.to_glib_none().0) } } #[doc(alias = "graphene_plane_get_normal")] #[doc(alias = "get_normal")] pub fn normal(&self) -> Vec3 { unsafe { let mut normal = Vec3::uninitialized(); ffi::graphene_plane_get_normal(self.to_glib_none().0, normal.to_glib_none_mut().0); normal } } #[doc(alias = "graphene_plane_negate")] #[must_use] pub fn negate(&self) -> Plane { unsafe { let mut res = Plane::uninitialized(); ffi::graphene_plane_negate(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_plane_normalize")] #[must_use] pub fn normalize(&self) -> Plane { unsafe { let mut res = Plane::uninitialized(); ffi::graphene_plane_normalize(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_plane_transform")] #[must_use] pub fn transform(&self, matrix: &Matrix, normal_matrix: Option<&Matrix>) -> Plane { unsafe { let mut res = Plane::uninitialized(); ffi::graphene_plane_transform( self.to_glib_none().0, matrix.to_glib_none().0, normal_matrix.to_glib_none().0, res.to_glib_none_mut().0, ); res } } } impl PartialEq for Plane { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Plane {} graphene-rs-0.19.2/src/auto/point.rs000064400000000000000000000047061046102023000153750ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::Vec2; use glib::translate::*; glib::wrapper! { pub struct Point(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_point_get_type(), ptr as *mut _) as *mut ffi::graphene_point_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_point_get_type(), ptr as *mut _), type_ => || ffi::graphene_point_get_type(), } } impl Point { #[doc(alias = "graphene_point_distance")] pub fn distance(&self, b: &Point) -> (f32, f32, f32) { unsafe { let mut d_x = std::mem::MaybeUninit::uninit(); let mut d_y = std::mem::MaybeUninit::uninit(); let ret = ffi::graphene_point_distance( self.to_glib_none().0, b.to_glib_none().0, d_x.as_mut_ptr(), d_y.as_mut_ptr(), ); (ret, d_x.assume_init(), d_y.assume_init()) } } #[doc(alias = "graphene_point_equal")] fn equal(&self, b: &Point) -> bool { unsafe { ffi::graphene_point_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_point_interpolate")] #[must_use] pub fn interpolate(&self, b: &Point, factor: f64) -> Point { unsafe { let mut res = Point::uninitialized(); ffi::graphene_point_interpolate( self.to_glib_none().0, b.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_point_near")] pub fn near(&self, b: &Point, epsilon: f32) -> bool { unsafe { ffi::graphene_point_near(self.to_glib_none().0, b.to_glib_none().0, epsilon) } } #[doc(alias = "graphene_point_to_vec2")] pub fn to_vec2(&self) -> Vec2 { unsafe { let mut v = Vec2::uninitialized(); ffi::graphene_point_to_vec2(self.to_glib_none().0, v.to_glib_none_mut().0); v } } #[doc(alias = "graphene_point_zero")] pub fn zero() -> Point { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_point_zero()) } } } impl PartialEq for Point { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Point {} graphene-rs-0.19.2/src/auto/point3_d.rs000064400000000000000000000102771046102023000157630ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Rect, Vec3}; use glib::translate::*; glib::wrapper! { pub struct Point3D(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_point3d_get_type(), ptr as *mut _) as *mut ffi::graphene_point3d_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_point3d_get_type(), ptr as *mut _), type_ => || ffi::graphene_point3d_get_type(), } } impl Point3D { #[doc(alias = "graphene_point3d_cross")] #[must_use] pub fn cross(&self, b: &Point3D) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_point3d_cross( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_point3d_distance")] pub fn distance(&self, b: &Point3D) -> (f32, Vec3) { unsafe { let mut delta = Vec3::uninitialized(); let ret = ffi::graphene_point3d_distance( self.to_glib_none().0, b.to_glib_none().0, delta.to_glib_none_mut().0, ); (ret, delta) } } #[doc(alias = "graphene_point3d_dot")] pub fn dot(&self, b: &Point3D) -> f32 { unsafe { ffi::graphene_point3d_dot(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_point3d_equal")] fn equal(&self, b: &Point3D) -> bool { unsafe { ffi::graphene_point3d_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_point3d_interpolate")] #[must_use] pub fn interpolate(&self, b: &Point3D, factor: f64) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_point3d_interpolate( self.to_glib_none().0, b.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_point3d_length")] pub fn length(&self) -> f32 { unsafe { ffi::graphene_point3d_length(self.to_glib_none().0) } } #[doc(alias = "graphene_point3d_near")] pub fn near(&self, b: &Point3D, epsilon: f32) -> bool { unsafe { ffi::graphene_point3d_near(self.to_glib_none().0, b.to_glib_none().0, epsilon) } } #[doc(alias = "graphene_point3d_normalize")] #[must_use] pub fn normalize(&self) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_point3d_normalize(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_point3d_normalize_viewport")] #[must_use] pub fn normalize_viewport(&self, viewport: &Rect, z_near: f32, z_far: f32) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_point3d_normalize_viewport( self.to_glib_none().0, viewport.to_glib_none().0, z_near, z_far, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_point3d_scale")] #[must_use] pub fn scale(&self, factor: f32) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_point3d_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_point3d_to_vec3")] pub fn to_vec3(&self) -> Vec3 { unsafe { let mut v = Vec3::uninitialized(); ffi::graphene_point3d_to_vec3(self.to_glib_none().0, v.to_glib_none_mut().0); v } } #[doc(alias = "graphene_point3d_zero")] pub fn zero() -> Point3D { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_point3d_zero()) } } } impl PartialEq for Point3D { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Point3D {} graphene-rs-0.19.2/src/auto/quad.rs000064400000000000000000000020071046102023000151660ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Point, Rect}; use glib::translate::*; glib::wrapper! { pub struct Quad(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_quad_get_type(), ptr as *mut _) as *mut ffi::graphene_quad_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_quad_get_type(), ptr as *mut _), type_ => || ffi::graphene_quad_get_type(), } } impl Quad { #[doc(alias = "graphene_quad_bounds")] pub fn bounds(&self) -> Rect { unsafe { let mut r = Rect::uninitialized(); ffi::graphene_quad_bounds(self.to_glib_none().0, r.to_glib_none_mut().0); r } } #[doc(alias = "graphene_quad_contains")] pub fn contains(&self, p: &Point) -> bool { unsafe { ffi::graphene_quad_contains(self.to_glib_none().0, p.to_glib_none().0) } } } graphene-rs-0.19.2/src/auto/quaternion.rs000064400000000000000000000131361046102023000164260ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Matrix, Vec3, Vec4}; use glib::translate::*; glib::wrapper! { pub struct Quaternion(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_quaternion_get_type(), ptr as *mut _) as *mut ffi::graphene_quaternion_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_quaternion_get_type(), ptr as *mut _), type_ => || ffi::graphene_quaternion_get_type(), } } impl Quaternion { #[doc(alias = "graphene_quaternion_add")] #[must_use] pub fn add(&self, b: &Quaternion) -> Quaternion { unsafe { let mut res = Quaternion::uninitialized(); ffi::graphene_quaternion_add( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_quaternion_dot")] pub fn dot(&self, b: &Quaternion) -> f32 { unsafe { ffi::graphene_quaternion_dot(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_quaternion_equal")] fn equal(&self, b: &Quaternion) -> bool { unsafe { ffi::graphene_quaternion_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_quaternion_invert")] #[must_use] pub fn invert(&self) -> Quaternion { unsafe { let mut res = Quaternion::uninitialized(); ffi::graphene_quaternion_invert(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_quaternion_multiply")] #[must_use] pub fn multiply(&self, b: &Quaternion) -> Quaternion { unsafe { let mut res = Quaternion::uninitialized(); ffi::graphene_quaternion_multiply( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_quaternion_normalize")] #[must_use] pub fn normalize(&self) -> Quaternion { unsafe { let mut res = Quaternion::uninitialized(); ffi::graphene_quaternion_normalize(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_quaternion_scale")] #[must_use] pub fn scale(&self, factor: f32) -> Quaternion { unsafe { let mut res = Quaternion::uninitialized(); ffi::graphene_quaternion_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_quaternion_slerp")] #[must_use] pub fn slerp(&self, b: &Quaternion, factor: f32) -> Quaternion { unsafe { let mut res = Quaternion::uninitialized(); ffi::graphene_quaternion_slerp( self.to_glib_none().0, b.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_quaternion_to_angle_vec3")] pub fn to_angle_vec3(&self) -> (f32, Vec3) { unsafe { let mut angle = std::mem::MaybeUninit::uninit(); let mut axis = Vec3::uninitialized(); ffi::graphene_quaternion_to_angle_vec3( self.to_glib_none().0, angle.as_mut_ptr(), axis.to_glib_none_mut().0, ); (angle.assume_init(), axis) } } #[doc(alias = "graphene_quaternion_to_angles")] pub fn to_angles(&self) -> (f32, f32, f32) { unsafe { let mut deg_x = std::mem::MaybeUninit::uninit(); let mut deg_y = std::mem::MaybeUninit::uninit(); let mut deg_z = std::mem::MaybeUninit::uninit(); ffi::graphene_quaternion_to_angles( self.to_glib_none().0, deg_x.as_mut_ptr(), deg_y.as_mut_ptr(), deg_z.as_mut_ptr(), ); ( deg_x.assume_init(), deg_y.assume_init(), deg_z.assume_init(), ) } } #[doc(alias = "graphene_quaternion_to_matrix")] pub fn to_matrix(&self) -> Matrix { unsafe { let mut m = Matrix::uninitialized(); ffi::graphene_quaternion_to_matrix(self.to_glib_none().0, m.to_glib_none_mut().0); m } } #[doc(alias = "graphene_quaternion_to_radians")] pub fn to_radians(&self) -> (f32, f32, f32) { unsafe { let mut rad_x = std::mem::MaybeUninit::uninit(); let mut rad_y = std::mem::MaybeUninit::uninit(); let mut rad_z = std::mem::MaybeUninit::uninit(); ffi::graphene_quaternion_to_radians( self.to_glib_none().0, rad_x.as_mut_ptr(), rad_y.as_mut_ptr(), rad_z.as_mut_ptr(), ); ( rad_x.assume_init(), rad_y.assume_init(), rad_z.assume_init(), ) } } #[doc(alias = "graphene_quaternion_to_vec4")] pub fn to_vec4(&self) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_quaternion_to_vec4(self.to_glib_none().0, res.to_glib_none_mut().0); res } } } impl PartialEq for Quaternion { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Quaternion {} graphene-rs-0.19.2/src/auto/ray.rs000064400000000000000000000117201046102023000150310ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Box, Plane, Point3D, RayIntersectionKind, Sphere, Triangle, Vec3}; use glib::translate::*; glib::wrapper! { pub struct Ray(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_ray_get_type(), ptr as *mut _) as *mut ffi::graphene_ray_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_ray_get_type(), ptr as *mut _), type_ => || ffi::graphene_ray_get_type(), } } impl Ray { #[doc(alias = "graphene_ray_equal")] fn equal(&self, b: &Ray) -> bool { unsafe { ffi::graphene_ray_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_ray_get_closest_point_to_point")] #[doc(alias = "get_closest_point_to_point")] pub fn closest_point_to_point(&self, p: &Point3D) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_ray_get_closest_point_to_point( self.to_glib_none().0, p.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_ray_get_direction")] #[doc(alias = "get_direction")] pub fn direction(&self) -> Vec3 { unsafe { let mut direction = Vec3::uninitialized(); ffi::graphene_ray_get_direction(self.to_glib_none().0, direction.to_glib_none_mut().0); direction } } #[doc(alias = "graphene_ray_get_distance_to_plane")] #[doc(alias = "get_distance_to_plane")] pub fn distance_to_plane(&self, p: &Plane) -> f32 { unsafe { ffi::graphene_ray_get_distance_to_plane(self.to_glib_none().0, p.to_glib_none().0) } } #[doc(alias = "graphene_ray_get_distance_to_point")] #[doc(alias = "get_distance_to_point")] pub fn distance_to_point(&self, p: &Point3D) -> f32 { unsafe { ffi::graphene_ray_get_distance_to_point(self.to_glib_none().0, p.to_glib_none().0) } } #[doc(alias = "graphene_ray_get_origin")] #[doc(alias = "get_origin")] pub fn origin(&self) -> Point3D { unsafe { let mut origin = Point3D::uninitialized(); ffi::graphene_ray_get_origin(self.to_glib_none().0, origin.to_glib_none_mut().0); origin } } #[doc(alias = "graphene_ray_get_position_at")] #[doc(alias = "get_position_at")] pub fn position_at(&self, t: f32) -> Point3D { unsafe { let mut position = Point3D::uninitialized(); ffi::graphene_ray_get_position_at( self.to_glib_none().0, t, position.to_glib_none_mut().0, ); position } } #[doc(alias = "graphene_ray_intersect_box")] pub fn intersect_box(&self, b: &Box) -> (RayIntersectionKind, f32) { unsafe { let mut t_out = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::graphene_ray_intersect_box( self.to_glib_none().0, b.to_glib_none().0, t_out.as_mut_ptr(), )); (ret, t_out.assume_init()) } } #[doc(alias = "graphene_ray_intersect_sphere")] pub fn intersect_sphere(&self, s: &Sphere) -> (RayIntersectionKind, f32) { unsafe { let mut t_out = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::graphene_ray_intersect_sphere( self.to_glib_none().0, s.to_glib_none().0, t_out.as_mut_ptr(), )); (ret, t_out.assume_init()) } } #[doc(alias = "graphene_ray_intersect_triangle")] pub fn intersect_triangle(&self, t: &Triangle) -> (RayIntersectionKind, f32) { unsafe { let mut t_out = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::graphene_ray_intersect_triangle( self.to_glib_none().0, t.to_glib_none().0, t_out.as_mut_ptr(), )); (ret, t_out.assume_init()) } } #[doc(alias = "graphene_ray_intersects_box")] pub fn intersects_box(&self, b: &Box) -> bool { unsafe { ffi::graphene_ray_intersects_box(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_ray_intersects_sphere")] pub fn intersects_sphere(&self, s: &Sphere) -> bool { unsafe { ffi::graphene_ray_intersects_sphere(self.to_glib_none().0, s.to_glib_none().0) } } #[doc(alias = "graphene_ray_intersects_triangle")] pub fn intersects_triangle(&self, t: &Triangle) -> bool { unsafe { ffi::graphene_ray_intersects_triangle(self.to_glib_none().0, t.to_glib_none().0) } } } impl PartialEq for Ray { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Ray {} graphene-rs-0.19.2/src/auto/rect.rs000064400000000000000000000171001046102023000151710ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::Point; use glib::translate::*; glib::wrapper! { pub struct Rect(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_rect_get_type(), ptr as *mut _) as *mut ffi::graphene_rect_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_rect_get_type(), ptr as *mut _), type_ => || ffi::graphene_rect_get_type(), } } impl Rect { #[doc(alias = "graphene_rect_contains_point")] pub fn contains_point(&self, p: &Point) -> bool { unsafe { ffi::graphene_rect_contains_point(self.to_glib_none().0, p.to_glib_none().0) } } #[doc(alias = "graphene_rect_contains_rect")] pub fn contains_rect(&self, b: &Rect) -> bool { unsafe { ffi::graphene_rect_contains_rect(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_rect_equal")] fn equal(&self, b: &Rect) -> bool { unsafe { ffi::graphene_rect_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_rect_expand")] #[must_use] pub fn expand(&self, p: &Point) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_rect_expand( self.to_glib_none().0, p.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_rect_get_area")] #[doc(alias = "get_area")] pub fn area(&self) -> f32 { unsafe { ffi::graphene_rect_get_area(self.to_glib_none().0) } } #[doc(alias = "graphene_rect_get_bottom_left")] #[doc(alias = "get_bottom_left")] pub fn bottom_left(&self) -> Point { unsafe { let mut p = Point::uninitialized(); ffi::graphene_rect_get_bottom_left(self.to_glib_none().0, p.to_glib_none_mut().0); p } } #[doc(alias = "graphene_rect_get_bottom_right")] #[doc(alias = "get_bottom_right")] pub fn bottom_right(&self) -> Point { unsafe { let mut p = Point::uninitialized(); ffi::graphene_rect_get_bottom_right(self.to_glib_none().0, p.to_glib_none_mut().0); p } } #[doc(alias = "graphene_rect_get_center")] #[doc(alias = "get_center")] pub fn center(&self) -> Point { unsafe { let mut p = Point::uninitialized(); ffi::graphene_rect_get_center(self.to_glib_none().0, p.to_glib_none_mut().0); p } } #[doc(alias = "graphene_rect_get_height")] #[doc(alias = "get_height")] pub fn height(&self) -> f32 { unsafe { ffi::graphene_rect_get_height(self.to_glib_none().0) } } #[doc(alias = "graphene_rect_get_top_left")] #[doc(alias = "get_top_left")] pub fn top_left(&self) -> Point { unsafe { let mut p = Point::uninitialized(); ffi::graphene_rect_get_top_left(self.to_glib_none().0, p.to_glib_none_mut().0); p } } #[doc(alias = "graphene_rect_get_top_right")] #[doc(alias = "get_top_right")] pub fn top_right(&self) -> Point { unsafe { let mut p = Point::uninitialized(); ffi::graphene_rect_get_top_right(self.to_glib_none().0, p.to_glib_none_mut().0); p } } #[doc(alias = "graphene_rect_get_width")] #[doc(alias = "get_width")] pub fn width(&self) -> f32 { unsafe { ffi::graphene_rect_get_width(self.to_glib_none().0) } } #[doc(alias = "graphene_rect_get_x")] #[doc(alias = "get_x")] pub fn x(&self) -> f32 { unsafe { ffi::graphene_rect_get_x(self.to_glib_none().0) } } #[doc(alias = "graphene_rect_get_y")] #[doc(alias = "get_y")] pub fn y(&self) -> f32 { unsafe { ffi::graphene_rect_get_y(self.to_glib_none().0) } } #[doc(alias = "graphene_rect_inset")] pub fn inset(&mut self, d_x: f32, d_y: f32) { unsafe { ffi::graphene_rect_inset(self.to_glib_none_mut().0, d_x, d_y); } } #[doc(alias = "graphene_rect_inset_r")] #[must_use] pub fn inset_r(&self, d_x: f32, d_y: f32) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_rect_inset_r(self.to_glib_none().0, d_x, d_y, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_rect_interpolate")] #[must_use] pub fn interpolate(&self, b: &Rect, factor: f64) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_rect_interpolate( self.to_glib_none().0, b.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_rect_intersection")] pub fn intersection(&self, b: &Rect) -> Option { unsafe { let mut res = Rect::uninitialized(); let ret = ffi::graphene_rect_intersection( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); if ret { Some(res) } else { None } } } #[doc(alias = "graphene_rect_normalize")] pub fn normalize(&mut self) { unsafe { ffi::graphene_rect_normalize(self.to_glib_none_mut().0); } } #[doc(alias = "graphene_rect_normalize_r")] #[must_use] pub fn normalize_r(&self) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_rect_normalize_r(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_rect_offset")] pub fn offset(&mut self, d_x: f32, d_y: f32) { unsafe { ffi::graphene_rect_offset(self.to_glib_none_mut().0, d_x, d_y); } } #[doc(alias = "graphene_rect_offset_r")] #[must_use] pub fn offset_r(&self, d_x: f32, d_y: f32) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_rect_offset_r(self.to_glib_none().0, d_x, d_y, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_rect_round_extents")] #[must_use] pub fn round_extents(&self) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_rect_round_extents(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_rect_scale")] #[must_use] pub fn scale(&self, s_h: f32, s_v: f32) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_rect_scale(self.to_glib_none().0, s_h, s_v, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_rect_union")] #[must_use] pub fn union(&self, b: &Rect) -> Rect { unsafe { let mut res = Rect::uninitialized(); ffi::graphene_rect_union( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_rect_zero")] pub fn zero() -> Rect { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_rect_zero()) } } } impl PartialEq for Rect { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Rect {} graphene-rs-0.19.2/src/auto/size.rs000064400000000000000000000033561046102023000152160ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::translate::*; glib::wrapper! { pub struct Size(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_size_get_type(), ptr as *mut _) as *mut ffi::graphene_size_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_size_get_type(), ptr as *mut _), type_ => || ffi::graphene_size_get_type(), } } impl Size { #[doc(alias = "graphene_size_equal")] fn equal(&self, b: &Size) -> bool { unsafe { ffi::graphene_size_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_size_interpolate")] #[must_use] pub fn interpolate(&self, b: &Size, factor: f64) -> Size { unsafe { let mut res = Size::uninitialized(); ffi::graphene_size_interpolate( self.to_glib_none().0, b.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_size_scale")] #[must_use] pub fn scale(&self, factor: f32) -> Size { unsafe { let mut res = Size::uninitialized(); ffi::graphene_size_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_size_zero")] pub fn zero() -> Size { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_size_zero()) } } } impl PartialEq for Size { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Size {} graphene-rs-0.19.2/src/auto/sphere.rs000064400000000000000000000053431046102023000155300ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Box, Point3D}; use glib::translate::*; glib::wrapper! { pub struct Sphere(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_sphere_get_type(), ptr as *mut _) as *mut ffi::graphene_sphere_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_sphere_get_type(), ptr as *mut _), type_ => || ffi::graphene_sphere_get_type(), } } impl Sphere { #[doc(alias = "graphene_sphere_contains_point")] pub fn contains_point(&self, point: &Point3D) -> bool { unsafe { ffi::graphene_sphere_contains_point(self.to_glib_none().0, point.to_glib_none().0) } } #[doc(alias = "graphene_sphere_distance")] pub fn distance(&self, point: &Point3D) -> f32 { unsafe { ffi::graphene_sphere_distance(self.to_glib_none().0, point.to_glib_none().0) } } #[doc(alias = "graphene_sphere_equal")] fn equal(&self, b: &Sphere) -> bool { unsafe { ffi::graphene_sphere_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_sphere_get_bounding_box")] #[doc(alias = "get_bounding_box")] pub fn bounding_box(&self) -> Box { unsafe { let mut box_ = Box::uninitialized(); ffi::graphene_sphere_get_bounding_box(self.to_glib_none().0, box_.to_glib_none_mut().0); box_ } } #[doc(alias = "graphene_sphere_get_center")] #[doc(alias = "get_center")] pub fn center(&self) -> Point3D { unsafe { let mut center = Point3D::uninitialized(); ffi::graphene_sphere_get_center(self.to_glib_none().0, center.to_glib_none_mut().0); center } } #[doc(alias = "graphene_sphere_get_radius")] #[doc(alias = "get_radius")] pub fn radius(&self) -> f32 { unsafe { ffi::graphene_sphere_get_radius(self.to_glib_none().0) } } #[doc(alias = "graphene_sphere_is_empty")] pub fn is_empty(&self) -> bool { unsafe { ffi::graphene_sphere_is_empty(self.to_glib_none().0) } } #[doc(alias = "graphene_sphere_translate")] #[must_use] pub fn translate(&self, point: &Point3D) -> Sphere { unsafe { let mut res = Sphere::uninitialized(); ffi::graphene_sphere_translate( self.to_glib_none().0, point.to_glib_none().0, res.to_glib_none_mut().0, ); res } } } impl PartialEq for Sphere { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Sphere {} graphene-rs-0.19.2/src/auto/triangle.rs000064400000000000000000000116611046102023000160470ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Box, Plane, Point3D, Vec2, Vec3}; use glib::translate::*; glib::wrapper! { pub struct Triangle(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_triangle_get_type(), ptr as *mut _) as *mut ffi::graphene_triangle_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_triangle_get_type(), ptr as *mut _), type_ => || ffi::graphene_triangle_get_type(), } } impl Triangle { #[doc(alias = "graphene_triangle_contains_point")] pub fn contains_point(&self, p: &Point3D) -> bool { unsafe { ffi::graphene_triangle_contains_point(self.to_glib_none().0, p.to_glib_none().0) } } #[doc(alias = "graphene_triangle_equal")] fn equal(&self, b: &Triangle) -> bool { unsafe { ffi::graphene_triangle_equal(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_triangle_get_area")] #[doc(alias = "get_area")] pub fn area(&self) -> f32 { unsafe { ffi::graphene_triangle_get_area(self.to_glib_none().0) } } #[doc(alias = "graphene_triangle_get_barycoords")] #[doc(alias = "get_barycoords")] pub fn barycoords(&self, p: Option<&Point3D>) -> Option { unsafe { let mut res = Vec2::uninitialized(); let ret = ffi::graphene_triangle_get_barycoords( self.to_glib_none().0, p.to_glib_none().0, res.to_glib_none_mut().0, ); if ret { Some(res) } else { None } } } #[doc(alias = "graphene_triangle_get_bounding_box")] #[doc(alias = "get_bounding_box")] pub fn bounding_box(&self) -> Box { unsafe { let mut res = Box::uninitialized(); ffi::graphene_triangle_get_bounding_box( self.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_triangle_get_midpoint")] #[doc(alias = "get_midpoint")] pub fn midpoint(&self) -> Point3D { unsafe { let mut res = Point3D::uninitialized(); ffi::graphene_triangle_get_midpoint(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_triangle_get_normal")] #[doc(alias = "get_normal")] pub fn normal(&self) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_triangle_get_normal(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_triangle_get_plane")] #[doc(alias = "get_plane")] pub fn plane(&self) -> Plane { unsafe { let mut res = Plane::uninitialized(); ffi::graphene_triangle_get_plane(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_triangle_get_points")] #[doc(alias = "get_points")] pub fn points(&self) -> (Point3D, Point3D, Point3D) { unsafe { let mut a = Point3D::uninitialized(); let mut b = Point3D::uninitialized(); let mut c = Point3D::uninitialized(); ffi::graphene_triangle_get_points( self.to_glib_none().0, a.to_glib_none_mut().0, b.to_glib_none_mut().0, c.to_glib_none_mut().0, ); (a, b, c) } } #[doc(alias = "graphene_triangle_get_uv")] #[doc(alias = "get_uv")] pub fn uv(&self, p: Option<&Point3D>, uv_a: &Vec2, uv_b: &Vec2, uv_c: &Vec2) -> Option { unsafe { let mut res = Vec2::uninitialized(); let ret = ffi::graphene_triangle_get_uv( self.to_glib_none().0, p.to_glib_none().0, uv_a.to_glib_none().0, uv_b.to_glib_none().0, uv_c.to_glib_none().0, res.to_glib_none_mut().0, ); if ret { Some(res) } else { None } } } #[doc(alias = "graphene_triangle_get_vertices")] #[doc(alias = "get_vertices")] pub fn vertices(&self) -> (Vec3, Vec3, Vec3) { unsafe { let mut a = Vec3::uninitialized(); let mut b = Vec3::uninitialized(); let mut c = Vec3::uninitialized(); ffi::graphene_triangle_get_vertices( self.to_glib_none().0, a.to_glib_none_mut().0, b.to_glib_none_mut().0, c.to_glib_none_mut().0, ); (a, b, c) } } } impl PartialEq for Triangle { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Triangle {} graphene-rs-0.19.2/src/auto/vec2.rs000064400000000000000000000135601046102023000151010ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::translate::*; glib::wrapper! { pub struct Vec2(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_vec2_get_type(), ptr as *mut _) as *mut ffi::graphene_vec2_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_vec2_get_type(), ptr as *mut _), type_ => || ffi::graphene_vec2_get_type(), } } impl Vec2 { #[doc(alias = "graphene_vec2_add")] #[must_use] pub fn add(&self, b: &Vec2) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_add( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec2_divide")] #[must_use] pub fn divide(&self, b: &Vec2) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_divide( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec2_dot")] pub fn dot(&self, b: &Vec2) -> f32 { unsafe { ffi::graphene_vec2_dot(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_vec2_equal")] fn equal(&self, v2: &Vec2) -> bool { unsafe { ffi::graphene_vec2_equal(self.to_glib_none().0, v2.to_glib_none().0) } } #[doc(alias = "graphene_vec2_get_x")] #[doc(alias = "get_x")] pub fn x(&self) -> f32 { unsafe { ffi::graphene_vec2_get_x(self.to_glib_none().0) } } #[doc(alias = "graphene_vec2_get_y")] #[doc(alias = "get_y")] pub fn y(&self) -> f32 { unsafe { ffi::graphene_vec2_get_y(self.to_glib_none().0) } } #[doc(alias = "graphene_vec2_interpolate")] #[must_use] pub fn interpolate(&self, v2: &Vec2, factor: f64) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_interpolate( self.to_glib_none().0, v2.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec2_length")] pub fn length(&self) -> f32 { unsafe { ffi::graphene_vec2_length(self.to_glib_none().0) } } #[doc(alias = "graphene_vec2_max")] #[must_use] pub fn max(&self, b: &Vec2) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_max( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec2_min")] #[must_use] pub fn min(&self, b: &Vec2) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_min( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec2_multiply")] #[must_use] pub fn multiply(&self, b: &Vec2) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_multiply( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec2_near")] pub fn near(&self, v2: &Vec2, epsilon: f32) -> bool { unsafe { ffi::graphene_vec2_near(self.to_glib_none().0, v2.to_glib_none().0, epsilon) } } #[doc(alias = "graphene_vec2_negate")] #[must_use] pub fn negate(&self) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_negate(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec2_normalize")] #[must_use] pub fn normalize(&self) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_normalize(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec2_scale")] #[must_use] pub fn scale(&self, factor: f32) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec2_subtract")] #[must_use] pub fn subtract(&self, b: &Vec2) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec2_subtract( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec2_one")] pub fn one() -> Vec2 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec2_one()) } } #[doc(alias = "graphene_vec2_x_axis")] pub fn x_axis() -> Vec2 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec2_x_axis()) } } #[doc(alias = "graphene_vec2_y_axis")] pub fn y_axis() -> Vec2 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec2_y_axis()) } } #[doc(alias = "graphene_vec2_zero")] pub fn zero() -> Vec2 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec2_zero()) } } } impl PartialEq for Vec2 { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Vec2 {} graphene-rs-0.19.2/src/auto/vec3.rs000064400000000000000000000201041046102023000150720ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Vec2, Vec4}; use glib::translate::*; glib::wrapper! { pub struct Vec3(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_vec3_get_type(), ptr as *mut _) as *mut ffi::graphene_vec3_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_vec3_get_type(), ptr as *mut _), type_ => || ffi::graphene_vec3_get_type(), } } impl Vec3 { #[doc(alias = "graphene_vec3_add")] #[must_use] pub fn add(&self, b: &Vec3) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_add( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec3_cross")] #[must_use] pub fn cross(&self, b: &Vec3) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_cross( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec3_divide")] #[must_use] pub fn divide(&self, b: &Vec3) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_divide( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec3_dot")] pub fn dot(&self, b: &Vec3) -> f32 { unsafe { ffi::graphene_vec3_dot(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_vec3_equal")] fn equal(&self, v2: &Vec3) -> bool { unsafe { ffi::graphene_vec3_equal(self.to_glib_none().0, v2.to_glib_none().0) } } #[doc(alias = "graphene_vec3_get_x")] #[doc(alias = "get_x")] pub fn x(&self) -> f32 { unsafe { ffi::graphene_vec3_get_x(self.to_glib_none().0) } } #[doc(alias = "graphene_vec3_get_xy")] #[doc(alias = "get_xy")] pub fn xy(&self) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec3_get_xy(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec3_get_xy0")] #[doc(alias = "get_xy0")] #[must_use] pub fn xy0(&self) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_get_xy0(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec3_get_xyz0")] #[doc(alias = "get_xyz0")] pub fn xyz0(&self) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec3_get_xyz0(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec3_get_xyz1")] #[doc(alias = "get_xyz1")] pub fn xyz1(&self) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec3_get_xyz1(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec3_get_xyzw")] #[doc(alias = "get_xyzw")] pub fn xyzw(&self, w: f32) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec3_get_xyzw(self.to_glib_none().0, w, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec3_get_y")] #[doc(alias = "get_y")] pub fn y(&self) -> f32 { unsafe { ffi::graphene_vec3_get_y(self.to_glib_none().0) } } #[doc(alias = "graphene_vec3_get_z")] #[doc(alias = "get_z")] pub fn z(&self) -> f32 { unsafe { ffi::graphene_vec3_get_z(self.to_glib_none().0) } } #[doc(alias = "graphene_vec3_interpolate")] #[must_use] pub fn interpolate(&self, v2: &Vec3, factor: f64) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_interpolate( self.to_glib_none().0, v2.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec3_length")] pub fn length(&self) -> f32 { unsafe { ffi::graphene_vec3_length(self.to_glib_none().0) } } #[doc(alias = "graphene_vec3_max")] #[must_use] pub fn max(&self, b: &Vec3) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_max( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec3_min")] #[must_use] pub fn min(&self, b: &Vec3) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_min( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec3_multiply")] #[must_use] pub fn multiply(&self, b: &Vec3) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_multiply( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec3_near")] pub fn near(&self, v2: &Vec3, epsilon: f32) -> bool { unsafe { ffi::graphene_vec3_near(self.to_glib_none().0, v2.to_glib_none().0, epsilon) } } #[doc(alias = "graphene_vec3_negate")] #[must_use] pub fn negate(&self) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_negate(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec3_normalize")] #[must_use] pub fn normalize(&self) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_normalize(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec3_scale")] #[must_use] pub fn scale(&self, factor: f32) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec3_subtract")] #[must_use] pub fn subtract(&self, b: &Vec3) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec3_subtract( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec3_one")] pub fn one() -> Vec3 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec3_one()) } } #[doc(alias = "graphene_vec3_x_axis")] pub fn x_axis() -> Vec3 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec3_x_axis()) } } #[doc(alias = "graphene_vec3_y_axis")] pub fn y_axis() -> Vec3 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec3_y_axis()) } } #[doc(alias = "graphene_vec3_z_axis")] pub fn z_axis() -> Vec3 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec3_z_axis()) } } #[doc(alias = "graphene_vec3_zero")] pub fn zero() -> Vec3 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec3_zero()) } } } impl PartialEq for Vec3 { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Vec3 {} graphene-rs-0.19.2/src/auto/vec4.rs000064400000000000000000000162371046102023000151070ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{Vec2, Vec3}; use glib::translate::*; glib::wrapper! { pub struct Vec4(BoxedInline); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_vec4_get_type(), ptr as *mut _) as *mut ffi::graphene_vec4_t, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_vec4_get_type(), ptr as *mut _), type_ => || ffi::graphene_vec4_get_type(), } } impl Vec4 { #[doc(alias = "graphene_vec4_add")] #[must_use] pub fn add(&self, b: &Vec4) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_add( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec4_divide")] #[must_use] pub fn divide(&self, b: &Vec4) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_divide( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec4_dot")] pub fn dot(&self, b: &Vec4) -> f32 { unsafe { ffi::graphene_vec4_dot(self.to_glib_none().0, b.to_glib_none().0) } } #[doc(alias = "graphene_vec4_equal")] fn equal(&self, v2: &Vec4) -> bool { unsafe { ffi::graphene_vec4_equal(self.to_glib_none().0, v2.to_glib_none().0) } } #[doc(alias = "graphene_vec4_get_w")] #[doc(alias = "get_w")] pub fn w(&self) -> f32 { unsafe { ffi::graphene_vec4_get_w(self.to_glib_none().0) } } #[doc(alias = "graphene_vec4_get_x")] #[doc(alias = "get_x")] pub fn x(&self) -> f32 { unsafe { ffi::graphene_vec4_get_x(self.to_glib_none().0) } } #[doc(alias = "graphene_vec4_get_xy")] #[doc(alias = "get_xy")] pub fn xy(&self) -> Vec2 { unsafe { let mut res = Vec2::uninitialized(); ffi::graphene_vec4_get_xy(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec4_get_xyz")] #[doc(alias = "get_xyz")] pub fn xyz(&self) -> Vec3 { unsafe { let mut res = Vec3::uninitialized(); ffi::graphene_vec4_get_xyz(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec4_get_y")] #[doc(alias = "get_y")] pub fn y(&self) -> f32 { unsafe { ffi::graphene_vec4_get_y(self.to_glib_none().0) } } #[doc(alias = "graphene_vec4_get_z")] #[doc(alias = "get_z")] pub fn z(&self) -> f32 { unsafe { ffi::graphene_vec4_get_z(self.to_glib_none().0) } } #[doc(alias = "graphene_vec4_interpolate")] #[must_use] pub fn interpolate(&self, v2: &Vec4, factor: f64) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_interpolate( self.to_glib_none().0, v2.to_glib_none().0, factor, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec4_length")] pub fn length(&self) -> f32 { unsafe { ffi::graphene_vec4_length(self.to_glib_none().0) } } #[doc(alias = "graphene_vec4_max")] #[must_use] pub fn max(&self, b: &Vec4) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_max( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec4_min")] #[must_use] pub fn min(&self, b: &Vec4) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_min( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec4_multiply")] #[must_use] pub fn multiply(&self, b: &Vec4) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_multiply( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec4_near")] pub fn near(&self, v2: &Vec4, epsilon: f32) -> bool { unsafe { ffi::graphene_vec4_near(self.to_glib_none().0, v2.to_glib_none().0, epsilon) } } #[doc(alias = "graphene_vec4_negate")] #[must_use] pub fn negate(&self) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_negate(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec4_normalize")] #[must_use] pub fn normalize(&self) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_normalize(self.to_glib_none().0, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec4_scale")] #[must_use] pub fn scale(&self, factor: f32) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0); res } } #[doc(alias = "graphene_vec4_subtract")] #[must_use] pub fn subtract(&self, b: &Vec4) -> Vec4 { unsafe { let mut res = Vec4::uninitialized(); ffi::graphene_vec4_subtract( self.to_glib_none().0, b.to_glib_none().0, res.to_glib_none_mut().0, ); res } } #[doc(alias = "graphene_vec4_one")] pub fn one() -> Vec4 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec4_one()) } } #[doc(alias = "graphene_vec4_w_axis")] pub fn w_axis() -> Vec4 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec4_w_axis()) } } #[doc(alias = "graphene_vec4_x_axis")] pub fn x_axis() -> Vec4 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec4_x_axis()) } } #[doc(alias = "graphene_vec4_y_axis")] pub fn y_axis() -> Vec4 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec4_y_axis()) } } #[doc(alias = "graphene_vec4_z_axis")] pub fn z_axis() -> Vec4 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec4_z_axis()) } } #[doc(alias = "graphene_vec4_zero")] pub fn zero() -> Vec4 { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::graphene_vec4_zero()) } } } impl PartialEq for Vec4 { #[inline] fn eq(&self, other: &Self) -> bool { self.equal(other) } } impl Eq for Vec4 {} graphene-rs-0.19.2/src/auto/versions.txt000064400000000000000000000002041046102023000162740ustar 00000000000000Generated by gir (https://github.com/gtk-rs/gir @ 9ebc44374393) from gir-files (https://github.com/gtk-rs/gir-files @ 4d83970797d4) graphene-rs-0.19.2/src/box_.rs000064400000000000000000000051561046102023000142230ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Box, Point3D, Vec3}; impl Box { #[doc(alias = "graphene_box_get_vertices")] #[doc(alias = "get_vertices")] pub fn vertices(&self) -> &[Vec3; 8] { unsafe { let mut out: [ffi::graphene_vec3_t; 8] = std::mem::zeroed(); ffi::graphene_box_get_vertices(self.to_glib_none().0, &mut out as *mut _); &*(&out as *const [ffi::graphene_vec3_t; 8] as *const [Vec3; 8]) } } #[doc(alias = "graphene_box_init")] pub fn new(min: Option<&Point3D>, max: Option<&Point3D>) -> Self { assert_initialized_main_thread!(); unsafe { let mut b = Self::uninitialized(); ffi::graphene_box_init( b.to_glib_none_mut().0, min.to_glib_none().0, max.to_glib_none().0, ); b } } #[doc(alias = "graphene_box_init_from_points")] #[doc(alias = "init_from_points")] pub fn from_points(points: &[Point3D]) -> Self { assert_initialized_main_thread!(); let n = points.len() as u32; unsafe { let mut b = Self::uninitialized(); ffi::graphene_box_init_from_points(b.to_glib_none_mut().0, n, points.to_glib_none().0); b } } #[doc(alias = "graphene_box_init_from_vec3")] #[doc(alias = "init_from_vec3")] pub fn from_vec3(min: Option<&Vec3>, max: Option<&Vec3>) -> Self { assert_initialized_main_thread!(); unsafe { let mut b = Self::uninitialized(); ffi::graphene_box_init_from_vec3( b.to_glib_none_mut().0, min.to_glib_none().0, max.to_glib_none().0, ); b } } #[doc(alias = "graphene_box_init_from_vectors")] #[doc(alias = "init_from_vectors")] pub fn from_vectors(vectors: &[Vec3]) -> Self { assert_initialized_main_thread!(); let n = vectors.len() as u32; unsafe { let mut b = Self::uninitialized(); ffi::graphene_box_init_from_vectors( b.to_glib_none_mut().0, n, vectors.to_glib_none().0, ); b } } } impl Default for Box { fn default() -> Self { Self::zero() } } impl fmt::Debug for Box { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Box") .field("min", &self.min()) .field("max", &self.max()) .finish() } } graphene-rs-0.19.2/src/euler.rs000064400000000000000000000063021046102023000144020ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Euler, EulerOrder, Matrix, Quaternion, Vec3}; impl Euler { #[doc(alias = "graphene_euler_init")] pub fn new(x: f32, y: f32, z: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut eul = Self::uninitialized(); ffi::graphene_euler_init(eul.to_glib_none_mut().0, x, y, z); eul } } #[doc(alias = "graphene_euler_init_from_matrix")] #[doc(alias = "init_from_matrix")] pub fn from_matrix(m: Option<&Matrix>, order: EulerOrder) -> Self { assert_initialized_main_thread!(); unsafe { let mut eul = Self::uninitialized(); ffi::graphene_euler_init_from_matrix( eul.to_glib_none_mut().0, m.to_glib_none().0, order.into_glib(), ); eul } } #[doc(alias = "graphene_euler_init_from_quaternion")] #[doc(alias = "init_from_quaternion")] pub fn from_quaternion(q: Option<&Quaternion>, order: EulerOrder) -> Self { assert_initialized_main_thread!(); unsafe { let mut eul = Self::uninitialized(); ffi::graphene_euler_init_from_quaternion( eul.to_glib_none_mut().0, q.to_glib_none().0, order.into_glib(), ); eul } } #[doc(alias = "graphene_euler_init_from_radians")] #[doc(alias = "init_from_radians")] pub fn from_radians(x: f32, y: f32, z: f32, order: EulerOrder) -> Self { unsafe { let mut eul = Self::uninitialized(); ffi::graphene_euler_init_from_radians( eul.to_glib_none_mut().0, x, y, z, order.into_glib(), ); eul } } #[doc(alias = "graphene_euler_init_from_vec3")] #[doc(alias = "init_from_vec3")] pub fn from_vec3(v: Option<&Vec3>, order: EulerOrder) -> Self { assert_initialized_main_thread!(); unsafe { let mut eul = Self::uninitialized(); ffi::graphene_euler_init_from_vec3( eul.to_glib_none_mut().0, v.to_glib_none().0, order.into_glib(), ); eul } } #[doc(alias = "graphene_euler_init_with_order")] #[doc(alias = "init_with_order")] pub fn with_order(x: f32, y: f32, z: f32, order: EulerOrder) -> Self { assert_initialized_main_thread!(); unsafe { let mut eul = Self::uninitialized(); ffi::graphene_euler_init_with_order( eul.to_glib_none_mut().0, x, y, z, order.into_glib(), ); eul } } } impl fmt::Debug for Euler { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Euler") .field("order", &self.order()) .field("alpha", &self.alpha()) .field("beta", &self.beta()) .field("gamma", &self.gamma()) .finish() } } graphene-rs-0.19.2/src/frustum.rs000064400000000000000000000034321046102023000147740ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Frustum, Matrix, Plane}; impl Frustum { #[doc(alias = "graphene_frustum_get_planes")] #[doc(alias = "get_planes")] pub fn planes(&self) -> &[Plane; 6] { unsafe { let mut out: [ffi::graphene_plane_t; 6] = std::mem::zeroed(); ffi::graphene_frustum_get_planes(self.to_glib_none().0, &mut out as *mut _); &*(&out as *const [ffi::graphene_plane_t; 6] as *const [Plane; 6]) } } #[doc(alias = "graphene_frustum_init")] pub fn new(p0: &Plane, p1: &Plane, p2: &Plane, p3: &Plane, p4: &Plane, p5: &Plane) -> Self { assert_initialized_main_thread!(); unsafe { let mut fru = Self::uninitialized(); ffi::graphene_frustum_init( fru.to_glib_none_mut().0, p0.to_glib_none().0, p1.to_glib_none().0, p2.to_glib_none().0, p3.to_glib_none().0, p4.to_glib_none().0, p5.to_glib_none().0, ); fru } } #[doc(alias = "graphene_frustum_init_from_matrix")] #[doc(alias = "init_from_matrix")] pub fn from_matrix(matrix: &Matrix) -> Self { assert_initialized_main_thread!(); unsafe { let mut fru = Self::uninitialized(); ffi::graphene_frustum_init_from_matrix( fru.to_glib_none_mut().0, matrix.to_glib_none().0, ); fru } } } impl fmt::Debug for Frustum { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Frustum") .field("planes", &self.planes()) .finish() } } graphene-rs-0.19.2/src/lib.rs000064400000000000000000000011341046102023000140320ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] pub use ffi; pub use glib; // Graphene has no runtime to initialize macro_rules! assert_initialized_main_thread { () => {}; } // No-op macro_rules! skip_assert_initialized { () => {}; } mod auto; pub mod prelude; pub use crate::auto::*; mod box_; mod euler; mod frustum; mod matrix; mod plane; mod point; mod point3_d; mod quad; mod quaternion; mod ray; mod rect; mod size; mod sphere; mod triangle; mod vec2; mod vec3; mod vec4; graphene-rs-0.19.2/src/matrix.rs000064400000000000000000000152771046102023000146050ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Matrix, Point3D, Vec3, Vec4}; impl Matrix { #[doc(alias = "graphene_matrix_init_from_2d")] #[doc(alias = "init_from_2d")] pub fn from_2d(xx: f64, yx: f64, xy: f64, yy: f64, x_0: f64, y_0: f64) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_from_2d(mat.to_glib_none_mut().0, xx, yx, xy, yy, x_0, y_0); mat } } #[doc(alias = "graphene_matrix_init_from_float")] #[doc(alias = "init_from_float")] pub fn from_float(v: [f32; 16]) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_from_float(mat.to_glib_none_mut().0, v.as_ptr() as *const _); mat } } #[doc(alias = "graphene_matrix_init_from_vec4")] #[doc(alias = "init_from_vec4")] pub fn from_vec4(v0: &Vec4, v1: &Vec4, v2: &Vec4, v3: &Vec4) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_from_vec4( mat.to_glib_none_mut().0, v0.to_glib_none().0, v1.to_glib_none().0, v2.to_glib_none().0, v3.to_glib_none().0, ); mat } } #[doc(alias = "graphene_matrix_init_frustum")] #[doc(alias = "init_frustum")] pub fn new_frustum( left: f32, right: f32, bottom: f32, top: f32, z_near: f32, z_far: f32, ) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_frustum( mat.to_glib_none_mut().0, left, right, bottom, top, z_near, z_far, ); mat } } #[doc(alias = "graphene_matrix_init_identity")] #[doc(alias = "init_identity")] pub fn new_identity() -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_identity(mat.to_glib_none_mut().0); mat } } #[doc(alias = "graphene_matrix_init_look_at")] #[doc(alias = "init_look_at")] pub fn new_look_at(eye: &Vec3, center: &Vec3, up: &Vec3) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_look_at( mat.to_glib_none_mut().0, eye.to_glib_none().0, center.to_glib_none().0, up.to_glib_none().0, ); mat } } #[doc(alias = "graphene_matrix_init_ortho")] #[doc(alias = "init_ortho")] pub fn new_ortho( left: f32, right: f32, top: f32, bottom: f32, z_near: f32, z_far: f32, ) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_ortho( mat.to_glib_none_mut().0, left, right, top, bottom, z_near, z_far, ); mat } } #[doc(alias = "graphene_matrix_init_perspective")] #[doc(alias = "init_perspective")] pub fn new_perspective(fovy: f32, aspect: f32, z_near: f32, z_far: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_perspective( mat.to_glib_none_mut().0, fovy, aspect, z_near, z_far, ); mat } } #[doc(alias = "graphene_matrix_init_rotate")] #[doc(alias = "init_rotate")] pub fn new_rotate(angle: f32, axis: &Vec3) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_rotate( mat.to_glib_none_mut().0, angle, axis.to_glib_none().0, ); mat } } #[doc(alias = "graphene_matrix_init_scale")] #[doc(alias = "init_scale")] pub fn new_scale(x: f32, y: f32, z: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_scale(mat.to_glib_none_mut().0, x, y, z); mat } } #[doc(alias = "graphene_matrix_init_skew")] #[doc(alias = "init_skew")] pub fn new_skew(x_skew: f32, y_skew: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_skew(mat.to_glib_none_mut().0, x_skew, y_skew); mat } } #[doc(alias = "graphene_matrix_init_translate")] #[doc(alias = "init_translate")] pub fn new_translate(p: &Point3D) -> Self { assert_initialized_main_thread!(); unsafe { let mut mat = Self::uninitialized(); ffi::graphene_matrix_init_translate(mat.to_glib_none_mut().0, p.to_glib_none().0); mat } } #[doc(alias = "graphene_matrix_to_float")] pub fn to_float(&self) -> [f32; 16] { unsafe { let mut out = std::mem::MaybeUninit::uninit(); ffi::graphene_matrix_to_float(self.to_glib_none().0, out.as_mut_ptr()); out.assume_init() } } #[inline] pub fn values(&self) -> &[[f32; 4]; 4] { unsafe { &*(&self.inner.value as *const ffi::graphene_simd4x4f_t as *const [[f32; 4]; 4]) } } } impl fmt::Debug for Matrix { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Matrix") .field("values", &self.values()) .finish() } } impl Default for Matrix { fn default() -> Self { Self::new_identity() } } #[cfg(test)] mod tests { use super::Matrix; #[test] fn test_matrix_values() { let matrix = Matrix::new_identity(); assert_eq!( matrix.values(), &[ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0] ], ); } } graphene-rs-0.19.2/src/plane.rs000064400000000000000000000042721046102023000143710ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Plane, Point3D, Vec3, Vec4}; impl Plane { #[doc(alias = "graphene_plane_init")] pub fn new(normal: Option<&Vec3>, constant: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut plane = Self::uninitialized(); ffi::graphene_plane_init( plane.to_glib_none_mut().0, normal.to_glib_none().0, constant, ); plane } } #[doc(alias = "graphene_plane_init_from_point")] #[doc(alias = "init_from_point")] pub fn from_point(normal: &Vec3, point: &Point3D) -> Self { assert_initialized_main_thread!(); unsafe { let mut plane = Self::uninitialized(); ffi::graphene_plane_init_from_point( plane.to_glib_none_mut().0, normal.to_glib_none().0, point.to_glib_none().0, ); plane } } #[doc(alias = "graphene_plane_init_from_points")] #[doc(alias = "init_from_points")] pub fn from_points(a: &Point3D, b: &Point3D, c: &Point3D) -> Self { assert_initialized_main_thread!(); unsafe { let mut plane = Self::uninitialized(); ffi::graphene_plane_init_from_points( plane.to_glib_none_mut().0, a.to_glib_none().0, b.to_glib_none().0, c.to_glib_none().0, ); plane } } #[doc(alias = "graphene_plane_init_from_vec4")] #[doc(alias = "init_from_vec4")] pub fn from_vec4(src: &Vec4) -> Self { assert_initialized_main_thread!(); unsafe { let mut plane = Self::uninitialized(); ffi::graphene_plane_init_from_vec4(plane.to_glib_none_mut().0, src.to_glib_none().0); plane } } } impl fmt::Debug for Plane { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Plane") .field("constant", &self.constant()) .field("normal", &self.normal()) .finish() } } graphene-rs-0.19.2/src/point.rs000064400000000000000000000026321046102023000144210ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Point, Vec2}; impl Point { #[doc(alias = "graphene_point_init")] pub fn new(x: f32, y: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut p = Self::uninitialized(); ffi::graphene_point_init(p.to_glib_none_mut().0, x, y); p } } #[doc(alias = "graphene_point_init_from_vec2")] #[doc(alias = "init_from_vec2")] pub fn from_vec2(src: &Vec2) -> Point { assert_initialized_main_thread!(); unsafe { let mut p = Self::uninitialized(); ffi::graphene_point_init_from_vec2(p.to_glib_none_mut().0, src.to_glib_none().0); p } } #[inline] pub fn x(&self) -> f32 { self.inner.x } #[inline] pub fn set_x(&mut self, x: f32) { self.inner.x = x; } #[inline] pub fn y(&self) -> f32 { self.inner.y } #[inline] pub fn set_y(&mut self, y: f32) { self.inner.y = y; } } impl fmt::Debug for Point { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Point") .field("x", &self.x()) .field("y", &self.y()) .finish() } } impl Default for Point { fn default() -> Self { Self::zero() } } graphene-rs-0.19.2/src/point3_d.rs000064400000000000000000000031611046102023000150050ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Point3D, Vec3}; impl Point3D { #[doc(alias = "graphene_point3d_init")] pub fn new(x: f32, y: f32, z: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut p = Self::uninitialized(); ffi::graphene_point3d_init(p.to_glib_none_mut().0, x, y, z); p } } #[doc(alias = "graphene_point3d_init_from_vec3")] #[doc(alias = "init_from_vec3")] pub fn from_vec3(v: &Vec3) -> Self { assert_initialized_main_thread!(); unsafe { let mut p = Self::uninitialized(); ffi::graphene_point3d_init_from_vec3(p.to_glib_none_mut().0, v.to_glib_none().0); p } } #[inline] pub fn x(&self) -> f32 { self.inner.x } #[inline] pub fn set_x(&mut self, x: f32) { self.inner.x = x; } #[inline] pub fn y(&self) -> f32 { self.inner.y } #[inline] pub fn set_y(&mut self, y: f32) { self.inner.y = y; } #[inline] pub fn z(&self) -> f32 { self.inner.z } #[inline] pub fn set_z(&mut self, z: f32) { self.inner.z = z; } } impl fmt::Debug for Point3D { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Point3D") .field("x", &self.x()) .field("y", &self.y()) .field("z", &self.z()) .finish() } } impl Default for Point3D { fn default() -> Self { Self::zero() } } graphene-rs-0.19.2/src/prelude.rs000064400000000000000000000003041046102023000147220ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for blanket imports. #[doc(hidden)] pub use glib::prelude::*; graphene-rs-0.19.2/src/quad.rs000064400000000000000000000044141046102023000142220ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Point, Quad, Rect}; impl Quad { #[doc(alias = "graphene_quad_init")] pub fn new(p1: &Point, p2: &Point, p3: &Point, p4: &Point) -> Self { assert_initialized_main_thread!(); unsafe { let mut quad = Self::uninitialized(); ffi::graphene_quad_init( quad.to_glib_none_mut().0, p1.to_glib_none().0, p2.to_glib_none().0, p3.to_glib_none().0, p4.to_glib_none().0, ); quad } } #[doc(alias = "graphene_quad_init_from_rect")] #[doc(alias = "init_from_rect")] pub fn from_rect(r: &Rect) -> Self { assert_initialized_main_thread!(); unsafe { let mut quad = Self::uninitialized(); ffi::graphene_quad_init_from_rect(quad.to_glib_none_mut().0, r.to_glib_none().0); quad } } #[doc(alias = "graphene_quad_init_from_points")] #[doc(alias = "init_from_points")] pub fn from_points(points: &[Point; 4]) -> Self { assert_initialized_main_thread!(); unsafe { let points = [ *points[0].to_glib_none().0, *points[1].to_glib_none().0, *points[2].to_glib_none().0, *points[3].to_glib_none().0, ]; let mut quad = Self::uninitialized(); ffi::graphene_quad_init_from_points( quad.to_glib_none_mut().0, points.as_ptr() as *const _, ); quad } } #[doc(alias = "graphene_quad_get_point")] #[doc(alias = "get_point")] pub fn point(&self, index_: u32) -> Point { assert!(index_ < 4); unsafe { from_glib_none(ffi::graphene_quad_get_point(self.to_glib_none().0, index_)) } } #[inline] pub fn points(&self) -> &[Point; 4] { unsafe { &*(&self.inner.points as *const [ffi::graphene_point_t; 4] as *const [Point; 4]) } } } impl fmt::Debug for Quad { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Quad") .field("points", &self.points()) .finish() } } graphene-rs-0.19.2/src/quaternion.rs000064400000000000000000000101411046102023000154470ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Euler, Matrix, Quaternion, Vec3, Vec4}; impl Quaternion { #[doc(alias = "graphene_quaternion_init")] pub fn new(x: f32, y: f32, z: f32, w: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut quat = Self::uninitialized(); ffi::graphene_quaternion_init(quat.to_glib_none_mut().0, x, y, z, w); quat } } #[doc(alias = "graphene_quaternion_init_from_angle_vec3")] #[doc(alias = "init_from_angle_vec3")] pub fn from_angle_vec3(angle: f32, axis: &Vec3) -> Self { assert_initialized_main_thread!(); unsafe { let mut quat = Self::uninitialized(); ffi::graphene_quaternion_init_from_angle_vec3( quat.to_glib_none_mut().0, angle, axis.to_glib_none().0, ); quat } } #[doc(alias = "graphene_quaternion_init_from_angles")] #[doc(alias = "init_from_angles")] pub fn from_angles(deg_x: f32, deg_y: f32, deg_z: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut quat = Self::uninitialized(); ffi::graphene_quaternion_init_from_angles( quat.to_glib_none_mut().0, deg_x, deg_y, deg_z, ); quat } } #[doc(alias = "graphene_quaternion_init_from_euler")] #[doc(alias = "init_from_euler")] pub fn from_euler(e: &Euler) -> Self { assert_initialized_main_thread!(); unsafe { let mut quat = Self::uninitialized(); ffi::graphene_quaternion_init_from_euler(quat.to_glib_none_mut().0, e.to_glib_none().0); quat } } #[doc(alias = "graphene_quaternion_init_from_matrix")] #[doc(alias = "init_from_matrix")] pub fn from_matrix(m: &Matrix) -> Self { assert_initialized_main_thread!(); unsafe { let mut quat = Self::uninitialized(); ffi::graphene_quaternion_init_from_matrix( quat.to_glib_none_mut().0, m.to_glib_none().0, ); quat } } #[doc(alias = "graphene_quaternion_init_from_radians")] #[doc(alias = "init_from_radians")] pub fn from_radians(rad_x: f32, rad_y: f32, rad_z: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut quat = Self::uninitialized(); ffi::graphene_quaternion_init_from_radians( quat.to_glib_none_mut().0, rad_x, rad_y, rad_z, ); quat } } #[doc(alias = "graphene_quaternion_init_from_vec4")] #[doc(alias = "init_from_vec4")] pub fn from_vec4(src: &Vec4) -> Self { assert_initialized_main_thread!(); unsafe { let mut quat = Self::uninitialized(); ffi::graphene_quaternion_init_from_vec4( quat.to_glib_none_mut().0, src.to_glib_none().0, ); quat } } #[doc(alias = "graphene_quaternion_init_identity")] #[doc(alias = "init_identity")] pub fn new_identity() -> Self { assert_initialized_main_thread!(); unsafe { let mut quat = Self::uninitialized(); ffi::graphene_quaternion_init_identity(quat.to_glib_none_mut().0); quat } } #[inline] pub fn x(&self) -> f32 { self.inner.x } #[inline] pub fn y(&self) -> f32 { self.inner.y } #[inline] pub fn z(&self) -> f32 { self.inner.z } #[inline] pub fn w(&self) -> f32 { self.inner.w } } impl fmt::Debug for Quaternion { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Quaternion") .field("x", &self.x()) .field("y", &self.y()) .field("z", &self.z()) .field("w", &self.w()) .finish() } } graphene-rs-0.19.2/src/ray.rs000064400000000000000000000025031046102023000140600ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Point3D, Ray, Vec3}; impl Ray { #[doc(alias = "graphene_ray_init")] pub fn new(origin: Option<&Point3D>, direction: Option<&Vec3>) -> Self { assert_initialized_main_thread!(); unsafe { let mut ray = Self::uninitialized(); ffi::graphene_ray_init( ray.to_glib_none_mut().0, origin.to_glib_none().0, direction.to_glib_none().0, ); ray } } #[doc(alias = "graphene_ray_init_from_vec3")] #[doc(alias = "init_from_vec3")] pub fn from_vec3(origin: Option<&Vec3>, direction: Option<&Vec3>) -> Self { assert_initialized_main_thread!(); unsafe { let mut ray = Self::uninitialized(); ffi::graphene_ray_init_from_vec3( ray.to_glib_none_mut().0, origin.to_glib_none().0, direction.to_glib_none().0, ); ray } } } impl fmt::Debug for Ray { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Ray") .field("origin", &self.origin()) .field("direction", &self.direction()) .finish() } } graphene-rs-0.19.2/src/rect.rs000064400000000000000000000034271046102023000142300ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Rect, Vec2}; impl Rect { #[doc(alias = "graphene_rect_get_vertices")] #[doc(alias = "get_vertices")] pub fn vertices(&self) -> &[Vec2; 4] { unsafe { let mut out: [ffi::graphene_vec2_t; 4] = std::mem::zeroed(); ffi::graphene_rect_get_vertices(self.to_glib_none().0, &mut out as *mut _); &*(&out as *const [ffi::graphene_vec2_t; 4] as *const [Vec2; 4]) } } #[doc(alias = "graphene_rect_init")] pub fn new(x: f32, y: f32, width: f32, height: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut rect = Self::uninitialized(); ffi::graphene_rect_init(rect.to_glib_none_mut().0, x, y, width, height); rect } } } impl fmt::Debug for Rect { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Rect") .field("x", &self.x()) .field("y", &self.y()) .field("width", &self.width()) .field("height", &self.height()) .finish() } } impl Default for Rect { fn default() -> Self { Self::zero() } } #[cfg(test)] mod tests { use super::*; use crate::Point; #[test] fn contains_point() { let rect = Rect::new(100., 100., 100., 100.); let right = Point::new(250., 150.); let below = Point::new(150., 50.); let left = Point::new(50., 150.); let above = Point::new(150., 250.); assert!(!rect.contains_point(&right)); assert!(!rect.contains_point(&below)); assert!(!rect.contains_point(&left)); assert!(!rect.contains_point(&above)); } } graphene-rs-0.19.2/src/size.rs000064400000000000000000000020551046102023000142410ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::Size; impl Size { #[doc(alias = "graphene_size_init")] pub fn new(width: f32, height: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut siz = Self::uninitialized(); ffi::graphene_size_init(siz.to_glib_none_mut().0, width, height); siz } } #[inline] pub fn width(&self) -> f32 { self.inner.width } #[inline] pub fn set_width(&mut self, width: f32) { self.inner.width = width; } #[inline] pub fn height(&self) -> f32 { self.inner.height } #[inline] pub fn set_height(&mut self, height: f32) { self.inner.height = height; } } impl fmt::Debug for Size { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Size") .field("width", &self.width()) .field("height", &self.height()) .finish() } } graphene-rs-0.19.2/src/sphere.rs000064400000000000000000000035501046102023000145560ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Point3D, Sphere, Vec3}; impl Sphere { #[doc(alias = "graphene_sphere_init")] pub fn new(center: Option<&Point3D>, radius: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut sph = Self::uninitialized(); ffi::graphene_sphere_init(sph.to_glib_none_mut().0, center.to_glib_none().0, radius); sph } } #[doc(alias = "graphene_sphere_init_from_points")] #[doc(alias = "init_from_points")] pub fn from_points(points: &[Point3D], center: Option<&Point3D>) -> Self { assert_initialized_main_thread!(); let n = points.len() as u32; unsafe { let mut sph = Self::uninitialized(); ffi::graphene_sphere_init_from_points( sph.to_glib_none_mut().0, n, points.to_glib_none().0, center.to_glib_none().0, ); sph } } #[doc(alias = "graphene_sphere_init_from_vectors")] #[doc(alias = "init_from_vectors")] pub fn from_vectors(vectors: &[Vec3], center: Option<&Point3D>) -> Self { assert_initialized_main_thread!(); let n = vectors.len() as u32; unsafe { let mut sph = Self::uninitialized(); ffi::graphene_sphere_init_from_vectors( sph.to_glib_none_mut().0, n, vectors.to_glib_none().0, center.to_glib_none().0, ); sph } } } impl fmt::Debug for Sphere { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Sphere") .field("radius", &self.radius()) .field("center", &self.center()) .finish() } } graphene-rs-0.19.2/src/triangle.rs000064400000000000000000000037311046102023000150760ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Point3D, Triangle, Vec3}; impl Triangle { #[doc(alias = "graphene_triangle_init_from_float")] #[doc(alias = "init_from_float")] pub fn from_float(a: [f32; 3], b: [f32; 3], c: [f32; 3]) -> Self { assert_initialized_main_thread!(); unsafe { let mut tri = Self::uninitialized(); ffi::graphene_triangle_init_from_float( tri.to_glib_none_mut().0, a.as_ptr() as *const _, b.as_ptr() as *const _, c.as_ptr() as *const _, ); tri } } #[doc(alias = "graphene_triangle_init_from_point3d")] #[doc(alias = "init_from_point3d")] pub fn from_point3d(a: Option<&Point3D>, b: Option<&Point3D>, c: Option<&Point3D>) -> Self { assert_initialized_main_thread!(); unsafe { let mut tri = Self::uninitialized(); ffi::graphene_triangle_init_from_point3d( tri.to_glib_none_mut().0, a.to_glib_none().0, b.to_glib_none().0, c.to_glib_none().0, ); tri } } #[doc(alias = "graphene_triangle_init_from_vec3")] #[doc(alias = "init_from_vec3")] pub fn from_vec3(a: Option<&Vec3>, b: Option<&Vec3>, c: Option<&Vec3>) -> Self { assert_initialized_main_thread!(); unsafe { let mut tri = Self::uninitialized(); ffi::graphene_triangle_init_from_vec3( tri.to_glib_none_mut().0, a.to_glib_none().0, b.to_glib_none().0, c.to_glib_none().0, ); tri } } } impl fmt::Debug for Triangle { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Triangle") .field("points", &self.points()) .finish() } } graphene-rs-0.19.2/src/vec2.rs000064400000000000000000000026121046102023000141250ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::Vec2; impl Vec2 { #[doc(alias = "graphene_vec2_init")] pub fn new(x: f32, y: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut vec = Self::uninitialized(); ffi::graphene_vec2_init(vec.to_glib_none_mut().0, x, y); vec } } #[doc(alias = "graphene_vec2_init_from_float")] #[doc(alias = "init_from_float")] pub fn from_float(src: [f32; 2]) -> Self { assert_initialized_main_thread!(); unsafe { let mut vec = Self::uninitialized(); ffi::graphene_vec2_init_from_float(vec.to_glib_none_mut().0, src.as_ptr() as *const _); vec } } #[doc(alias = "graphene_vec2_to_float")] pub fn to_float(&self) -> [f32; 2] { unsafe { let mut out = std::mem::MaybeUninit::uninit(); ffi::graphene_vec2_to_float(self.to_glib_none().0, out.as_mut_ptr()); out.assume_init() } } } impl fmt::Debug for Vec2 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Vec2") .field("x", &self.x()) .field("y", &self.y()) .finish() } } impl Default for Vec2 { fn default() -> Self { Self::zero() } } graphene-rs-0.19.2/src/vec3.rs000064400000000000000000000026701046102023000141320ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::Vec3; impl Vec3 { #[doc(alias = "graphene_vec3_init")] pub fn new(x: f32, y: f32, z: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut vec = Self::uninitialized(); ffi::graphene_vec3_init(vec.to_glib_none_mut().0, x, y, z); vec } } #[doc(alias = "graphene_vec3_init_from_float")] #[doc(alias = "init_from_float")] pub fn from_float(src: [f32; 3]) -> Self { assert_initialized_main_thread!(); unsafe { let mut vec = Self::uninitialized(); ffi::graphene_vec3_init_from_float(vec.to_glib_none_mut().0, src.as_ptr() as *const _); vec } } #[doc(alias = "graphene_vec3_to_float")] pub fn to_float(&self) -> [f32; 3] { unsafe { let mut out = std::mem::MaybeUninit::uninit(); ffi::graphene_vec3_to_float(self.to_glib_none().0, out.as_mut_ptr()); out.assume_init() } } } impl fmt::Debug for Vec3 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Vec3") .field("x", &self.x()) .field("y", &self.y()) .field("z", &self.z()) .finish() } } impl Default for Vec3 { fn default() -> Self { Self::zero() } } graphene-rs-0.19.2/src/vec4.rs000064400000000000000000000043651046102023000141360ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use glib::translate::*; use crate::{Vec2, Vec3, Vec4}; impl Vec4 { #[doc(alias = "graphene_vec4_init")] pub fn new(x: f32, y: f32, z: f32, w: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut vec = Self::uninitialized(); ffi::graphene_vec4_init(vec.to_glib_none_mut().0, x, y, z, w); vec } } #[doc(alias = "graphene_vec4_init_from_vec2")] #[doc(alias = "init_from_vec2")] pub fn from_vec2(src: &Vec2, z: f32, w: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut vec = Self::uninitialized(); ffi::graphene_vec4_init_from_vec2(vec.to_glib_none_mut().0, src.to_glib_none().0, z, w); vec } } #[doc(alias = "graphene_vec4_init_from_vec3")] #[doc(alias = "init_from_vec3")] pub fn from_vec3(src: &Vec3, w: f32) -> Self { assert_initialized_main_thread!(); unsafe { let mut vec = Self::uninitialized(); ffi::graphene_vec4_init_from_vec3(vec.to_glib_none_mut().0, src.to_glib_none().0, w); vec } } #[doc(alias = "graphene_vec4_init_from_float")] #[doc(alias = "init_from_float")] pub fn from_float(src: [f32; 4]) -> Self { assert_initialized_main_thread!(); unsafe { let mut vec = Self::uninitialized(); ffi::graphene_vec4_init_from_float(vec.to_glib_none_mut().0, src.as_ptr() as *const _); vec } } #[doc(alias = "graphene_vec4_to_float")] pub fn to_float(&self) -> [f32; 4] { unsafe { let mut out = std::mem::MaybeUninit::uninit(); ffi::graphene_vec4_to_float(self.to_glib_none().0, out.as_mut_ptr()); out.assume_init() } } } impl fmt::Debug for Vec4 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Vec4") .field("x", &self.x()) .field("y", &self.y()) .field("z", &self.z()) .field("w", &self.w()) .finish() } } impl Default for Vec4 { fn default() -> Self { Self::zero() } } graphene-rs-0.19.2/tests/check_gir.rs000064400000000000000000000003461046102023000155610ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[test] fn check_gir_file() { let res = gir_format_check::check_gir_file("Gir.toml"); println!("{res}"); assert_eq!(res.nb_errors, 0); }