Struct bbecs::data_types::point::Point[][src]

pub struct Point {
    pub x: f32,
    pub y: f32,
}
Expand description

Point that stores a f32 x and y with methods for manipulating the point. Uses Vector math for the methods

Fields

x: f32y: f32

Implementations

impl Point[src]

pub fn new(x: f32, y: f32) -> Self[src]

pub fn to_array(&self) -> [f32; 2][src]

Creates an array of the point with x being the first element, and y being the second. This is mostly useful for working with ggez points as they can cast from arrays.

use bbecs::data_types::point::Point;
let location = Point::new(15.0, 7.0);
assert_eq!(location.to_array(), [15.0, 7.0]);

pub fn add(&mut self, other: &Point)[src]

Adds another point to the one being called, mutating itself

use bbecs::data_types::point::Point;
let mut location = Point::new(0.0, 0.0);
let velocity = Point::new(1.0, 2.0);
location.add(&velocity);
assert_eq!(location, Point::new(1.0, 2.0));

pub fn to_perpendicular_left(&self) -> Self[src]

Create a new Point that is perpendicular to the self pointing towards the left

use bbecs::data_types::point::Point;
let velocity = Point::new(10.0, 25.0);
let left_velocity = velocity.to_perpendicular_left();
assert_eq!(left_velocity, Point::new(25.0, -10.0));

pub fn to_perpendicular_right(&self) -> Self[src]

Create a new Point that is perpendicular to the self pointing towards the right

use bbecs::data_types::point::Point;
let velocity = Point::new(10.0, 25.0);
let right_velocity = velocity.to_perpendicular_right();
assert_eq!(right_velocity, Point::new(-25.0, 10.0));

pub fn multiply_scalar(&mut self, scalar: f32)[src]

Multiplies the x and y by a scalar (single f32) and mutates itself

use bbecs::data_types::point::Point;
let mut point = Point::new(1.0, 2.0);
point.multiply_scalar(10.0);
assert_eq!(point, Point::new(10.0, 20.0));

pub fn normalize(&mut self)[src]

Normalize the point, which makes the hypotenuse equal to 1.0

pub fn length(&self) -> f32[src]

Get the length of the Point

pub fn distance_to(&self, other: &Self) -> f32[src]

pub fn rotation(&self) -> f32[src]

pub fn clamp(&mut self, max: f32, min: f32)[src]

Trait Implementations

impl AddAssign<Point> for Point[src]

fn add_assign(&mut self, rhs: Self)[src]

Performs the += operation. Read more

impl CastComponents<Point> for ComponentData[src]

fn cast(&self) -> Result<&Rc<RefCell<Point>>>[src]

impl Clone for Point[src]

fn clone(&self) -> Point[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Point[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for Point[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl Div<usize> for Point[src]

type Output = Self

The resulting type after applying the / operator.

fn div(self, rhs: usize) -> Self::Output[src]

Performs the / operation. Read more

impl PartialEq<Point> for Point[src]

fn eq(&self, other: &Point) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Point) -> bool[src]

This method tests for !=.

impl ResourceCast<Point> for Resource[src]

fn cast(&self) -> Result<&Point>[src]

fn cast_mut(&mut self) -> Result<&mut Point>[src]

impl Sub<Point> for Point[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, rhs: Self) -> Self[src]

Performs the - operation. Read more

impl Sum<Point> for Point[src]

fn sum<I: Iterator<Item = Point>>(points: I) -> Self[src]

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

impl WorldMethods<Point> for World[src]

fn with_component(&mut self, name: &str, data: Point) -> Result<&mut Self>[src]

fn add_resource(&mut self, name: String, data: Point)[src]

impl Copy for Point[src]

impl StructuralPartialEq for Point[src]

Auto Trait Implementations

impl RefUnwindSafe for Point

impl Send for Point

impl Sync for Point

impl Unpin for Point

impl UnwindSafe for Point

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Debug + Any
[src]

fn is<T>() -> bool where
    T: Scalar
[src]

Tests if Self the same as the type T Read more

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

pub fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

pub fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).

pub unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

pub fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V