Trait components::PathExt[][src]

pub trait PathExt: 'static {
Show methods pub fn add_close(&self);
pub fn add_curve_to(
        &self,
        x_1: i32,
        y_1: i32,
        x_2: i32,
        y_2: i32,
        x_3: i32,
        y_3: i32
    );
pub fn add_line_to(&self, x: i32, y: i32);
pub fn add_move_to(&self, x: i32, y: i32);
pub fn add_node(&self, node: &PathNode);
pub fn add_rel_curve_to(
        &self,
        x_1: i32,
        y_1: i32,
        x_2: i32,
        y_2: i32,
        x_3: i32,
        y_3: i32
    );
pub fn add_rel_line_to(&self, x: i32, y: i32);
pub fn add_rel_move_to(&self, x: i32, y: i32);
pub fn add_string(&self, str: &str) -> bool;
pub fn clear(&self);
pub fn foreach<P>(&self, callback: P)
    where
        P: FnMut(&PathNode)
;
pub fn get_description(&self) -> Option<GString>;
pub fn get_length(&self) -> u32;
pub fn get_n_nodes(&self) -> u32;
pub fn get_node(&self, index_: u32) -> PathNode;
pub fn get_nodes(&self) -> Vec<PathNode, Global>;
pub fn get_position(&self, progress: f64) -> (u32, Knot);
pub fn insert_node(&self, index_: i32, node: &PathNode);
pub fn remove_node(&self, index_: u32);
pub fn replace_node(&self, index_: u32, node: &PathNode);
pub fn set_description(&self, str: &str) -> bool;
pub fn connect_property_description_notify<F>(
        &self,
        f: F
    ) -> SignalHandlerId
    where
        F: 'static + Fn(&Self)
;
pub fn connect_property_length_notify<F>(&self, f: F) -> SignalHandlerId
    where
        F: 'static + Fn(&Self)
;
}

Trait containing all Path methods.

Implementors

Path

Required methods

pub fn add_close(&self)[src]

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.

pub fn add_curve_to(
    &self,
    x_1: i32,
    y_1: i32,
    x_2: i32,
    y_2: i32,
    x_3: i32,
    y_3: i32
)
[src]

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

pub fn add_line_to(&self, x: i32, y: i32)[src]

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

pub fn add_move_to(&self, x: i32, y: i32)[src]

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

pub fn add_node(&self, node: &PathNode)[src]

Adds node to the end of the path.

node

a PathNode

pub fn add_rel_curve_to(
    &self,
    x_1: i32,
    y_1: i32,
    x_2: i32,
    y_2: i32,
    x_3: i32,
    y_3: i32
)
[src]

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

pub fn add_rel_line_to(&self, x: i32, y: i32)[src]

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

x

the x coordinate

y

the y coordinate

pub fn add_rel_move_to(&self, x: i32, y: i32)[src]

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

x

the x coordinate

y

the y coordinate

pub fn add_string(&self, str: &str) -> bool[src]

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.

pub fn clear(&self)[src]

Removes all nodes from the path.

pub fn foreach<P>(&self, callback: P) where
    P: FnMut(&PathNode), 
[src]

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

pub fn get_description(&self) -> Option<GString>[src]

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.

pub fn get_length(&self) -> u32[src]

Retrieves an approximation of the total length of the path.

Returns

the length of the path.

pub fn get_n_nodes(&self) -> u32[src]

Retrieves the number of nodes in the path.

Returns

the number of nodes.

pub fn get_node(&self, index_: u32) -> PathNode[src]

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

pub fn get_nodes(&self) -> Vec<PathNode, Global>[src]

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.

pub fn get_position(&self, progress: f64) -> (u32, Knot)[src]

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.

pub fn insert_node(&self, index_: i32, node: &PathNode)[src]

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

pub fn remove_node(&self, index_: u32)[src]

Removes the node at the given offset from the path.

index_

index of the node to remove

pub fn replace_node(&self, index_: u32, node: &PathNode)[src]

Replaces the node at offset index_ with node.

index_

index to the existing node

node

the replacement node

pub fn set_description(&self, str: &str) -> bool[src]

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.

pub fn connect_property_description_notify<F>(&self, f: F) -> SignalHandlerId where
    F: 'static + Fn(&Self), 
[src]

pub fn connect_property_length_notify<F>(&self, f: F) -> SignalHandlerId where
    F: 'static + Fn(&Self), 
[src]

Loading content...

Implementors

impl<O> PathExt for O where
    O: IsA<Path>, 
[src]

Loading content...