Vec4

Struct Vec4 

Source
pub struct Vec4<T> {
    pub x: T,
    pub y: T,
    pub z: T,
    pub w: T,
}

Fields§

§x: T§y: T§z: T§w: T

Implementations§

Source§

impl<T> Vec4<T>

Source

pub fn new(x: T, y: T, z: T, w: T) -> Self

Examples found in repository?
examples/triangle.rs (line 23)
7fn main() {
8    let window = qqx::Window::new().build();
9
10    let triangle = qqx::Polygon::new().vertex(Vertex::new()
11        .pos(qqx::Vec2::new(-0.5, -0.5))
12        .color(qqx::Color::RED))
13    .vertex(Vertex::new()
14        .pos(qqx::Vec2::new(0.0, 0.5))
15        .color(qqx::Color::GREEN))
16    .vertex(Vertex::new()
17        .pos(qqx::Vec2::new(0.5, -0.25))
18        .color(qqx::Color::BLUE)
19    ).bind(window);
20
21    qqx::callback::on_frame(move || {
22        window.draw()
23            .clear(qqx::Color::from(qqx::Vec4::new(0.0, 0.1, 1.0, 1.0)))
24            .draw(&triangle)
25            .finish();
26
27        let next_frame_time = std::time::Instant::now() + std::time::Duration::from_nanos(16_666_667);
28        return qqx::ControlFlow::WaitUntil(next_frame_time);
29    });
30
31    qqx::eventloop();
32}
More examples
Hide additional examples
examples/animated_triangle.rs (line 30)
8fn main() {
9    let window = qqx::Window::new().build();
10
11    let mut triangle = qqx::Polygon::new().vertex(Vertex::new()
12        .pos(qqx::Vec2::new(-0.5, -0.5))
13        .color(qqx::Color::RED))
14    .vertex(Vertex::new()
15        .pos(qqx::Vec2::new(0.0, 0.5))
16        .color(qqx::Color::GREEN))
17    .vertex(Vertex::new()
18        .pos(qqx::Vec2::new(0.5, -0.25))
19        .color(qqx::Color::BLUE)
20    ).bind(window);
21
22    triangle.set_pos(qqx::Vec2::new(-0.5, 0.0));
23    qqx::callback::on_frame(move || {
24        triangle.r#move(qqx::Vec2::new(0.0002, 0.0));
25        if triangle.get_pos().x > 0.5 {
26            triangle.set_pos(qqx::Vec2::new(-0.5, 0.0));
27        }
28
29        window.draw()
30            .clear(qqx::Color::from(qqx::Vec4::new(0.0, 0.1, 1.0, 1.0)))
31            .draw(&triangle)
32            .finish();
33
34        qqx::ControlFlow::Poll
35    });
36
37    qqx::eventloop();
38}

Trait Implementations§

Source§

impl<T> Add<T> for Vec4<T>
where T: Add<Output = T> + Copy,

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add for Vec4<T>
where T: Add<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign<T> for Vec4<T>
where T: Add<Output = T> + Copy,

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<T> AddAssign for Vec4<T>
where T: Add<Output = T> + Copy,

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl AsUniformValue for Vec4<f32>

Source§

fn as_uniform_value(&self) -> UniformValue<'_>

Builds a UniformValue.
Source§

impl Attribute for Vec4<f32>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<f64>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<i16>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<i32>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<i64>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<i8>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<u16>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<u32>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<u64>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl Attribute for Vec4<u8>

Source§

fn get_type() -> AttributeType

Get the type of data.
Source§

fn is_supported<C>(caps: &C) -> bool

Returns true if the backend supports this type of attribute.
Source§

impl<T> Clone for Vec4<T>
where T: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Vec4<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Vec4<T>
where T: Default,

Source§

fn default() -> Self

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

impl<T> Div<T> for Vec4<T>
where T: Div<Output = T> + Copy,

Source§

type Output = Vec4<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div for Vec4<T>
where T: Div<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for Vec4<T>
where T: Div<Output = T> + Copy,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T> DivAssign for Vec4<T>
where T: Div<Output = T> + Copy,

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl<T> From<[T; 4]> for Vec4<T>
where T: Copy,

Source§

fn from(x: [T; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Vec4<f32>

Source§

fn from(x: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Vec4<u8>

Source§

fn from(x: Color) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec4<T>> for [T; 4]
where T: Copy,

Source§

fn from(x: Vec4<T>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec4<f32>> for Color

Source§

fn from(x: Vec4<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec4<u8>> for Color

Source§

fn from(x: Vec4<u8>) -> Self

Converts to this type from the input type.
Source§

impl<T> Mul<T> for Vec4<T>
where T: Mul<Output = T> + Copy,

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul for Vec4<T>
where T: Mul<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for Vec4<T>
where T: Mul<Output = T> + Copy,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T> MulAssign for Vec4<T>
where T: Mul<Output = T> + Copy,

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<T> Neg for Vec4<T>
where T: Neg<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> Rem<T> for Vec4<T>
where T: Rem<Output = T> + Copy,

Source§

type Output = Vec4<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl<T> Rem for Vec4<T>
where T: Rem<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl<T> RemAssign<T> for Vec4<T>
where T: Rem<Output = T> + Copy,

Source§

fn rem_assign(&mut self, rhs: T)

Performs the %= operation. Read more
Source§

impl<T> RemAssign for Vec4<T>
where T: Rem<Output = T> + Copy,

Source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
Source§

impl<T> Sub<T> for Vec4<T>
where T: Sub<Output = T> + Copy,

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub for Vec4<T>
where T: Sub<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> SubAssign<T> for Vec4<T>
where T: Sub<Output = T> + Copy,

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl<T> SubAssign for Vec4<T>
where T: Sub<Output = T> + Copy,

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<T> Copy for Vec4<T>
where T: Copy,

Auto Trait Implementations§

§

impl<T> Freeze for Vec4<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vec4<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vec4<T>
where T: Send,

§

impl<T> Sync for Vec4<T>
where T: Sync,

§

impl<T> Unpin for Vec4<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vec4<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Content for T
where T: Copy,

Source§

type Owned = T

A type that holds a sized version of the content.
Source§

unsafe fn read<F, E>(size: usize, f: F) -> Result<T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

Prepares an output buffer, then turns this buffer into an Owned. User-provided closure F must only write to and not read from &mut Self.
Source§

fn get_elements_size() -> usize

Returns the size of each element.
Source§

fn to_void_ptr(&self) -> *const ()

Produces a pointer to the data.
Source§

fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>

Builds a pointer to this type from a raw pointer.
Source§

fn is_size_suitable(size: usize) -> bool

Returns true if the size is suitable to store a type like this.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

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>,

Source§

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.