Trait PathExt

Source
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;
}
Expand description

Trait containing all Path methods.

§Implementors

Path

Required Methods§

Source

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.

Source

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

Source

fn add_line_to(&self, x: i32, y: i32)

Adds a PathNodeType::LineTo type node to the path. This causes the actor to move to the new coordinates in a straight line.

§x

the x coordinate

§y

the y coordinate

Source

fn add_move_to(&self, x: i32, y: i32)

Adds a PathNodeType::MoveTo type node to the path. This is usually used as the first node in a path. It can also be used in the middle of the path to cause the actor to jump to the new coordinate.

§x

the x coordinate

§y

the y coordinate

Source

fn add_node(&self, node: &PathNode)

Adds node to the end of the path.

§node

a PathNode

Source

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

Source

fn add_rel_line_to(&self, x: i32, y: i32)

Same as PathExt::add_line_to except the coordinates are relative to the previous node.

§x

the x coordinate

§y

the y coordinate

Source

fn add_rel_move_to(&self, x: i32, y: i32)

Same as PathExt::add_move_to except the coordinates are relative to the previous node.

§x

the x coordinate

§y

the y coordinate

Source

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 a PathNodeType::MoveTo node. Takes one pair of coordinates.
  • L: Adds a PathNodeType::LineTo node. Takes one pair of coordinates.
  • C: Adds a PathNodeType::CurveTo node. Takes three pairs of coordinates.
  • z: Adds a PathNodeType::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.

Source

fn clear(&self)

Removes all nodes from the path.

Source

fn foreach<P: FnMut(&PathNode)>(&self, callback: P)

Calls a function for each node of the path.

§callback

the function to call with each node

§user_data

user data to pass to the function

Source

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.

Source

fn get_length(&self) -> u32

Retrieves an approximation of the total length of the path.

§Returns

the length of the path.

Source

fn get_n_nodes(&self) -> u32

Retrieves the number of nodes in the path.

§Returns

the number of nodes.

Source

fn get_node(&self, index_: u32) -> PathNode

Retrieves the node of the path indexed by index.

§index_

the node number to retrieve

§node

a location to store a copy of the node

Source

fn get_nodes(&self) -> Vec<PathNode>

Returns a glib::SList of PathNodes. 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.

Source

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.

Source

fn insert_node(&self, index_: i32, node: &PathNode)

Inserts node into the path before the node at the given offset. If index_ is negative it will append the node to the end of the path.

§index_

offset of where to insert the node

§node

the node to insert

Source

fn remove_node(&self, index_: u32)

Removes the node at the given offset from the path.

§index_

index of the node to remove

Source

fn replace_node(&self, index_: u32, node: &PathNode)

Replaces the node at offset index_ with node.

§index_

index to the existing node

§node

the replacement node

Source

fn set_description(&self, str: &str) -> bool

Replaces all of the nodes in the path with nodes described by str. See PathExt::add_string for details of the format.

If the string is invalid then false is returned and the path is unaltered.

§str

a string describing the path

§Returns

true is the path was valid, false otherwise.

Source

fn connect_property_description_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

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.

Implementors§

Source§

impl<O: IsA<Path>> PathExt for O