pub trait PathExt: 'static {
Show 23 methods
// Required methods
fn add_close(&self);
fn add_curve_to(
&self,
x_1: i32,
y_1: i32,
x_2: i32,
y_2: i32,
x_3: i32,
y_3: i32,
);
fn add_line_to(&self, x: i32, y: i32);
fn add_move_to(&self, x: i32, y: i32);
fn add_node(&self, node: &PathNode);
fn add_rel_curve_to(
&self,
x_1: i32,
y_1: i32,
x_2: i32,
y_2: i32,
x_3: i32,
y_3: i32,
);
fn add_rel_line_to(&self, x: i32, y: i32);
fn add_rel_move_to(&self, x: i32, y: i32);
fn add_string(&self, str: &str) -> bool;
fn clear(&self);
fn foreach<P: FnMut(&PathNode)>(&self, callback: P);
fn get_description(&self) -> Option<GString>;
fn get_length(&self) -> u32;
fn get_n_nodes(&self) -> u32;
fn get_node(&self, index_: u32) -> PathNode;
fn get_nodes(&self) -> Vec<PathNode>;
fn get_position(&self, progress: f64) -> (u32, Knot);
fn insert_node(&self, index_: i32, node: &PathNode);
fn remove_node(&self, index_: u32);
fn replace_node(&self, index_: u32, node: &PathNode);
fn set_description(&self, str: &str) -> bool;
fn connect_property_description_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn connect_property_length_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
}
Required Methods§
Sourcefn add_close(&self)
fn add_close(&self)
Adds a PathNodeType::Close
type node to the path. This creates a
straight line from the last node to the last PathNodeType::MoveTo
type node.
Sourcefn add_curve_to(
&self,
x_1: i32,
y_1: i32,
x_2: i32,
y_2: i32,
x_3: i32,
y_3: i32,
)
fn add_curve_to( &self, x_1: i32, y_1: i32, x_2: i32, y_2: i32, x_3: i32, y_3: i32, )
Adds a PathNodeType::CurveTo
type node to the path. This causes
the actor to follow a bezier from the last node to (x_3
, y_3
) using
(x_1
, y_1
) and (x_2
,y_2
) as control points.
§x_1
the x coordinate of the first control point
§y_1
the y coordinate of the first control point
§x_2
the x coordinate of the second control point
§y_2
the y coordinate of the second control point
§x_3
the x coordinate of the third control point
§y_3
the y coordinate of the third control point
Sourcefn add_line_to(&self, x: i32, y: i32)
fn add_line_to(&self, x: i32, y: i32)
Sourcefn add_move_to(&self, x: i32, y: i32)
fn add_move_to(&self, x: i32, y: i32)
Sourcefn add_rel_curve_to(
&self,
x_1: i32,
y_1: i32,
x_2: i32,
y_2: i32,
x_3: i32,
y_3: i32,
)
fn add_rel_curve_to( &self, x_1: i32, y_1: i32, x_2: i32, y_2: i32, x_3: i32, y_3: i32, )
Same as PathExt::add_curve_to
except the coordinates are
relative to the previous node.
§x_1
the x coordinate of the first control point
§y_1
the y coordinate of the first control point
§x_2
the x coordinate of the second control point
§y_2
the y coordinate of the second control point
§x_3
the x coordinate of the third control point
§y_3
the y coordinate of the third control point
Sourcefn add_rel_line_to(&self, x: i32, y: i32)
fn add_rel_line_to(&self, x: i32, y: i32)
Sourcefn add_rel_move_to(&self, x: i32, y: i32)
fn add_rel_move_to(&self, x: i32, y: i32)
Sourcefn add_string(&self, str: &str) -> bool
fn add_string(&self, str: &str) -> bool
Adds new nodes to the end of the path as described in str
. The
format is a subset of the SVG path format. Each node is represented
by a letter and is followed by zero, one or three pairs of
coordinates. The coordinates can be separated by spaces or a
comma. The types are:
M
: Adds aPathNodeType::MoveTo
node. Takes one pair of coordinates.L
: Adds aPathNodeType::LineTo
node. Takes one pair of coordinates.C
: Adds aPathNodeType::CurveTo
node. Takes three pairs of coordinates.z
: Adds aPathNodeType::Close
node. No coordinates are needed.
The M, L and C commands can also be specified in lower case which means the coordinates are relative to the previous node.
For example, to move an actor in a 100 by 100 pixel square centered on the point 300,300 you could use the following path:
M 250,350 l 0 -100 L 350,250 l 0 100 z
If the path description isn’t valid false
will be returned and no
nodes will be added.
§str
a string describing the new nodes
§Returns
true
is the path description was valid or false
otherwise.
Sourcefn get_description(&self) -> Option<GString>
fn get_description(&self) -> Option<GString>
Returns a newly allocated string describing the path in the same
format as used by PathExt::add_string
.
§Returns
a string description of the path. Free with g_free
.
Sourcefn get_length(&self) -> u32
fn get_length(&self) -> u32
Sourcefn get_n_nodes(&self) -> u32
fn get_n_nodes(&self) -> u32
Sourcefn get_nodes(&self) -> Vec<PathNode>
fn get_nodes(&self) -> Vec<PathNode>
Returns a glib::SList
of PathNode
s. The list should be
freed with glib::SList::free
. The nodes are owned by the path and
should not be freed. Altering the path may cause the nodes in the
list to become invalid so you should copy them if you want to keep
the list.
§Returns
a list of nodes in the path.
Sourcefn get_position(&self, progress: f64) -> (u32, Knot)
fn get_position(&self, progress: f64) -> (u32, Knot)
The value in progress
represents a position along the path where
0.0 is the beginning and 1.0 is the end of the path. An
interpolated position is then stored in position
.
§progress
a position along the path as a fraction of its length
§position
location to store the position
§Returns
index of the node used to calculate the position.
Sourcefn insert_node(&self, index_: i32, node: &PathNode)
fn insert_node(&self, index_: i32, node: &PathNode)
Sourcefn remove_node(&self, index_: u32)
fn remove_node(&self, index_: u32)
Sourcefn replace_node(&self, index_: u32, node: &PathNode)
fn replace_node(&self, index_: u32, node: &PathNode)
Sourcefn set_description(&self, str: &str) -> bool
fn set_description(&self, str: &str) -> bool
fn connect_property_description_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_property_length_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.