Struct conrod::Range
[−]
[src]
pub struct Range { pub start: Scalar, pub end: Scalar, }
Some start and end position along a single axis.
Fields
start: Scalar
The start of some Range
along an axis.
end: Scalar
The end of some Range
along an axis.
Methods
impl Range
[src]
fn new(range: Range<Scalar>) -> Range
Construct a new Range
from a given range, i.e. Range::new(start..end)
.
fn from_pos_and_len(pos: Scalar, len: Scalar) -> Range
Construct a new Range
from a given length and its centered position.
fn magnitude(&self) -> Scalar
The start
value subtracted from the end
value.
fn len(&self) -> Scalar
The absolute length of the Range aka the absolute magnitude.
fn middle(&self) -> Scalar
Return the value directly between the start and end values.
fn invert(self) -> Range
The current range with its start and end values swapped.
fn map_value_to(&self, value: Scalar, other: &Range) -> Scalar
Map the given Scalar from Self
to some other given Range
.
fn shift(self, amount: Scalar) -> Range
Shift the Range
start and end points by a given Scalar
.
fn direction(&self) -> Scalar
The direction of the Range represented as a normalised scalar.
fn undirected(self) -> Range
Converts the Range to an undirected Range. By ensuring that start
<= end
.
If start
> end
, then the start and end points will be swapped.
fn max(self, other: Range) -> Range
The Range that encompasses both self and the given Range.
The returned Range's start
will always be <= its end
.
fn overlap(self, other: Range) -> Option<Range>
The Range that represents the range of the overlap between two Ranges if there is some.
The returned Range's start
will always be <= its end
.
fn max_directed(self, other: Range) -> Range
The Range that encompasses both self and the given Range.
The returned Range will retain self
's original direction.
fn is_over(&self, pos: Scalar) -> bool
Is the given scalar within our range.
fn round(self) -> Range
Round the values at both ends of the Range and return the result.
fn floor(self) -> Range
Floor the values at both ends of the Range and return the result.
fn sub_frame(self, frame: Scalar) -> Range
Shorten the Range from both ends by the given Scalar amount.
fn add_frame(self, frame: Scalar) -> Range
Lengthen the Range from both ends by the given Scalar amount.
fn pad_start(self, pad: Scalar) -> Range
The Range with some padding given to the start
value.
fn pad_end(self, pad: Scalar) -> Range
The Range with some padding given to the end
value.
fn pad(self, pad: Scalar) -> Range
The Range with some given padding to be applied to each end.
fn padding(self, start: Scalar, end: Scalar) -> Range
The Range with some padding given for each end.
Trait Implementations
impl PartialEq for Range
[src]
fn eq(&self, __arg_0: &Range) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Range) -> bool
This method tests for !=
.
impl Debug for Range
[src]
impl Clone for Range
[src]
fn clone(&self) -> Range
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Copy for Range
[src]
impl Add<Range> for Range
[src]
type Output = Range
The resulting type after applying the +
operator
fn add(self, rhs: Range) -> Range
The method for the +
operator