#[repr(transparent)]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.
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 curvatureReturns
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 PartialEq<PathPoint> for PathPoint
impl PartialEq<PathPoint> for PathPoint
source§impl PartialOrd<PathPoint> for PathPoint
impl PartialOrd<PathPoint> for PathPoint
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StaticType for PathPoint
impl StaticType for PathPoint
source§fn static_type() -> Type
fn static_type() -> Type
Self
.