logo
pub trait Translate<T: CoordNum> {
    fn translate(&self, x_offset: T, y_offset: T) -> Self;
    fn translate_mut(&mut self, x_offset: T, y_offset: T);
}

Required Methods

Translate a Geometry along its axes by the given offsets

Performance

If you will be performing multiple transformations, like Scale, Skew, Translate, or Rotate, it is more efficient to compose the transformations and apply them as a single operation using the AffineOps trait.

Examples
use geo::Translate;
use geo::line_string;

let ls = line_string![
    (x: 0.0, y: 0.0),
    (x: 5.0, y: 5.0),
    (x: 10.0, y: 10.0),
];

let translated = ls.translate(1.5, 3.5);

assert_eq!(translated, line_string![
    (x: 1.5, y: 3.5),
    (x: 6.5, y: 8.5),
    (x: 11.5, y: 13.5),
]);

Translate a Geometry along its axes, but in place.

Implementors