pub trait Scale {
// Required methods
fn scale(&self, scale_factor: BroadcastablePrimitive<Float64Type>) -> Self;
fn scale_xy(
&self,
x_factor: BroadcastablePrimitive<Float64Type>,
y_factor: BroadcastablePrimitive<Float64Type>
) -> Self;
fn scale_around_point(
&self,
x_factor: BroadcastablePrimitive<Float64Type>,
y_factor: BroadcastablePrimitive<Float64Type>,
origin: Point
) -> Self;
}
Expand description
Required Methods§
sourcefn scale(&self, scale_factor: BroadcastablePrimitive<Float64Type>) -> Self
fn scale(&self, scale_factor: BroadcastablePrimitive<Float64Type>) -> Self
Scale geometries from its bounding box center.
Examples
use geo::Scale;
use geo::{LineString, line_string};
let ls: LineString = line_string![(x: 0., y: 0.), (x: 10., y: 10.)];
let scaled = ls.scale(2.);
assert_eq!(scaled, line_string![
(x: -5., y: -5.),
(x: 15., y: 15.)
]);
sourcefn scale_xy(
&self,
x_factor: BroadcastablePrimitive<Float64Type>,
y_factor: BroadcastablePrimitive<Float64Type>
) -> Self
fn scale_xy( &self, x_factor: BroadcastablePrimitive<Float64Type>, y_factor: BroadcastablePrimitive<Float64Type> ) -> Self
Scale geometries from its bounding box center, using different values for x_factor
and
y_factor
to distort the geometry’s aspect ratio.
Examples
use geo::Scale;
use geo::{LineString, line_string};
let ls: LineString = line_string![(x: 0., y: 0.), (x: 10., y: 10.)];
let scaled = ls.scale_xy(2., 4.);
assert_eq!(scaled, line_string![
(x: -5., y: -15.),
(x: 15., y: 25.)
]);
sourcefn scale_around_point(
&self,
x_factor: BroadcastablePrimitive<Float64Type>,
y_factor: BroadcastablePrimitive<Float64Type>,
origin: Point
) -> Self
fn scale_around_point( &self, x_factor: BroadcastablePrimitive<Float64Type>, y_factor: BroadcastablePrimitive<Float64Type>, origin: Point ) -> Self
Scale geometries around a point of origin
.
The point of origin is usually given as the 2D bounding box centre of the geometry, in
which case you can just use scale
or scale_xy
, but
this method allows you to specify any point.
Examples
use geo::Scale;
use geo::{LineString, line_string};
let ls: LineString = line_string![(x: 0., y: 0.), (x: 10., y: 10.)];
let scaled = ls.scale_xy(2., 4.);
assert_eq!(scaled, line_string![
(x: -5., y: -15.),
(x: 15., y: 25.)
]);
Object Safety§
This trait is not object safe.