pub struct Vec4<T> {
pub x: T,
pub y: T,
pub z: T,
pub w: T,
}Fields§
§x: T§y: T§z: T§w: TImplementations§
Source§impl<T> Vec4<T>
impl<T> Vec4<T>
Sourcepub fn new(x: T, y: T, z: T, w: T) -> Self
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
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> AddAssign<T> for Vec4<T>
impl<T> AddAssign<T> for Vec4<T>
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+= operation. Read moreSource§impl<T> AddAssign for Vec4<T>
impl<T> AddAssign for Vec4<T>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl AsUniformValue for Vec4<f32>
impl AsUniformValue for Vec4<f32>
Source§fn as_uniform_value(&self) -> UniformValue<'_>
fn as_uniform_value(&self) -> UniformValue<'_>
Builds a
UniformValue.Source§impl Attribute for Vec4<f32>
impl Attribute for Vec4<f32>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<f64>
impl Attribute for Vec4<f64>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<i16>
impl Attribute for Vec4<i16>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<i32>
impl Attribute for Vec4<i32>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<i64>
impl Attribute for Vec4<i64>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<i8>
impl Attribute for Vec4<i8>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<u16>
impl Attribute for Vec4<u16>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<u32>
impl Attribute for Vec4<u32>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<u64>
impl Attribute for Vec4<u64>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl Attribute for Vec4<u8>
impl Attribute for Vec4<u8>
Source§fn get_type() -> AttributeType
fn get_type() -> AttributeType
Get the type of data.
Source§fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
fn is_supported<C>(caps: &C) -> boolwhere
C: CapabilitiesSource + ?Sized,
Returns true if the backend supports this type of attribute.
Source§impl<T> DivAssign<T> for Vec4<T>
impl<T> DivAssign<T> for Vec4<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/= operation. Read moreSource§impl<T> DivAssign for Vec4<T>
impl<T> DivAssign for Vec4<T>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/= operation. Read moreSource§impl<T> MulAssign<T> for Vec4<T>
impl<T> MulAssign<T> for Vec4<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*= operation. Read moreSource§impl<T> MulAssign for Vec4<T>
impl<T> MulAssign for Vec4<T>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl<T> RemAssign<T> for Vec4<T>
impl<T> RemAssign<T> for Vec4<T>
Source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
Performs the
%= operation. Read moreSource§impl<T> RemAssign for Vec4<T>
impl<T> RemAssign for Vec4<T>
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
Performs the
%= operation. Read moreSource§impl<T> SubAssign<T> for Vec4<T>
impl<T> SubAssign<T> for Vec4<T>
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the
-= operation. Read moreSource§impl<T> SubAssign for Vec4<T>
impl<T> SubAssign for Vec4<T>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl<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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Content for Twhere
T: Copy,
impl<T> Content for Twhere
T: Copy,
Source§unsafe fn read<F, E>(size: usize, f: F) -> Result<T, E>
unsafe fn read<F, E>(size: usize, f: F) -> Result<T, 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
fn get_elements_size() -> usize
Returns the size of each element.
Source§fn to_void_ptr(&self) -> *const ()
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>
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
fn is_size_suitable(size: usize) -> bool
Returns true if the size is suitable to store a type like this.