pub struct PathPoint { /* private fields */ }
v4_14
only.Expand description
PathPoint
is an opaque type representing a point on a path.
It can be queried for properties of the path at that point, such as its tangent or its curvature.
To obtain a PathPoint
, use Path::closest_point()
,
Path::start_point()
, Path::end_point()
or PathMeasure::point()
.
Note that PathPoint
structs are meant to be stack-allocated,
and don’t hold a reference to the path object they are obtained from.
It is the callers responsibility to keep a reference to the path
as long as the PathPoint
is used.
GLib type: Inline allocated boxed type with stack copy semantics.
Implementations§
Source§impl PathPoint
impl PathPoint
pub fn as_ptr(&self) -> *mut GskPathPoint
Sourcepub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const GskPathPoint) -> &'a Self
pub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const GskPathPoint) -> &'a Self
Borrows the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow_mut<'a>(
ptr: *mut GskPathPoint,
) -> &'a mut Self
pub unsafe fn from_glib_ptr_borrow_mut<'a>( ptr: *mut GskPathPoint, ) -> &'a mut Self
Borrows the underlying C value mutably.
Source§impl PathPoint
impl PathPoint
Sourcepub fn distance(&self, measure: &PathMeasure) -> f32
pub fn distance(&self, measure: &PathMeasure) -> f32
Returns the distance from the beginning of the path to @self.
§measure
a PathMeasure
for the path
§Returns
the distance of @self
Sourcepub fn rotation(&self, path: &Path, direction: PathDirection) -> f32
pub fn rotation(&self, path: &Path, direction: PathDirection) -> f32
Gets the direction of the tangent at a given point.
This is a convenience variant of tangent()
that returns the angle between the tangent and the X axis. The angle
can e.g. be used in
gtk_snapshot_rotate().
§path
the path that @self is on
§direction
the direction for which to return the rotation
§Returns
the angle between the tangent and the X axis, in degrees
Sourcepub fn tangent(&self, path: &Path, direction: PathDirection) -> Vec2
pub fn tangent(&self, path: &Path, direction: PathDirection) -> Vec2
Gets the tangent of the path at the point.
Note that certain points on a path may not have a single tangent, such as sharp turns. At such points, there are two tangents – the direction of the path going into the point, and the direction coming out of it. The @direction argument lets you choose which one to get.
If the path is just a single point (e.g. a circle with
radius zero), then @tangent is set to 0, 0
.
If you want to orient something in the direction of the
path, rotation()
may be more
convenient to use.
§path
the path that @self is on
§direction
the direction for which to return the tangent
§Returns
§tangent
Return location for the tangent at the point
Source§impl PathPoint
impl PathPoint
Sourcepub fn curvature(
&self,
path: &Path,
direction: PathDirection,
) -> (f32, Option<Point>)
pub fn curvature( &self, path: &Path, direction: PathDirection, ) -> (f32, Option<Point>)
Calculates the curvature of the path at the point.
Optionally, returns the center of the osculating circle as well. The curvature is the inverse of the radius of the osculating circle.
Lines have a curvature of zero (indicating an osculating circle of infinite radius. In this case, the @center is not modified.
Circles with a radius of zero have INFINITY
as curvature
Note that certain points on a path may not have a single curvature, such as sharp turns. At such points, there are two curvatures – the (limit of) the curvature of the path going into the point, and the (limit of) the curvature of the path coming out of it. The @direction argument lets you choose which one to get.
## `path` the path that @self is on ## `direction` the direction for which to return the curvature§Returns
The curvature of the path at the given point
§center
Return location for the center of the osculating circle
Trait Implementations§
Source§impl HasParamSpec for PathPoint
impl HasParamSpec for PathPoint
Source§impl Ord for PathPoint
impl Ord for PathPoint
Source§impl PartialOrd for PathPoint
impl PartialOrd for PathPoint
Source§impl StaticType for PathPoint
impl StaticType for PathPoint
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.