pub struct Triangle {
    pub corners: [Vec2D; 3],
    pub fill_char: ColChar,
}
Expand description

The Triangle takes three Vec2Ds and returns a triangle with those vertices when blit to a View

Fields§

§corners: [Vec2D; 3]

The 3 cornes of the triangle

§fill_char: ColChar

The ColChar used to fill the triange

Implementations§

source§

impl Triangle

source

pub const fn new( pos0: Vec2D, pos1: Vec2D, pos2: Vec2D, fill_char: ColChar ) -> Self

Create a new triangle from three separate positions and a ColChar

source

pub const fn with_array(corners: [Vec2D; 3], fill_char: ColChar) -> Self

Create a new triangle from an array of Vec2Ds and a ColChar

source

pub const fn corners(&self) -> [Vec2D; 3]

👎Deprecated: Triangle has been restructured, just use Triangle.corners now

Return the triangle’s points as an array

source

pub fn interpolate(i0: isize, d0: isize, i1: isize, d1: isize) -> Vec<isize>

Draw a pseudo-line between the independent and dependent positions. Returns rounded values as isizes. If you don’t want the values rounded, use Triangle::interpolate_floating()

source

pub fn interpolate_floating(i0: isize, d0: f64, i1: isize, d1: f64) -> Vec<f64>

Draw a pseudo-line between the independent and dependent positions

source

pub fn draw(corners: [Vec2D; 3]) -> Vec<Vec2D>

Takes three corner Vec2Ds and returns the points you should plot to the screen to make a triangle

Trait Implementations§

source§

impl ViewElement for Triangle

source§

fn active_pixels(&self) -> Vec<Pixel>

Return a vector of the element’s Pixels - A ColChar. If your whole object is a solid colour, consider using utils::points_to_pixels() which will add the same ColChar to every point and can then be used as this function’s output
source§

fn active_points(&self) -> Vec<Vec2D>

Return the positions the ViewElement occupies, essentially active_pixels() without the ColChars. This has a default setting that extracts the Vec2Ds from active_pixels but you can set it to something else to make it faster

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.